Turbulence is the pseudo-random displacement of the input value.
The get(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 Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault power for theTurbulencenoise module.Fields inherited from class org.spongepowered.noise.module.NoiseModule
sourceModule -
Constructor Summary
ConstructorsConstructorDescriptionTurbulence(NoiseModule source) Create a new Turbulence module with the source modules pre-configured. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGet the frequency of the turbulence.doubleget(double x, double y, double z) Generates an output value given the coordinates of the specified input value.doublepower()Get the power of the turbulence.intGet the roughness of the turbulence.intseed()Get the seed of the internal Perlin-noise modules that are used to displace the input values.voidsetFrequency(double frequency) Set the frequency of the turbulence.voidsetPower(double power) Set the power of the turbulence.voidsetRoughness(int roughness) Set the roughness of the turbulence.voidsetSeed(int seed) Set the seed of the internal Perlin-noise modules that are used to displace the input values.Methods inherited from class org.spongepowered.noise.module.NoiseModule
setSourceModule, sourceModule, sourceModuleCount
-
Field Details
-
DEFAULT_TURBULENCE_POWER
public static final double DEFAULT_TURBULENCE_POWERDefault power for theTurbulencenoise module.- See Also:
-
-
Constructor Details
-
Turbulence
public Turbulence() -
Turbulence
Create a new Turbulence module with the source modules pre-configured.- Parameters:
source- the input module
-
-
Method Details
-
power
public double power()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:
-
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
-
roughnessCount
public int roughnessCount()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
Perlinnoise modules that displace the input value: one for thex, one for they, and one for thezcoordinates. The roughness value is equal to the number of octaves used by thePerlinnoise modules.- Parameters:
roughness- the roughness of the turbulence
-
frequency
public double frequency()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
-
seed
public int seed()Get the seed of the internal Perlin-noise modules that are used to displace the input values.Internally, there are three
Perlinnoise modules that displace the input value: one for thex, one for they, and one for thezcoordinates.- 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
Perlinnoise modules that displace the input value: one for thex, one for they, and one for thezcoordinates. This noise module assigns the following seed values to thePerlinnoise modules:- It assigns the seed value
seed + 0to thexnoise module. - It assigns the seed value
seed + 1to theynoise module. - It assigns the seed value
seed + 2to theznoise module.
- Parameters:
seed- the seed value
- It assigns the seed value
-
get
public double get(double x, double y, double z) Description copied from class:NoiseModuleGenerates an output value given the coordinates of the specified input value.All source modules required by this module must have been connected with the
NoiseModule.setSourceModule(int, NoiseModule)method. If these source modules are not connected, this method will throw aNoModuleException.To determine the number of source modules required by this noise module, call the
NoiseModule.sourceModuleCount()method.- Specified by:
getin classNoiseModule- Parameters:
x- thexcoordinate of the input valuey- theycoordinate of the input valuez- thezcoordinate of the input value- Returns:
- the output value
-