Glsl debugger

glsl is very difficult to learn,what bebugger tool do you use?

I do not know glsl very well at all really. I have just been viewing Shader Toy examples and then trying to make them work or modify them to create some uniforms. It is very frustrating. So sorry, no advice on debuggers. If you turn the log parameter to true in the ZIM Shader then it shows you the fragment and vertex shader in the console. You will get an error in the console and can then match the line number to the log. That is all we did to debug.

Our discoveries along the way are noted in the Docs under the Shader under a category of TIPS. DOCS - ZIM JavaScript Canvas Framework - Documentation

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>ZIM - Shader step by step</title>
    <script type="module">
        import zim from "https://zimjs.org/cdn/019/zim";
        new Frame(FIT, 1024, 768, pink.darken(0.5), black, ready);
        function ready() {
            const fragment = `
            // VERSION 1 - ShaderToy mainImage(out, in) {} Format
float box(in vec2 _uv, in float _size){
        //leftBottom
        vec2 uv_leftBottom = step(_size,_uv);
        // top-right
        vec2 uv_topRight = step(_size,1.0-_uv);
        return uv_leftBottom.x * uv_leftBottom.y*uv_topRight.x * uv_topRight.y;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord / iResolution.xy;
    vec3 color = vec3(0.0);
    //float pct=box(uv, vec2(0.5,0.5/4.)) ;
    float pct=box(uv,0.25)
    color += vec3(pct);
    fragColor = vec4(color, 1.0);
}
            `;
            var s1 = new Shader(180, 180, fragment).pos(10, 10, LEFT, TOP);
            new Label("s1 ", null, null, red).sca(.6).loc(s1);
        }

    </script>
    <meta name="viewport" content="width=device-width, user-scalable=no" />
</head>

<body>
</body>

</html>

If you turn the log:true on then it shows the vertex and fragment code. The error is saying that the vertexStatus is true so it compiled. But the fragmentStatus has an error on line 29. So I copied the log version of the fragment shader to a file with line numbers and got this:

Line 29 is having a problem with the syntax. Not sure what. Oh... do you need a semicolon on the line before?

ok,thanks

1 Like

I will leave this topic open if you have any more questions, we can try and work through them together.