Class Turbulence


  • public class Turbulence
    extends Module
    Noise module that randomly displaces the input value before returning the output value from a source module.

    Turbulence is the pseudo-random displacement of the input value. The getValue(double, double, double) method randomly displaces the (x, y, z) coordinates of the input value before retrieving the output value from the source module. To control the turbulence, an application can modify its frequency, its power, and its roughness.

    The frequency of the turbulence determines how rapidly the displacement amount changes. To specify the frequency, call the setFrequency(double) method.

    he power of the turbulence determines the scaling factor that is applied to the displacement amount. To specify the power, call the setPower(double) method.

    The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes. To specify the roughness, call the setRoughness(int) method.

    Use of this noise module may require some trial and error. Assuming that you are using a generator module as the source module, you should first:

    • Set the frequency to the same frequency as the source module.
    • Set the power to the reciprocal of the frequency.

    From these initial frequency and power values, modify these values until this noise module produce the desired changes in your terrain or texture. For example:

    • Low frequency (1/8 initial frequency) and low power (1/8 initial power) produces very minor, almost unnoticeable changes.
    • Low frequency (1/8 initial frequency) and high power (8 times initial power) produces "ropey" lava-like terrain or marble-like textures.
    • High frequency (8 times initial frequency) and low power (1/8 initial power) produces a noisy version of the initial terrain or texture.
    • High frequency (8 times initial frequency) and high power (8 times initial power) produces nearly pure noise, which isn't entirely useful.

    Displacing the input values result in more realistic terrain and textures. If you are generating elevations for terrain height maps, you can use this noise module to produce more realistic mountain ranges or terrain features that look like flowing lava rock. If you are generating values for textures, you can use this noise module to produce realistic marble-like or "oily" textures.

    Internally, there are three noise::module::Perlin noise modules that displace the input value; one for the x, one for the y, and one for the z coordinate.

    Source Modules
    This module requires one source module.
    • Field Detail

      • DEFAULT_TURBULENCE_POWER

        public static final double DEFAULT_TURBULENCE_POWER
        Default power for the Turbulence noise module.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Turbulence

        public Turbulence()
      • Turbulence

        public Turbulence​(Module source)
        Create a new Turbulence module with the source modules pre-configured.
        Parameters:
        source - the input module
    • Method Detail

      • getPower

        public double getPower()
        Get the power of the turbulence.

        The power of the turbulence determines the scaling factor that is applied to the displacement amount.

        Returns:
        the power of the turbulence
        See Also:
        DEFAULT_TURBULENCE_POWER
      • setPower

        public void setPower​(double power)
        Set the power of the turbulence.

        The power of the turbulence determines the scaling factor that is applied to the displacement amount.

        Parameters:
        power - the power of the turbulence
      • getRoughnessCount

        public int getRoughnessCount()
        Get the roughness of the turbulence.

        The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes.

        Returns:
        the roughness of the turbulence
      • setRoughness

        public void setRoughness​(int roughness)
        Set the roughness of the turbulence.

        The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes.

        Internally, there are three Perlin noise modules that displace the input value: one for the x, one for the y, and one for the z coordinates. The roughness value is equal to the number of octaves used by the Perlin noise modules.

        Parameters:
        roughness - the roughness of the turbulence
      • getFrequency

        public double getFrequency()
        Get the frequency of the turbulence.

        The frequency of the turbulence determines how rapidly the displacement amount changes.

        Returns:
        the frequency of the turbulence
      • setFrequency

        public void setFrequency​(double frequency)
        Set the frequency of the turbulence.

        The frequency of the turbulence determines how rapidly the displacement amount changes.

        Parameters:
        frequency - the frequency of the turbulence
      • getSeed

        public int getSeed()
        Get the seed of the internal Perlin-noise modules that are used to displace the input values.

        Internally, there are three Perlin noise modules that displace the input value: one for the x, one for the y, and one for the z coordinates.

        Returns:
        the seed value
      • setSeed

        public void setSeed​(int seed)
        Set the seed of the internal Perlin-noise modules that are used to displace the input values.

        Internally, there are three Perlin noise modules that displace the input value: one for the x, one for the y, and one for the z coordinates. This noise module assigns the following seed values to the Perlin noise modules:

        • It assigns the seed value seed + 0 to the x noise module.
        • It assigns the seed value seed + 1 to the y noise module.
        • It assigns the seed value seed + 2 to the z noise module.
        Parameters:
        seed - the seed value
      • getValue

        public double getValue​(double x,
                               double y,
                               double z)
        Description copied from class: Module
        Generates an output value given the coordinates of the specified input value.

        All source modules required by this module must have been connected with the Module.setSourceModule(int, Module) method. If these source modules are not connected, this method will throw a NoModuleException.

        To determine the number of source modules required by this noise module, call the Module.getSourceModuleCount() method.

        Specified by:
        getValue in class Module
        Parameters:
        x - the x coordinate of the input value
        y - the y coordinate of the input value
        z - the z coordinate of the input value
        Returns:
        the output value