Need help with Shade code line

vinteesetevinteesete Posts: 1Member
edited October 2019 in Shaders

Hi there, I'm new to programming and godot, and right now I'm trying to implement this GLSL shader in godot and having troble with it.

This is the line I'm struggling with:

float pattern = tri(fract((uv.y + time / 12.) * 20.0), 2.0 / divisions, divisionsShift)- (-uv.y + 0.30) * 0.85;

I want to put it in godot programming language, but i can't find a replace to the tri function that works similar.

Again, just a beginner here, but i would appreciate some help. Thanks!!


  • TwistedTwiglegTwistedTwigleg Posts: 2,459Admin

    It looks like this GitHub gist has a definition of the tri function, though I'm not sure if it is the same tri function or not: also has a definition for a tri function:

    float tri(in float x){return abs(fract(x)-.5);}
    vec3 tri3(in vec3 p){return vec3( tri(p.z+tri(p.y*1.)), tri(p.z+tri(p.x*1.)), tri(p.y+tri(p.x*1.)));}

    I have no idea if either function is what you are looking for, but hopefully one of them will work. :smile:
    (Side note: Welcome to the forums)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file