2

For a given version of Godot, you can deterministically generate OpenSimplexNoise using seed (documentation).

However, in the documentation for RandomNumberGenerator there is the following:

Note: The underlying algorithm is an implementation detail. As a result, it should not be depended upon for reproducible random streams across Godot versions.

Some workarounds for the above issue are described here, the short answer is to write a custom portable RNG.

Is there any way to insert a custom RNG for OpenSimplexNoise to manage determinism? Is there another solution?

Dan Healy
  • 747
  • 7
  • 13

1 Answers1

1

The Godot developers are warning you that they might decide to change RandomNumberGenerator for a future version (also and some changes happened already).

And no, you can't insert a custom random number generator for OpenSimplexNoise.

Anyway, OpenSimplexNoise does not use RandomNumberGenerator or rand. Instead it takes this library as a git module: smcameron/open-simplex-noise-in-c.

Does OpenSimplexNoise change? Rarely. However, there is a breaking change in OpenSimplexNoise for Godot 4 and 3.4: the axis has been swaped (this is a fix).


So that leads us to add a custom noise solution. Which could be a port of OpenSimplex noise to C# or GDScript.

See open-simplex-noise.c from Godot source and digitalshadow/OpenSimplexNoise.cs (which is a port to C#, there are some other ports linked in the comments there too).


And for the texture, there are a couple options:

  • You can create a script that draws the image (I suggest using lockbits) and set it.
  • Or you can extend Viewport (which entains adding a Viewport to the scene and attaching a script). Then you take advantage of ViewportTexture, and you can take advantage of shaders to create the texture you want. Take BastiaanOlij/godot-noise-texture-asset for reference.
Theraot
  • 31,890
  • 5
  • 57
  • 86
  • Looking at the library it uses, it’s based on a linear congruential generator written in C. I think this guarantees determinism and portability so long as I am using this library. For me, I think this means I can use it and not worry, unless that implementation changes and I need to upgrade godot version for some reason. In that case, I could probably invoke the library directly myself – Dan Healy Sep 22 '21 at 04:20