This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

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,561Admin

    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.