Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
FastNoise plugin - Page 3 - Gideros Forum

FastNoise plugin

13»

Comments

  • rrraptorrrraptor Member
    edited December 2019
    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:
    noise:generateTexture(128, 128, false, _, {...})
    OR
    noise:generateTexture(128, 128, false, nil, {...})
    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).

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    @rraptor, I will integrate your changes and build 2019.12. I'll leave 1D noise code in though, to avoid having to add it back in case we need it later
  • @hgy29 but it doesnt work corectly :D Whats the point? I dont how to fix it because it uses some magic numbers like:

    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

    image.png
    1600 x 861 - 1M
    add.png
    1600 x 861 - 1M
    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    @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.

    Likes: SinisterSoft

    +1 -1 (+1 / -0 ) Share on Facebook
  • rrraptorrrraptor Member
    edited December 2019
    hgy29 said:

    we can say it is still beta code :)

    And who is going to fix it? :D
    hgy29 said:

    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?

    P.S. :D
    dd.png
    1600 x 861 - 848K
    dd.png 848.2K
  • hgy29hgy29 Maintainer
    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).
  • @hgy29 I did a quick test.

    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

    screen_01.png
    1024 x 1024 - 215K
    screen_02.png
    1024 x 1024 - 39K
    +1 -1 (+1 / -0 ) Share on Facebook
  • Been bisy, sorry :) I'll try to update wiki on this week.
    I've fixed this
    First, there is a white color where it should not be.
    Second, I think its better to add an option for color interpolation.
    And made 3D version. See here:
    https://github.com/MultiPain/Gideros_examples

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • 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
  • rrraptorrrraptor Member
    edited March 28
    @hgy29 I made an update :)

    https://github.com/MultiPain/Gideros_FastNoise_binding/blob/master/binding.cpp
    • Added tileable texture generation
    • Added a separate function to set color table
    • Color table format is changed to: {height_value, hex_color, [alpha_value]} (alpha is optional, default: 1.0)
    • Renamed array and texture generation methods (cuz damn, they were so long xD )
    Preview:



    P.S. I wander, how can I return RenderTarget instead of Texture...
    NoiseHuh.png
    1168 x 558 - 44K
    +1 -1 (+3 / -0 ) Share on Facebook
  • MoKaLuxMoKaLux Member
    that looks so nice <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.