diff options
author | Hendrik Brucker <hendrik.brucker@mail.de> | 2022-03-20 14:53:45 +0100 |
---|---|---|
committer | Hendrik Brucker <hendrik.brucker@mail.de> | 2022-03-20 14:53:45 +0100 |
commit | 2a55f10e8be2d3a9ffcbb57ab6dd278419c64b37 (patch) | |
tree | 90bf78ae0c5bfa29092398a0dd10ea2a304462ec /modules/noise/doc_classes | |
parent | c251ea01db289feb2f0b237eb3d865e28b0fa1cb (diff) |
Add FastNoiseLite / general noise overhaul
- replace OpenSimplexNoise
Co-authored-by: Cory Petkovsek <tinmanjuggernaut@users.noreply.github.com>
Diffstat (limited to 'modules/noise/doc_classes')
-rw-r--r-- | modules/noise/doc_classes/FastNoiseLite.xml | 169 | ||||
-rw-r--r-- | modules/noise/doc_classes/Noise.xml | 72 | ||||
-rw-r--r-- | modules/noise/doc_classes/NoiseTexture.xml | 47 |
3 files changed, 288 insertions, 0 deletions
diff --git a/modules/noise/doc_classes/FastNoiseLite.xml b/modules/noise/doc_classes/FastNoiseLite.xml new file mode 100644 index 0000000000..b6d91850c4 --- /dev/null +++ b/modules/noise/doc_classes/FastNoiseLite.xml @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="FastNoiseLite" inherits="Noise" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> + <brief_description> + Generates noise using the FastNoiseLite library. + </brief_description> + <description> + This class generates noise using the FastNoiseLite library, which is a collection of several noise algorithms including Cellular, Perlin, Value, and more. + Most generated noise values are in the range of [code][-1,1][/code], however not always. Some of the cellular noise algorithms return results above [code]1[/code]. + </description> + <tutorials> + </tutorials> + <members> + <member name="cellular_distance_function" type="int" setter="set_cellular_distance_function" getter="get_cellular_distance_function" enum="FastNoiseLite.CellularDistanceFunction" default="0"> + Determines how the distance to the nearest/second-nearest point is computed. See [enum CellularDistanceFunction] for options. + </member> + <member name="cellular_jitter" type="float" setter="set_cellular_jitter" getter="get_cellular_jitter" default="0.45"> + Maximum distance a point can move off of its grid position. Set to [code]0[/code] for an even grid. + </member> + <member name="cellular_return_type" type="int" setter="set_cellular_return_type" getter="get_cellular_return_type" enum="FastNoiseLite.CellularReturnType" default="0"> + Return type from cellular noise calculations. See [enum CellularReturnType]. + </member> + <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> + A [Gradient] which is used to map the luminance of each pixel to a color value. + </member> + <member name="domain_warp_amplitude" type="float" setter="set_domain_warp_amplitude" getter="get_domain_warp_amplitude" default="30.0"> + Sets the maximum warp distance from the origin. + </member> + <member name="domain_warp_enabled" type="bool" setter="set_domain_warp_enabled" getter="is_domain_warp_enabled" default="false"> + If enabled, another FastNoiseLite instance is used to warp the space, resulting in a distortion of the noise. + </member> + <member name="domain_warp_fractal_gain" type="float" setter="set_domain_warp_fractal_gain" getter="get_domain_warp_fractal_gain" default="0.5"> + Determines the strength of each subsequent layer of the noise which is used to warp the space. + A low value places more emphasis on the lower frequency base layers, while a high value puts more emphasis on the higher frequency layers. + </member> + <member name="domain_warp_fractal_lacunarity" type="float" setter="set_domain_warp_fractal_lacunarity" getter="get_domain_warp_fractal_lacunarity" default="6.0"> + Octave lacunarity of the fractal noise which warps the space. Increasing this value results in higher octaves producing noise with finer details and a rougher appearance. + </member> + <member name="domain_warp_fractal_octaves" type="int" setter="set_domain_warp_fractal_octaves" getter="get_domain_warp_fractal_octaves" default="5"> + The number of noise layers that are sampled to get the final value for the fractal noise which warps the space. + </member> + <member name="domain_warp_fractal_type" type="int" setter="set_domain_warp_fractal_type" getter="get_domain_warp_fractal_type" enum="FastNoiseLite.DomainWarpFractalType" default="1"> + The method for combining octaves into a fractal which is used to warp the space. See [enum DomainWarpFractalType]. + </member> + <member name="domain_warp_frequency" type="float" setter="set_domain_warp_frequency" getter="get_domain_warp_frequency" default="0.05"> + Frequency of the noise which warps the space. Low frequency results in smooth noise while high frequency results in rougher, more granular noise. + </member> + <member name="domain_warp_type" type="int" setter="set_domain_warp_type" getter="get_domain_warp_type" enum="FastNoiseLite.DomainWarpType" default="0"> + Sets the warp algorithm. See [enum DomainWarpType]. + </member> + <member name="fractal_gain" type="float" setter="set_fractal_gain" getter="get_fractal_gain" default="0.5"> + Determines the strength of each subsequent layer of noise in fractal noise. + A low value places more emphasis on the lower frequency base layers, while a high value puts more emphasis on the higher frequency layers. + </member> + <member name="fractal_lacunarity" type="float" setter="set_fractal_lacunarity" getter="get_fractal_lacunarity" default="2.0"> + Frequency multiplier between subsequent octaves. Increasing this value results in higher octaves producing noise with finer details and a rougher appearance. + </member> + <member name="fractal_octaves" type="int" setter="set_fractal_octaves" getter="get_fractal_octaves" default="5"> + The number of noise layers that are sampled to get the final value for fractal noise types. + </member> + <member name="fractal_ping_pong_strength" type="float" setter="set_fractal_ping_pong_strength" getter="get_fractal_ping_pong_strength" default="2.0"> + Sets the strength of the fractal ping pong type. + </member> + <member name="fractal_type" type="int" setter="set_fractal_type" getter="get_fractal_type" enum="FastNoiseLite.FractalType" default="1"> + The method for combining octaves into a fractal. See [enum FractalType]. + </member> + <member name="fractal_weighted_strength" type="float" setter="set_fractal_weighted_strength" getter="get_fractal_weighted_strength" default="0.0"> + Higher weighting means higher octaves have less impact if lower octaves have a large impact. + </member> + <member name="frequency" type="float" setter="set_frequency" getter="get_frequency" default="0.01"> + The frequency for all noise types. Low frequency results in smooth noise while high frequency results in rougher, more granular noise. + </member> + <member name="in_3d_space" type="bool" setter="set_in_3d_space" getter="is_in_3d_space" default="false"> + Determines whether the noise image returned by [method Noise.get_image] is calculated in 3d space. May result in reduced contrast. + </member> + <member name="noise_type" type="int" setter="set_noise_type" getter="get_noise_type" enum="FastNoiseLite.NoiseType" default="1"> + The noise algorithm used. See [enum NoiseType]. + </member> + <member name="offset" type="Vector3" setter="set_offset" getter="get_offset" default="Vector3(0, 0, 0)"> + Translate the noise input coordinates by the given [Vector3]. + </member> + <member name="seed" type="int" setter="set_seed" getter="get_seed" default="0"> + The random number seed for all noise types. + </member> + </members> + <constants> + <constant name="TYPE_VALUE" value="5" enum="NoiseType"> + A lattice of points are assigned random values then interpolated based on neighboring values. + </constant> + <constant name="TYPE_VALUE_CUBIC" value="4" enum="NoiseType"> + Similar to Value noise, but slower. Has more variance in peaks and valleys. + Cubic noise can be used to avoid certain artifacts when using value noise to create a bumpmap. In general, you should always use this mode if the value noise is being used for a heightmap or bumpmap. + </constant> + <constant name="TYPE_PERLIN" value="3" enum="NoiseType"> + A lattice of random gradients. Their dot products are interpolated to obtain values in between the lattices. + </constant> + <constant name="TYPE_CELLULAR" value="2" enum="NoiseType"> + Cellular includes both Worley noise and Voronoi diagrams which creates various regions of the same value. + </constant> + <constant name="TYPE_SIMPLEX" value="0" enum="NoiseType"> + As opposed to [constant TYPE_PERLIN], gradients exist in a simplex lattice rather than a grid lattice, avoiding directional artifacts. + </constant> + <constant name="TYPE_SIMPLEX_SMOOTH" value="1" enum="NoiseType"> + Modified, higher quality version of [constant TYPE_SIMPLEX], but slower. + </constant> + <constant name="FRACTAL_NONE" value="0" enum="FractalType"> + No fractal noise. + </constant> + <constant name="FRACTAL_FBM" value="1" enum="FractalType"> + Method using Fractional Brownian Motion to combine octaves into a fractal. + </constant> + <constant name="FRACTAL_RIDGED" value="2" enum="FractalType"> + Method of combining octaves into a fractal resulting in a "ridged" look. + </constant> + <constant name="FRACTAL_PING_PONG" value="3" enum="FractalType"> + Method of combining octaves into a fractal with a ping pong effect. + </constant> + <constant name="DISTANCE_EUCLIDEAN" value="0" enum="CellularDistanceFunction"> + Euclidean distance to the nearest point. + </constant> + <constant name="DISTANCE_EUCLIDEAN_SQUARED" value="1" enum="CellularDistanceFunction"> + Squared Euclidean distance to the nearest point. + </constant> + <constant name="DISTANCE_MANHATTAN" value="2" enum="CellularDistanceFunction"> + Manhattan distance (taxicab metric) to the nearest point. + </constant> + <constant name="DISTANCE_HYBRID" value="3" enum="CellularDistanceFunction"> + Blend of [constant DISTANCE_EUCLIDEAN] and [constant DISTANCE_MANHATTAN] to give curved cell boundaries + </constant> + <constant name="RETURN_CELL_VALUE" value="0" enum="CellularReturnType"> + The cellular distance function will return the same value for all points within a cell. + </constant> + <constant name="RETURN_DISTANCE" value="1" enum="CellularReturnType"> + The cellular distance function will return a value determined by the distance to the nearest point. + </constant> + <constant name="RETURN_DISTANCE2" value="2" enum="CellularReturnType"> + The cellular distance function returns the distance to the second-nearest point. + </constant> + <constant name="RETURN_DISTANCE2_ADD" value="3" enum="CellularReturnType"> + The distance to the nearest point is added to the distance to the second-nearest point. + </constant> + <constant name="RETURN_DISTANCE2_SUB" value="4" enum="CellularReturnType"> + The distance to the nearest point is subtracted from the distance to the second-nearest point. + </constant> + <constant name="RETURN_DISTANCE2_MUL" value="5" enum="CellularReturnType"> + The distance to the nearest point is multiplied with the distance to the second-nearest point. + </constant> + <constant name="RETURN_DISTANCE2_DIV" value="6" enum="CellularReturnType"> + The distance to the nearest point is divided by the distance to the second-nearest point. + </constant> + <constant name="DOMAIN_WARP_SIMPLEX" value="0" enum="DomainWarpType"> + The domain is warped using the simplex noise algorithm. + </constant> + <constant name="DOMAIN_WARP_SIMPLEX_REDUCED" value="1" enum="DomainWarpType"> + The domain is warped using a simplified version of the simplex noise algorithm. + </constant> + <constant name="DOMAIN_WARP_BASIC_GRID" value="2" enum="DomainWarpType"> + The domain is warped using a simple noise grid (not as smooth as the other methods, but more performant). + </constant> + <constant name="DOMAIN_WARP_FRACTAL_NONE" value="0" enum="DomainWarpFractalType"> + No fractal noise for warping the space. + </constant> + <constant name="DOMAIN_WARP_FRACTAL_PROGRESSIVE" value="1" enum="DomainWarpFractalType"> + Warping the space progressively, octave for octave, resulting in a more "liquified" distortion. + </constant> + <constant name="DOMAIN_WARP_FRACTAL_INDEPENDENT" value="2" enum="DomainWarpFractalType"> + Warping the space independently for each octave, resulting in a more chaotic distortion. + </constant> + </constants> +</class> diff --git a/modules/noise/doc_classes/Noise.xml b/modules/noise/doc_classes/Noise.xml new file mode 100644 index 0000000000..db0dec18d2 --- /dev/null +++ b/modules/noise/doc_classes/Noise.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Noise" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> + <brief_description> + Abstract base class for noise generators. + </brief_description> + <description> + This class defines the interface for noise generation libraries to inherit from. + A default get_seamless_noise() implementation is provided for libraries that do not provide seamless noise. This function requests a larger image from get_image(), reverses the quadrants of the image, then uses the strips of extra width to blend over the seams. + Inheriting noise classes can optionally override this function to provide a more optimal algorithm. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_image"> + <return type="Image" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="invert" type="bool" default="false" /> + <description> + Returns a 2D [Image] noise image. + </description> + </method> + <method name="get_noise_1d"> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <description> + Returns the 1D noise value at the given (x) coordinate. + </description> + </method> + <method name="get_noise_2d"> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <description> + Returns the 2D noise value at the given position. + </description> + </method> + <method name="get_noise_2dv"> + <return type="float" /> + <argument index="0" name="v" type="Vector2" /> + <description> + Returns the 2D noise value at the given position. + </description> + </method> + <method name="get_noise_3d"> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="z" type="float" /> + <description> + Returns the 3D noise value at the given position. + </description> + </method> + <method name="get_noise_3dv"> + <return type="float" /> + <argument index="0" name="v" type="Vector3" /> + <description> + Returns the 3D noise value at the given position. + </description> + </method> + <method name="get_seamless_image"> + <return type="Image" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="invert" type="bool" default="false" /> + <argument index="3" name="skirt" type="float" default="0.1" /> + <description> + Returns a seamless 2D [Image] noise image. + </description> + </method> + </methods> +</class> diff --git a/modules/noise/doc_classes/NoiseTexture.xml b/modules/noise/doc_classes/NoiseTexture.xml new file mode 100644 index 0000000000..63630eccde --- /dev/null +++ b/modules/noise/doc_classes/NoiseTexture.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="NoiseTexture" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> + <brief_description> + A texture filled with noise generated by a [Noise] object. + </brief_description> + <description> + Uses [FastNoiseLite] or other libraries to fill the texture data of your desired size. + NoiseTexture can also generate normalmap textures. + The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_image] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image and the generated byte data: + [codeblock] + var texture = NoiseTexture.new() + texture.noise = FastNoiseLite.new() + await texture.changed + var image = texture.get_image() + var data = image.get_data() + [/codeblock] + </description> + <tutorials> + </tutorials> + <members> + <member name="as_normal_map" type="bool" setter="set_as_normal_map" getter="is_normal_map" default="false"> + If [code]true[/code], the resulting texture contains a normal map created from the original noise interpreted as a bump map. + </member> + <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0"> + Strength of the bump maps used in this texture. A higher value will make the bump maps appear larger while a lower value will make them appear softer. + </member> + <member name="height" type="int" setter="set_height" getter="get_height" default="512"> + Height of the generated texture. + </member> + <member name="invert" type="bool" setter="set_invert" getter="get_invert" default="false"> + If [code]true[/code], inverts the noise texture. White becomes black, black becomes white. + </member> + <member name="noise" type="Noise" setter="set_noise" getter="get_noise"> + The instance of the [Noise] object. + </member> + <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false"> + If [code]true[/code], a seamless texture is requested from the [Noise] resource. + [b]Note:[/b] Seamless noise textures may take longer to generate and/or can have a lower contrast compared to non-seamless noise depending on the used [Noise] resource. This is because some implementations use higher dimensions for generating seamless noise. + </member> + <member name="seamless_blend_skirt" type="float" setter="set_seamless_blend_skirt" getter="get_seamless_blend_skirt" default="0.1"> + Used for the default/fallback implementation of the seamless texture generation. It determines the distance over which the seams are blended. High values may result in less details and contrast. See [Noise] for further details. + </member> + <member name="width" type="int" setter="set_width" getter="get_width" default="512"> + Width of the generated texture. + </member> + </members> +</class> |