Class SorbetNoise
java.lang.Object
com.github.yellowstonegames.grid.CyclicNoise
com.github.yellowstonegames.grid.SorbetNoise
- All Implemented Interfaces:
INoise, Externalizable, Serializable
A mix of
This is still very much in beta. 3D SorbetNoise can often have very obvious waves of high and low values pass through the noise field in straight-line bands. Higher dimensions tend to look better. This is somewhat unusual because this uses SimplexNoise, which looks drastically worse in dimensions 5 and up, but because CyclicNoise looks better around those dimensions, the quality changes offset each other.
CyclicNoise with Simplex noise; much less periodic than CyclicNoise alone. Largely based upon
this ShaderToy by jeyko, which in turn is based on
this ShaderToy by nimitz. This uses cyclic noise with a
dimension one higher than requested, and uses a call to SimplexNoise.noise(float, float, long) to fill that parameter.
This is still very much in beta. 3D SorbetNoise can often have very obvious waves of high and low values pass through the noise field in straight-line bands. Higher dimensions tend to look better. This is somewhat unusual because this uses SimplexNoise, which looks drastically worse in dimensions 5 and up, but because CyclicNoise looks better around those dimensions, the quality changes offset each other.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface INoise
INoise.Serializer -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSorbetNoise(int octaves) SorbetNoise(long seed, int octaves) SorbetNoise(long seed, int octaves, float frequency) -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of this INoise, which should be a deep copy for any mutable state but can be shallow for immutable types such as functions.booleanfloatgetNoise(float x, float y) Gets 2D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z) Gets 3D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w) Gets 4D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w, float u) Gets 5D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w, float u, float v) Gets 6D noise with a default or pre-set seed.getTag()Returns a typically-four-character String constant that should uniquely identify this INoise as well as possible.static SorbetNoiserecreateFromString(String data) stringDeserialize(String data) Given a serialized String produced byINoise.stringSerialize(), reassigns this INoise to have the described state from the given String.toString()Methods inherited from class CyclicNoise
getFrequency, getMaxDimension, getMinDimension, getNoise, getOctaves, getSeed, hasEfficientSetSeed, hashCode, setFrequency, setOctaves, setSeed, setSeed, stringSerializeMethods inherited from interface INoise
getNoiseWithSeed, getNoiseWithSeed, getNoiseWithSeed, getNoiseWithSeed, getNoiseWithSeed, getNoiseWithSeed, readExternal, writeExternal
-
Constructor Details
-
SorbetNoise
public SorbetNoise() -
SorbetNoise
public SorbetNoise(int octaves) -
SorbetNoise
public SorbetNoise(long seed, int octaves) -
SorbetNoise
public SorbetNoise(long seed, int octaves, float frequency)
-
-
Method Details
-
stringDeserialize
Description copied from interface:INoiseGiven a serialized String produced byINoise.stringSerialize(), reassigns this INoise to have the described state from the given String. The serialized String must have been produced by the same class as this object is.
Any class that implementsINoise.stringSerialize()should also implement this method in a compatible way. Using base-10 is expected for most uses. UsingBase.BASE10.readFloat(data, start, end)may be useful to parse only the part of data between start and end.
The default implementation throws anUnsupportedOperationExceptiononly. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or inINoise.Serializerunless they do implement this,INoise.getTag(),INoise.stringSerialize(), andINoise.copy().- Specified by:
stringDeserializein interfaceINoise- Overrides:
stringDeserializein classCyclicNoise- Parameters:
data- a serialized String, typically produced byINoise.stringSerialize()- Returns:
- this INoise, after being modified (if possible)
-
recreateFromString
-
getNoise
public float getNoise(float x, float y) Description copied from interface:INoiseGets 2D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classCyclicNoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z) Description copied from interface:INoiseGets 3D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classCyclicNoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w) Description copied from interface:INoiseGets 4D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classCyclicNoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w, float u) Description copied from interface:INoiseGets 5D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classCyclicNoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w, float u, float v) Description copied from interface:INoiseGets 6D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Overrides:
getNoisein classCyclicNoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite floatv- v position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
toString
- Overrides:
toStringin classCyclicNoise
-
getTag
Description copied from interface:INoiseReturns a typically-four-character String constant that should uniquely identify this INoise as well as possible. If a duplicate tag is already registered andINoise.Serializer.register(INoise)attempts to register the same tag again, a message is printed toSystem.err. The default implementation returns the String(NO), which is essentially an invalid tag, meant to indicate that this was not fully implemented. Implementing this is required for any usage of Serializer.- Specified by:
getTagin interfaceINoise- Overrides:
getTagin classCyclicNoise- Returns:
- a short String constant that identifies this INoise type
-
copy
Description copied from interface:INoiseCreates a copy of this INoise, which should be a deep copy for any mutable state but can be shallow for immutable types such as functions. This almost always just calls a copy constructor.
The default implementation throws anUnsupportedOperationExceptiononly. Implementors are strongly encouraged to implement this in general, and that is required to use an INoise class withINoise.Serializer.- Specified by:
copyin interfaceINoise- Overrides:
copyin classCyclicNoise- Returns:
- a copy of this INoise
-
equals
- Specified by:
equalsin interfaceINoise- Overrides:
equalsin classCyclicNoise
-