Class SorbetNoise

java.lang.Object
com.github.yellowstonegames.grid.CyclicNoise
com.github.yellowstonegames.grid.SorbetNoise
All Implemented Interfaces:
INoise, Externalizable, Serializable

@Beta public class SorbetNoise extends CyclicNoise
A mix of 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:
  • 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

      public SorbetNoise stringDeserialize(String data)
      Description copied from interface: INoise
      Given a serialized String produced by INoise.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 implements INoise.stringSerialize() should also implement this method in a compatible way. Using base-10 is expected for most uses. Using Base.BASE10.readFloat(data, start, end) may be useful to parse only the part of data between start and end.
      The default implementation throws an UnsupportedOperationException only. INoise classes do not have to implement any serialization methods, but they aren't serializable by the methods in this class or in INoise.Serializer unless they do implement this, INoise.getTag(), INoise.stringSerialize(), and INoise.copy().
      Specified by:
      stringDeserialize in interface INoise
      Overrides:
      stringDeserialize in class CyclicNoise
      Parameters:
      data - a serialized String, typically produced by INoise.stringSerialize()
      Returns:
      this INoise, after being modified (if possible)
    • recreateFromString

      public static SorbetNoise recreateFromString(String data)
    • getNoise

      public float getNoise(float x, float y)
      Description copied from interface: INoise
      Gets 2D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class CyclicNoise
      Parameters:
      x - x position; can be any finite float
      y - 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: INoise
      Gets 3D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class CyclicNoise
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - 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: INoise
      Gets 4D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class CyclicNoise
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - z position; can be any finite float
      w - 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: INoise
      Gets 5D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class CyclicNoise
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - z position; can be any finite float
      w - w position; can be any finite float
      u - 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: INoise
      Gets 6D noise with a default or pre-set seed.
      Specified by:
      getNoise in interface INoise
      Overrides:
      getNoise in class CyclicNoise
      Parameters:
      x - x position; can be any finite float
      y - y position; can be any finite float
      z - z position; can be any finite float
      w - w position; can be any finite float
      u - u position; can be any finite float
      v - v position; can be any finite float
      Returns:
      a noise value between -1.0f and 1.0f, both inclusive
    • toString

      public String toString()
      Overrides:
      toString in class CyclicNoise
    • getTag

      public String getTag()
      Description copied from interface: INoise
      Returns a typically-four-character String constant that should uniquely identify this INoise as well as possible. If a duplicate tag is already registered and INoise.Serializer.register(INoise) attempts to register the same tag again, a message is printed to System.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:
      getTag in interface INoise
      Overrides:
      getTag in class CyclicNoise
      Returns:
      a short String constant that identifies this INoise type
    • copy

      public SorbetNoise copy()
      Description copied from interface: INoise
      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. This almost always just calls a copy constructor.
      The default implementation throws an UnsupportedOperationException only. Implementors are strongly encouraged to implement this in general, and that is required to use an INoise class with INoise.Serializer.
      Specified by:
      copy in interface INoise
      Overrides:
      copy in class CyclicNoise
      Returns:
      a copy of this INoise
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface INoise
      Overrides:
      equals in class CyclicNoise