Difference between revisions of "Noise"
Line 92: | Line 92: | ||
=== <translate>Notes</translate> === | === <translate>Notes</translate> === | ||
− | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Methods</translate> === | === <translate>Methods</translate> === | ||
− | [[Special:MyLanguage/ | + | [[Special:MyLanguage/Noise.new|Noise.new]] ''<translate>creates a new Noise object</translate>''<br/><!-- GIDEROSMTD:Noise.new() creates a new Noise object --> |
+ | |||
+ | [[Special:MyLanguage/Noise:reset|Noise:reset]] ''<translate>reset noise parameters to default</translate>''<br/><!-- GIDEROSMTD:FastNoise:reset() reset noise parameters to default --> | ||
+ | [[Special:MyLanguage/Noise:noise|Noise:noise]] ''<translate>get noise value</translate>''<br/><!-- GIDEROSMTD:Noise:noise([x,y,z]) get noise value --> | ||
+ | [[Special:MyLanguage/Noise:noise1D|Noise:noise1D]] ''<translate>get 1D noise value</translate>''<br/><!-- GIDEROSMTD:Noise:noise1D(x) get 1D noise value --> | ||
+ | [[Special:MyLanguage/Noise:noise2D|Noise:noise2D]] ''<translate>get 2D noise value</translate>''<br/><!-- GIDEROSMTD:Noise:noise2D(x,y) get 2D noise value --> | ||
+ | [[Special:MyLanguage/Noise:noise3D|Noise:noise3D]] ''<translate>get 3D noise value</translate>''<br/><!-- GIDEROSMTD:Noise:noise3D(x,y,z) get 3D noise value --> | ||
+ | [[Special:MyLanguage/Noise:whiteNoise4D|Noise:whiteNoise4D]] ''<translate>get 4D white noise value</translate>''<br/><!-- GIDEROSMTD:Noise:whiteNoise4D(x,y,z,w) get 4D white noise value --> | ||
+ | [[Special:MyLanguage/Noise:whiteNoise1DInt|Noise:whiteNoise1DInt]] ''<translate>get integer 1D white noise value</translate>''<br/><!-- GIDEROSMTD:Noise:whiteNoise1DInt(x) get integer 1D white noise value --> | ||
+ | [[Special:MyLanguage/Noise:whiteNoise2DInt|Noise:whiteNoise2DInt]] ''<translate>get integer 2D white noise value</translate>''<br/><!-- GIDEROSMTD:Noise:whiteNoise2DInt(x,y) get integer 2D white noise value --> | ||
+ | [[Special:MyLanguage/Noise:whiteNoise3DInt|Noise:whiteNoise3DInt]] ''<translate>get integer 3D white noise value</translate>''<br/><!-- GIDEROSMTD:Noise:whiteNoise3DInt(x,y,z) get integer 3D white noise value --> | ||
+ | [[Special:MyLanguage/Noise:whiteNoise4DInt|Noise:whiteNoise4DInt]] ''<translate>get integer 4D white noise value</translate>''<br/><!-- GIDEROSMTD:Noise:whiteNoise4DInt(x,y,z,w) get integer 4D white noise value --> | ||
+ | [[Special:MyLanguage/Noise:simplex4D|Noise:simplex4D]] ''<translate>get 4D simplex noise value</translate>''<br/><!-- GIDEROSMTD:Noise:simplex4D(x,y,z,w) get 4D simplex noise value --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturb1D|Noise:gradientPerturb1D]] ''<translate>returns modified x</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturb1D(x) returns modified x --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturb2D|Noise:gradientPerturb2D]] ''<translate>returns modified x, y</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturb2D(x,y) returns modified x, y --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturb3D|Noise:gradientPerturb3D]] ''<translate>returns modified x, y, z</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturb3D(x,y,z) returns modified x, y, z --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturbFractal1D|Noise:gradientPerturbFractal1D]] ''<translate>returns modified x</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturbFractal1D(x) returns modified x --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturbFractal2D|Noise:gradientPerturbFractal2D]] ''<translate>returns modified x,y</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturbFractal2D(x,y) returns modified x,y --> | ||
+ | [[Special:MyLanguage/Noise:gradientPerturbFractal3D|Noise:gradientPerturbFractal3D]] ''<translate>returns modified x,y,z</translate>''<br/><!-- GIDEROSMTD:Noise:gradientPerturbFractal3D(x,y,z) returns modified x,y,z --> | ||
+ | |||
+ | [[Special:MyLanguage/Noise:setNoiseType|Noise:setNoiseType]] ''<translate>sets the type of noise returned by noise()</translate>''<br/><!-- GIDEROSMTD:Noise:setNoiseType(noiseType) sets the type of noise returned by noise() --> | ||
+ | [[Special:MyLanguage/Noise:setFractalOctaves|Noise:setFractalOctaves]] ''<translate>the amount of noise layers used to create the fractal</translate>''<br/><!-- GIDEROSMTD:Noise:setFractalOctaves(n) the amount of noise layers used to create the fractal --> | ||
+ | [[Special:MyLanguage/Noise:setInterp|Noise:setInterp]] ''<translate>changes the interpolation method used to smooth between noise values</translate>''<br/><!-- GIDEROSMTD:Noise:setInterp(interpolation) changes the interpolation method used to smooth between noise values --> | ||
+ | [[Special:MyLanguage/Noise:setSeed|Noise:setSeed]] ''<translate>using different seeds will cause the noise output to change</translate>''<br/><!-- GIDEROSMTD:Noise:setSeed() using different seeds will cause the noise output to change --> | ||
+ | [[Special:MyLanguage/Noise:setFrequency|Noise:setFrequency]] ''<translate>affects how coarse the noise output is</translate>''<br/><!-- GIDEROSMTD:Noise:setFrequency(frequency) affects how coarse the noise output is --> | ||
+ | [[Special:MyLanguage/Noise:setFractalLacunarity|Noise:setFractalLacunarity]] ''<translate>the frequency multiplier between each octave</translate>''<br/><!-- GIDEROSMTD:Noise:setFractalLacunarity(lacunarity) the frequency multiplier between each octave --> | ||
+ | [[Special:MyLanguage/Noise:setFractalGain|Noise:setFractalGain]] ''<translate>the relative strength of noise from each layer when compared to the last</translate>''<br/><!-- GIDEROSMTD:Noise:setFractalGain(gain) the relative strength of noise from each layer when compared to the last --> | ||
+ | [[Special:MyLanguage/Noise:setFractalType|Noise:setFractalType]] ''<translate>used in all fractal noise generation</translate>''<br/><!-- GIDEROSMTD:Noise:setFractalType(noiseType) used in all fractal noise generation --> | ||
+ | [[Special:MyLanguage/Noise:setCellularDistanceFunction|Noise:setCellularDistanceFunction]] ''<translate>the distance function used to calculate the cell for a given point</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularDistanceFunction(distanceFunctionType) the distance function used to calculate the cell for a given point --> | ||
+ | [[Special:MyLanguage/Noise:setCellularReturnType|Noise:setCellularReturnType]] ''<translate>what value does the cellular function return from its calculations</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularReturnType(returnType) what value does the cellular function return from its calculations --> | ||
+ | [[Special:MyLanguage/Noise:setCellularNoiseLookup|Noise:setCellularNoiseLookup]] ''<translate>TODO</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularNoiseLookup(Noise) TODO --> | ||
+ | [[Special:MyLanguage/Noise:setCellularDistance2Indices|Noise:setCellularDistance2Indices]] ''<translate>sets the 2 distance indicies used for distance2 return types</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularDistance2Indices(index0, index1) sets the 2 distance indicies used for distance2 return types --> | ||
+ | [[Special:MyLanguage/Noise:setCellularJitter|Noise:setCellularJitter]] ''<translate>sets the maximum distance a cellular point can move from its grid position</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularJitter(jitter) sets the maximum distance a cellular point can move from its grid position --> | ||
+ | [[Special:MyLanguage/Noise:setGradientPerturbAmp|Noise:setGradientPerturbAmp]] ''<translate>sets the maximum perturb distance from original location when using gradientPerturb()</translate>''<br/><!-- GIDEROSMTD:Noise:setGradientPerturbAmp(amp) sets the maximum perturb distance from original location when using gradientPerturb() --> | ||
+ | [[Special:MyLanguage/Noise:getNoiseType|Noise:getNoiseType]] ''<translate>returns noise type</translate>''<br/><!-- GIDEROSMTD:Noise:getNoiseType() returns noise type --> | ||
+ | [[Special:MyLanguage/Noise:getFractalOctaves|Noise:getFractalOctaves]] ''<translate>returns number of fractal octaves</translate>''<br/><!-- GIDEROSMTD:Noise:getFractalOctaves() returns number of fractal octaves --> | ||
+ | [[Special:MyLanguage/Noise:getInterp()|Noise:getInterp()]] ''<translate>returns interpolation type</translate>''<br/><!-- GIDEROSMTD:Noise:getInterp() returns interpolation type --> | ||
+ | [[Special:MyLanguage/Noise:getSeed|Noise:getSeed]] ''<translate>returns generator's seed</translate>''<br/><!-- GIDEROSMTD:Noise:getSeed() returns generator's seed --> | ||
+ | [[Special:MyLanguage/Noise:getFrequency|Noise:getFrequency]] ''<translate>returns noise frequency</translate>''<br/><!-- GIDEROSMTD:Noise:getFrequency() returns noise frequency --> | ||
+ | [[Special:MyLanguage/Noise:getFractalLacunarity|Noise:getFractalLacunarity]] ''<translate>returns noise lacunarity</translate>''<br/><!-- GIDEROSMTD:Noise:getFractalLacunarity() returns noise lacunarity --> | ||
+ | [[Special:MyLanguage/Noise:getFractalGain|Noise:getFractalGain]] ''<translate>return noise gain</translate>''<br/><!-- GIDEROSMTD:Noise:getFractalGain() return noise gain --> | ||
+ | [[Special:MyLanguage/Noise:getFractalType|Noise:getFractalType]] ''<translate>returns noise type</translate>''<br/><!-- GIDEROSMTD:Noise:getFractalType() returns noise type --> | ||
+ | [[Special:MyLanguage/Noise:getCellularDistanceFunction|Noise:getCellularDistanceFunction]] ''<translate>returns distance function type</translate>''<br/><!-- GIDEROSMTD:Noise:getCellularDistanceFunction() returns distance function type --> | ||
+ | [[Special:MyLanguage/Noise:getCellularReturnType|Noise:getCellularReturnType]] ''<translate>returns cellular return type</translate>''<br/><!-- GIDEROSMTD:Noise:getCellularReturnType() returns cellular return type --> | ||
+ | [[Special:MyLanguage/Noise:getCellularNoiseLookup|Noise:getCellularNoiseLookup]] ''<translate>returns Noise object that was set by setCellularNoiseLookup() function</translate>''<br/><!-- GIDEROSMTD:Noise:getCellularNoiseLookup() returns Noise object that was set by setCellularNoiseLookup() function --> | ||
+ | [[Special:MyLanguage/Noise:getCellularJitter|Noise:getCellularJitter]] ''<translate>returns cellular jitter value</translate>''<br/><!-- GIDEROSMTD:Noise:getCellularJitter() returns cellular jitter value --> | ||
+ | [[Special:MyLanguage/Noise:getGradientPerturbAmp|Noise:getGradientPerturbAmp]] ''<translate>returns gradient perturb amplitude.</translate>''<br/><!-- GIDEROSMTD:Noise:getGradientPerturbAmp() returns gradient perturb amplitude. --> | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
+ | [[Special:MyLanguage/Noise.FBM|Noise.FBM]]<br/><!-- GIDEROSCST:Noise.FBM fbm--> | ||
+ | [[Special:MyLanguage/Noise.BILLOW|Noise.BILLOW]]<br/><!-- GIDEROSCST:Noise.BILLOW billow--> | ||
+ | [[Special:MyLanguage/Noise.RIGID_MULTI|Noise.RIGID_MULTI]]<br/><!-- GIDEROSCST:Noise.RIGID_MULTI rigid_multi--> | ||
+ | [[Special:MyLanguage/Noise.VALUE|Noise.VALUE]]<br/><!-- GIDEROSCST:Noise.VALUE value--> | ||
+ | [[Special:MyLanguage/Noise.VALUE_FRACTAL|Noise.VALUE_FRACTAL]]<br/><!-- GIDEROSCST:Noise.VALUE_FRACTAL value_fractal--> | ||
+ | [[Special:MyLanguage/Noise.PERLIN|Noise.PERLIN]]<br/><!-- GIDEROSCST:Noise.PERLIN perlin--> | ||
+ | [[Special:MyLanguage/Noise.PERLIN_FRACTAL|Noise.PERLIN_FRACTAL]]<br/><!-- GIDEROSCST:Noise.PERLIN_FRACTAL perlin_fractal--> | ||
+ | [[Special:MyLanguage/Noise.SIMPLEX|Noise.SIMPLEX]]<br/><!-- GIDEROSCST:Noise.SIMPLEX simplex--> | ||
+ | [[Special:MyLanguage/Noise.SIMPLEX_FRACTAL|Noise.SIMPLEX_FRACTAL]]<br/><!-- GIDEROSCST:Noise.SIMPLEX_FRACTAL simplex_fractal--> | ||
+ | [[Special:MyLanguage/Noise.CELLULAR|Noise.CELLULAR]]<br/><!-- GIDEROSCST:Noise.CELLULAR cellular--> | ||
+ | [[Special:MyLanguage/Noise.WHITE_NOISE|Noise.WHITE_NOISE]]<br/><!-- GIDEROSCST:Noise.WHITE_NOISE white_noise--> | ||
+ | [[Special:MyLanguage/Noise.CUBIC|Noise.CUBIC]]<br/><!-- GIDEROSCST:Noise.CUBIC cubic--> | ||
+ | [[Special:MyLanguage/Noise.CUBIC_FRACTAL|Noise.CUBIC_FRACTAL]]<br/><!-- GIDEROSCST:Noise.CUBIC_FRACTAL cubic_fractal--> | ||
+ | [[Special:MyLanguage/Noise.CELL_VALUE|Noise.CELL_VALUE]]<br/><!-- GIDEROSCST:Noise.CELL_VALUE cell_value--> | ||
+ | [[Special:MyLanguage/Noise.NOISE_LOOKUP|Noise.NOISE_LOOKUP]]<br/><!-- GIDEROSCST:Noise.NOISE_LOOKUP noise_lookup--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE|Noise.DISTANCE]]<br/><!-- GIDEROSCST:Noise.DISTANCE distance--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE_2|Noise.DISTANCE_2]]<br/><!-- GIDEROSCST:Noise.DISTANCE_2 distance_2--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE_2_ADD|Noise.DISTANCE_2_ADD]]<br/><!-- GIDEROSCST:Noise.DISTANCE_2_ADD distance_2_add--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE_2_SUB|Noise.DISTANCE_2_SUB]]<br/><!-- GIDEROSCST:Noise.DISTANCE_2_SUB distance_2_sub--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE_2_MUL|Noise.DISTANCE_2_MUL]]<br/><!-- GIDEROSCST:Noise.DISTANCE_2_MUL distance_2_mul--> | ||
+ | [[Special:MyLanguage/Noise.DISTANCE_2_DIV|Noise.DISTANCE_2_DIV]]<br/><!-- GIDEROSCST:Noise.DISTANCE_2_DIV distance_2_div--> | ||
+ | [[Special:MyLanguage/Noise.LINEAR|Noise.LINEAR]]<br/><!-- GIDEROSCST:Noise.LINEAR linear--> | ||
+ | [[Special:MyLanguage/Noise.HERMITE|Noise.HERMITE]]<br/><!-- GIDEROSCST:Noise.HERMITE hermite--> | ||
+ | [[Special:MyLanguage/Noise.QUINTIC|Noise.QUINTIC]]<br/><!-- GIDEROSCST:Noise.QUINTIC quintic--> | ||
+ | [[Special:MyLanguage/Noise.EUCLIDEAN|Noise.EUCLIDEAN]]<br/><!-- GIDEROSCST:Noise.EUCLIDEAN euclidean--> | ||
+ | [[Special:MyLanguage/Noise.MANHATTAN|Noise.MANHATTAN]]<br/><!-- GIDEROSCST:Noise.MANHATTAN manhattan--> | ||
+ | [[Special:MyLanguage/Noise.NATURAL|Noise.NATURAL]]<br/><!-- GIDEROSCST:Noise.NATURAL natural--> | ||
|} | |} | ||
{{FastNoise}} | {{FastNoise}} |
Revision as of 08:09, 14 December 2019
Supported platforms:
Available since: Gideros 2019.12
Description
FastNoise is an open source noise generation library with a large collection of different noise algorithms. [FastNoise home page]
Features
- Value Noise 2D, 3D
- Perlin Noise 2D, 3D
- Simplex Noise 2D, 3D, 4D
- Cubic Noise 2D, 3D
- Gradient Perturb 2D, 3D
- Multiple fractal options for all of the above
- Cellular (Voronoi) Noise 2D, 3D
- White Noise 2D, 3D, 4D
- Texture generation
- Array generation
Orignal documentation: https://github.com/Auburns/FastNoise/wiki
Examples
Example 1.
require "FastNoise"
local myNoise = Noise.new() -- create FastNoise instance
myNoise:setSeed(456) -- set generation seed
myNoise:setFrequency(0.04) -- how coarse the noise output is
myNoise:setInterp(Noise.HERMITE) -- set noise interpolation type
myNoise:setNoiseType(Noise.SIMPLEX) -- set noise type
for y = 1, 4 do
for x = 1, 4 do
local v = myNoise:noise(x, y) -- generate 2D noise
-- other possible function:
-- myNoise:noise(x) -- 1D noise
-- myNoise:noise(x, y, z) -- 3D noise
-- myNoise:noise2D(x, y) -- true 2D noise
-- myNoise:noise3D(x, y, z) -- true 3D noise
-- difference between noise2D(x, y) and noise(x, y) is that "noise" function uses 3D noise with
-- x = 0, y = 0, z = 0 by default where noise2D uses only 2 values. In other words: noise(x) == noise(x,0,0);
-- noise(x, y) == noise(x,y,0); noise(x,y) == noise2D(x,y); noise(x,y,z) == noise3D(x,y,z)
print(v)
end
end
Example 2. Grayscaled noise image
require "FastNoise"
local n = Noise.new()
-- generate 128x128 texture
local tex = n:generateTexture(128, 128)
-- add it to scene
stage:addChild(Bitmap.new(tex))
Example 3. Colored seamless noise image
require "FastNoise"
local n = Noise.new()
n:setFrequency(0.03)
n:setFractalOctaves(5)
n:setFractalLacunarity(2.5)
n:setInterp(Noise.HERMITE)
n:setFractalGain(0.6)
n:setNoiseType(Noise.SIMPLEX_FRACTAL)
-- create a color table used by noise
-- h: height value in range [0..1]
-- color: in RGBA format
local colors = {
{h = 0.3, color = {52,99,195,255}},
{h = 0.4, color = {54,102,198,255}},
{h = 0.45, color = {209,208,128,255}},
{h = 0.55, color = {88,151,24,255}},
{h = 0.6, color = {63,106,20,255}},
{h = 0.7, color = {92,68,61,255}},
{h = 0.9, color = {75,60,55,255}},
{h = 1, color = {255,255,255,255}},
}
-- generate 128x128 texture
local tex = n:generateTexture(128, 128, false, {wrap=Texture.REPEAT}, {tileable = true, colors = colors})
-- add it to scene
stage:addChild(Pixel.new(tex, 256,256))
Notes
MethodsNoise.new creates a new Noise object Noise:reset reset noise parameters to default Noise:setNoiseType sets the type of noise returned by noise() |
EventsConstantsNoise.FBM |
- Noise:getCellularDistanceFunction
- Noise:getCellularJitter
- Noise:getCellularNoiseLookup
- Noise:getCellularReturnType
- Noise:getFractalGain
- Noise:getFractalLacunarity
- Noise:getFractalOctaves
- Noise:getFractalType
- Noise:getFrequency
- Noise:getGradientPerturbAmp
- Noise:getInterp
- Noise:getNoiseType
- Noise:getSeed
- Noise:getTexture
- Noise:getTileTexture
- Noise:gradientPerturb2D
- Noise:gradientPerturb3D
- Noise:gradientPerturbFractal2D
- Noise:gradientPerturbFractal3D
- Noise:noise
- Noise:noise2D
- Noise:noise3D
- Noise:reset
- Noise:setCellularDistance2Indices
- Noise:setCellularDistanceFunction
- Noise:setCellularJitter
- Noise:setCellularNoiseLookup
- Noise:setCellularReturnType
- Noise:setColorLookup
- Noise:setFractalGain
- Noise:setFractalLacunarity
- Noise:setFractalOctaves
- Noise:setFractalType
- Noise:setFrequency
- Noise:setGradientPerturbAmp
- Noise:setInterp
- Noise:setNoiseType
- Noise:setSeed
- Noise:simplex4D
- Noise:whiteNoise2DInt
- Noise:whiteNoise3DInt
- Noise:whiteNoise4D
- Noise:whiteNoise4DInt
- Noise.BILLOW
- Noise.CELLULAR
- Noise.CELL VALUE
- Noise.CUBIC
- Noise.CUBIC FRACTAL
- Noise.DISTANCE
- Noise.DISTANCE 2
- Noise.DISTANCE 2 ADD
- Noise.DISTANCE 2 DIV
- Noise.DISTANCE 2 MUL
- Noise.DISTANCE 2 SUB
- Noise.EUCLIDEAN
- Noise.FBM
- Noise.HERMITE
- Noise.LINEAR
- Noise.MANHATTAN
- Noise.NATURAL
- Noise.NOISE LOOKUP
- Noise.PERLIN
- Noise.PERLIN FRACTAL
- Noise.QUINTIC
- Noise.RIGID MULTI
- Noise.SIMPLEX
- Noise.SIMPLEX FRACTAL
- Noise.VALUE
- Noise.VALUE FRACTAL
- Noise.WHITE NOISE
- Noise.new