Did some changes again. Merged "generateTexture" and "generateTileableTexture" together. Now there is only 1 "generateTexture" with parameters.
-- parameters: (w, h, filtering, options, noiseOptions)-- w, h - texture size-- filtering (boolean): filter texture or not-- options (table): standart texture options-- noiseOptions (table): noise options-- xoff (number): offset noise by x [optional, 0]-- yoff (number): offset noise by y [optional, 0]-- yoff (number): offset noise by z [optional, 0]-- woff (number): offset noise by w (only for tileable texture) [optional, 0]-- min (number): minimum noise value (useful for distance return type) [optional, -1]-- max (number): maximum noise value (useful for distance return type) [optional, 1]-- tileable (boolean): generate tileable texture or not [optional, false]-- colors (table): color table:-- h (number): height in range [0..1]-- color (table): in RGBA format like {255,0,0,255}
noise:generateTexture(128, 128, false, {wrap = Texture.REPEAT}, {tileable =true, colors = noiseColorTable})
Idk if it ok, but if you dont need texture options the code will look like this:
Also, you need to pass correct values to color table, otherwise the game will crush, I have no idea why, probably I did something wrong with lua stack xD
@hgy29 if you will be updating it, notice that I also removed 1D noise from FastNoise.cpp (and header).
@rraptor, I understand. Anyhow it doesn't hurt, we can say it is still beta code So I integrated your changes and made some changes to the color mapping code, hopefully making it faster and supporting interpolation.
So I integrated your changes and made some changes to the color mapping code, hopefully making it faster and supporting interpolation.
I just cant understand this part:
while ((e < entryCount)&&(entries[e].level<=level)) e++; if (e==0) Color::lerp(alpha,entries[e].color,c,level/entries[e].level); else if (e==entryCount) Color::lerp(entries[entryCount-1].color,alpha,c,(level-entries[entryCount].level)/(1-entries[entryCount].level)); else Color::lerp(entries[e-1].color,entries[e].color,c,(level-entries[e-1].level)/(entries[e].level-entries[e-1].level))</p>
Since you added method to load a color table, it would be good to have extra method like "Noise:loadColorTable(t)" and load colors there instead of loading them in "generate" method?
Yes, good idea. Another good reason to say that the API is still beta and subject to change. The piece of code you quoted above looks for the point in the table in between which our lookup value is, then handle the cases where our value is below the first color or above the last one (in which case we assume out of bound color is just plain alpha).
These would be good as examples in the official distribution.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
Merged "generateTexture" and "generateTileableTexture" together. Now there is only 1 "generateTexture" with parameters.
@hgy29 if you will be updating it, notice that I also removed 1D noise from FastNoise.cpp (and header).
Likes: MoKaLux
For 3D noises:
static const FN_DECIMAL SQRT3 = FN_DECIMAL(1.7320508075688772935274463415059);
static const FN_DECIMAL F2 = FN_DECIMAL(0.5) * (SQRT3 - FN_DECIMAL(1.0));
static const FN_DECIMAL G2 = (FN_DECIMAL(3.0) - SQRT3) / FN_DECIMAL(6.0);
For 2D:
static const FN_DECIMAL F4 = (sqrt(FN_DECIMAL(5)) - 1) / 4;
static const FN_DECIMAL G4 = (5 - sqrt(FN_DECIMAL(5))) / 20;
For 1D: ???
P.S. terrible attempt in 3D xD Used mesh and viewport.
P.P.S. Another one, but a bit better Used same mesh and stage.
Likes: MoKaLux
So I integrated your changes and made some changes to the color mapping code, hopefully making it faster and supporting interpolation.
Likes: SinisterSoft
P.S.
The piece of code you quoted above looks for the point in the table in between which our lookup value is, then handle the cases where our value is below the first color or above the last one (in which case we assume out of bound color is just plain alpha).
VS original
First, there is a white color where it should not be.
Second, I think its better to add an option for color interpolation.
I'll change it today
Likes: MoKaLux
I've fixed this And made 3D version. See here:
https://github.com/MultiPain/Gideros_examples
Likes: MoKaLux
https://deluxepixel.com
https://github.com/MultiPain/Gideros_FastNoise_binding/blob/master/binding.cpp
P.S. I wander, how can I return RenderTarget instead of Texture...
Likes: MoKaLux, antix, SinisterSoft
https://github.com/MultiPain/Gideros_examples/tree/master/NoiseFlowField
Likes: MoKaLux