Qubit Noise Library | Generate complex and realistic noise maps in seconds

Qubit Noise Library

Download | Github

Introduction


Hello devforum! This will be one of my first community resources I have made, and I hope it's a useful module that many of you will use. The initial usecase of this module was to help me generate terrain for one of my games but that projects was recently scrapped so the module has been unused for a while. I believed others would probably find use in this module so here I am today.

Information


This noise module contains many features, such as persistence, lacunarity and octaves. These features are commonly used on other game engines to produce more realistic looking noise, or to customise it further (it's entirely up to you).

Usage


Generate Partial2DNoiseMap

Generate Partial2DNoiseMap

A Partial2DNoiseMap, is a noise map that will generate asynchronously. This means that you will need to use the event it returns to detect when a new noise value is added to its table. This may be useful if you are generating an enourmous NoiseMap and don't want to wait for it to finish (even though the times are relatively quick). This function can accept a table of settings or individual parameters

Usage:

noise.generate2DPartialMap(width, height, [optional] seed, scale,[optional] octaves, persistence, lacunarity, [optional] offset, normalise)
returns BindableEvent, noiseAdded

or:

noise.generate2DPartialMap(noiseSettings)

returns BindableEvent, noiseAdded

Example Code:

-- Generating noise using individual parameters
local noiseEvent = QubitNoise.generate2DPartialMap(15, 15, os.clock(), 25, 1, 0.5, 1, Vector2.new(0, 0))

-- Generating noise using noiseSettings local noiseSettings = {width = 15, height = 15, scale = 25, persistence = 0.5, lacunarity = 1} local noiseEvent = QubitNoise.generate2DPartialMap(noiseSettings)
noiseEvent:Connect(function(x, y, noise) print(string.format("%d, %d = %f", x, y, noise)) end)

Generate 2DNoiseMap

Generate 2DNoiseMap

This function internally calls noise.generate2DPartialMap function, but instead will run synchronuosly and will yield the thread until all the noise values have been generated and returned. (this is typically the one you will be most likely to use)

Usage:

noise.generate2DNoiseMap(width, height, [optional] seed, scale,[optional] octaves, persistence, lacunarity, [optional] offset, normalise)
returns 2D Table, noiseValues

or:

noise.generate2DNoiseMap(noiseSettings)

returns 2D Table, noiseValues

Example Code:

-- Generating noise using individual parameters
local noise = QubitNoise.generate2DNoiseMap(15, 15, os.clock(), 25, 1, 0.5, 1, Vector2.new(0, 0))

-- Generating noise using noiseSettings local noiseSettings = {width = 15, height = 15, scale = 25, persistence = 0.5, lacunarity = 1} local noiseEvent = QubitNoise.generate2DNoiseMap(noiseSettings)
print(string.format("1, 1 = %f", noise[1][1]))

Generate Circular Gradient

Generate Circular Gradient

This function is more or less a utility function if you want to use this in generation, I originally added it so I could create a circle gradient around a generated map so I could construct denser land masses towards the center of the circle and fade out outside. It may still be useful so I have decided to leave it in the module, it functions almost identically to the noise generation.

Usage:

noise.generateRadialGradient(width, length, shouldNormalise)
returns 2D Table, gradient

Example Code:

-- Generating gradient
local gradient = QubitNoise.generateRadialGradient(25, 25, true)

print(string.format("min = %d, max = %d", gradient.min, gradient.max)) print(string.format("1, 1 = %d", gradient[1][1]))

Showcase


Here are a few images/videos of the noise map being used with my terrain generator, to generate landmasses. The entire system uses the noise values from the Noise Generator and just instances new blocks into the world - offsetting the y position by the noise value - and setting the material depending on the noise value (e.g sand if the noise value < 0.75)

Beach Island

Noise Settings
- Seed: 18764.7645253
- Octaves: 35
- Persistence: 1
- Lacunarity: 0.25
22 Likes

Looking over it now, looks really well coded! Just curious as to why you’re using all the asserts for type checking when that’s all been added in with Luau?

1 Like

I initially made the module a while back for one of my projects, and as a result typed lua wasn’t really available at the time. If people like the module I might make a typed version, and even add 3D Noise support. Thanks for your response :grinning_face_with_smiling_eyes:

3 Likes

Can’t see anything on the showcase. Are you able to provide picture examples?

I Apologise for that, I uploaded some pictures but roblox seemed to have broken them when system edited it. I’ll send you the picture that was supposed to be there

1 Like

I can vouch, the code is well made and it works perfectly

1 Like

Fixed a minor bug, noise arrays were starting at 0, so you would need to index noise[0][0], this has been corrected to value lua standards of noise[1][1]

1 Like

Heya! Sorry to bother y’all, but for some reason whenever I input the linked model it only loads in the QubitTerrainGenerator. I can’t for the life of me find the actual QubitNoiseLibrary anywhere, and that’s causing things to error out. Is there something I should be doing differently? Thanks!

1 Like

Thanks for reporting that, I appear to have uploaded an alternate module in place of the noise module. :man_facepalming: I’ve reuploaded the noise module.

I wasn’t planning on releasing the terrain generator soon, but I guess you get to have an early copy :grinning_face_with_smiling_eyes:

3 Likes

Update 1b

Finally setup a github page.
I have also created 2 separate branches, one for the typed version (that is still in development) and one for the non-typed lua version.

Here are some features I have planned:

  • 3D Noise
  • Try and squeeze out more performance
  • Different noise types (Simplex, Cellular, etc)

If you have more suggestions/things you want added please go ahead and tell me (i’m always open).
I also hope on releasing the terrain generator bundled with the noise gen but it still needs a lot of work.

2 Likes

Just a minor change but i’ve added a more detailed readme.md on the git page which has better documentation

Update 1.3.2a

I recently pushed an update to the github luau-typed branch which adds types to all of the functions, I’ve also made a tiny little change which changes the PartialMap generator where I have replaced BindableEvents with a custom Signal library by Stravant

Work has also started on adding new noise functions to the library such as those mentioned above:

(Simplex, Cellular, etc)



You can view the Commit Here