Help with OpenSimplex 4D Noise banding

image










I am currently using this Module for the 4D noise in order to generate the base terrain shape. I am trying to use 4D noise so I could use the 4th as a seed and the other 3 for “cave-like” structures (in the pictures they don’t look like caves, more like plains, but this is so it’s easier to visualize).

My problem now is this “banding” which occurs periodically which is dependent on the frequency/lacunarity. From my observations these “artefacts” basically shift the terrain/noise in some direction and… that’s it. And to get the noise at a specific position I do:

local noiseModule = require(game.ServerScriptService.NoiseModule)
noiseModule.Seed(math.random(-2^23, 2^23-1))

local noise = noiseModule.Classic3D(x/frequency, y/frequency, z/frequency) * amplitude
-- with this module you don't actually need the 4th dimension for seeds, because you have to seed it beforehand

I don’t know if I am doing something wrong when passing the position, but I have tried 2 other modules with 4D noise, but with all of them the same thing happens. One of the other ones is this one: Simplex Noise Module with which I did:

local otherNoiseModule = require(game.ServerScriptService.OtherNoiseModule)
local noise = otherNoiseModule.Noise4D(x/frequency, y/frequency, z/frequency, seed) * amplitude

I tried searching for other modules or other people that have had the same problem, but I couldn’t find anything. The only close thing was this guy trying to do procedural terrain generation in Unity: c# - Implementing Scape's "Procedural Basics" Perlin Noise in Unity - Stack Overflow

If someone has some idea on what’s going on, please, do let me know!

Which axis are the bands on and how far apart are they?

So the band’s frequency (how far apart they are) is dependent on the lacunarity of the noise. So if I set the lacunarity at 100 the bands will be spaced every 600 studs (150 voxels), or lacunarity at 50 = 300 studs (75 voxels) => for each 1 “lacunarity value”, a band will appear every other 6 studs (1.5 voxels).
*note that I “calculated” it visually, not with code, because I have no idea what’s causing it, so I can’t take the output and measure it with code

And for the axis, well if you look at the pictures you can see that it is sort of a diagonal on all X, Y and Z axis. Although when I was messing with the source code of the module, trying to fix it, I changed the constant 0.(6) or 1/3*2 on line 244 to 1 and it made the artefacts horizontal, which also changed the terrain’s angle, which is now facing the way that the artefacts were facing when the constant was 0.(6)


But in general it is in all 3 axis.

Here’s how you can check if it’s your code or if there’s a bug in the OS implementation:

Try it with math.noise and just don’t have a random seed, or have a random seed by adding a large, random number to one of the axes.

If the artifacts are also present with math.noise then it’s your code that’s the problem, otherwise it’s the OS module.

1 Like

So because I need all 3 axis from the noise in order to get the “density”, I have to put all X, Y and Z in the math.noise's arguments, that means I can’t have seeds with the integrated noise function. But I just tested it and yes there aren’t any artefacts with it.

Of course that doesn’t mean that’s the solution, I still need these seeds, because the whole idea is that every time the terrain is different.

1 Like

Hey Harry. The second module you linked as an example of others you tried doesn’t support 4D noise, but it looks like you’re actually just looking for 3D noise that you can seed, which it will work for. The code example provided does not match my module’s implementation though, I’m not entirely sure what you did.

I’ve used it extensively for a couple different projects and can confirm from my and other users’ experiences that the module works, if you’re having some issues it’s most likely with your code, could you show me exactly how you were using my module here?

1 Like

Oops! I’m so sorry! Because I was looking for 4D noise modules or seeded 3D, I’ve put like 5 different modules in the place and I just got confused. My script literally looks like this:

	--local noise = math.noise(x/frequency, y/frequency, z/frequency) * amplitude
	--local noise = noiseModule2.Classic3D(x/frequency, y/frequency, z/frequency) * amplitude
	--local noise = noiseModule.Noise4D(x/frequency, y/frequency, z/frequency, seed) * amplitude
	local noise = noiseModule4:Get3DValue(x/frequency, y/frequency, z/frequency) * amplitude
	--local noise = noiseModule3.noise3_Classic(x/frequency, y/frequency, z/frequency) * amplitude

And after you mentioned it I actually went back and tested your module again and for some reason it works. I don’t remember why I “skipped” it an continued looking for some other, but it does work with what I am trying to do. And this is the right way for implementing your code:

local noiseModule = require(game.ServerScriptService.NoiseModule)
noiseModule(math.random(-2^23, 2^23-1))

local noise = noiseModule:Get3DValue(x/frequency, y/frequency, z/frequency) * amplitude

But I am unsure if I would mark this as the solution, because the idea of this topic is how to fix the banding… with the… eh whatever I’ll just do it.

And once again, sorry for the inconvenience.

And here’s the result:
image

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.