Hello developers! I’ve been working on this for the past few days now and I think I’m about ready to put out a released version of this. This is a fully self-contained implementation of the Simplex Noise algorithm as popularized by Ken Perlin, all in Lua no less. It offers much more customization than the standard Roblox
math.noise functionality, as you can initialize Octave objects with their own respective seeds. This version currently offers 2D and 3D evaluation, both scaled to be in the [-1,1] range. If you’re interested in the module you can grab a copy of it here:
Here’s an example of a terrain map I generated using this algorithm and my marching cubes implementation:
A standard use of this module will generally look like this:
local Simplex = require(script.SimplexModule) local Octave = Simplex() --Here you can provide a seed value, although one is not required --If no seed is provided, a random seed is generated instead. Octave:Init() --Must be called to initialize the octave for x = 1,10 do for y = 1,10 do local Noise2D = Octave:Get2DValue(x,y) -- Retrieve a value from a 2D point for z = 1,10 do local Noise3D = Octave:Get3DValue(x,y,z) -- Retrieve a value from 3D point end end end
Now, enough about the code, how does it stack up performance wise?
Here are the current benchmarks:
0.23782290000236 -- My Module 0.032688800012693 -- math.noise
These benchmarks are for the 2D implementation of the module. The 3D version suffers almost 1.5 times worse in comparison.
So yeah… the performance is not the best. this is mostly due to a few factors: bit manipulation is too expensive, to the point where modulo was actually faster (somehow…), and this is Lua. Lua isn’t nearly as fast as the C-side implementation of math.noise although Roblox if you read this a simplex noise module would be pretty sweet y’know?
Anyways, if you’re thinking about using this for a procedural or real-time use case, I would highly advise using math.noise instead, as the performance benefits far outweigh the visual improvements and versatility. However, I would say this is very well suited for something like a plugin or single-use implementation, where performance is not the utmost priority.
Thank you for reading, and I hope this module provides something for you! Until next time!