Dan Healy
Dan Healy

Reputation: 757

Deterministic OpenSimplexNoise across Godot versions

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?

Upvotes: 2

Views: 694

Answers (1)

Theraot
Theraot

Reputation: 40285

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.

Upvotes: 1

Related Questions