Difference between revisions of "Noise"
(some more links added/created) |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | |||
<!-- GIDEROSOBJ:FastNoise --> | <!-- GIDEROSOBJ:FastNoise --> | ||
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | ||
'''<translate>Available since</translate>:''' Gideros 2019.12<br/> | '''<translate>Available since</translate>:''' Gideros 2019.12<br/> | ||
− | === | + | === Description === |
− | + | FastNoise is an open source noise generation library with a large collection of different noise algorithms. | |
− | + | ||
− | + | '''[https://github.com/Auburns/FastNoise FastNoise home page]''' | |
− | === | + | |
+ | Orignal documentation: https://github.com/Auburns/FastNoise/wiki | ||
+ | |||
+ | === Features === | ||
* Value Noise 2D, 3D | * Value Noise 2D, 3D | ||
* Perlin Noise 2D, 3D | * Perlin Noise 2D, 3D | ||
Line 20: | Line 22: | ||
* Texture generation | * Texture generation | ||
* Array generation | * Array generation | ||
− | |||
− | === | + | === Examples === |
'''Example 1.''' | '''Example 1.''' | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 113: | Line 114: | ||
[[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: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: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: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: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 --> | ||
Line 124: | Line 124: | ||
[[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: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: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> | + | [[Special:MyLanguage/Noise:setCellularNoiseLookup|Noise:setCellularNoiseLookup]] ''<translate>noise used to calculate a cell value</translate>''<br/><!-- GIDEROSMTD:Noise:setCellularNoiseLookup(Noise) noise used to calculate a cell value --> |
[[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: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: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 --> |
Revision as of 07:58, 25 March 2020
Supported platforms:
Available since: Gideros 2019.12
Description
FastNoise is an open source noise generation library with a large collection of different noise algorithms.
Orignal documentation: https://github.com/Auburns/FastNoise/wiki
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
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))
See 3D examples here
Notes
MethodsNoise.new creates a new Noise object Noise:reset reset noise parameters to default |
EventsConstantsNoise.FBM |