'GLSL For loop has "Invalid Condition"

Im trying to get a piece of GLSL code from shadertoy to function in WebGL.

Specifically this shadertoy by iq: https://www.shadertoy.com/view/Xds3zN

Ive implemented the correct uniform objects and it seems to work with most shadertoy shaders I convert, however, the one in the link above has several issues.

I solved everything except for a single error which states

ERROR line 381  For    Invalid condition

The modified code I made is located here: https://pastebin.com/tgRhLNpA (Its too large to post in here)

The error is in the for loop condition within this block:

    // raymarch primitives   
    vec2 tb = iBox( ro-vec3(0.0,0.4,-0.5), rd, vec3(2.5,0.41,3.0) );
    if( tb.x<tb.y && tb.y>0.0 && tb.x<tmax)
    {
        //return vec2(tb.x,2.0);
        tmin = max(tb.x,tmin);
        tmax = min(tb.y,tmax);

        float t = tmin;
        for(int i=0; (i < 70) && (t < tmax); i++)
        {
            vec2 h = map( ro+rd*t );
            if( abs(h.x)<(0.0001*t) )
            { 
                res = vec2(t,h.y); 
                break;
            }
            t += h.x;
        }
    }

The original code IQ used was i<70 && t<tmax which errored, so I tried (i < 70) && (t < tmax) and I also tried (i < 70 && t < tmax) but both also had the same error..

As far as Im aware, Shadertoy/OpenGL and WebGL should share the same GLSL syntax features (iirc, shadertoy compiles GLSL into HLSL, Im not 100% sure), so Im confused as to why it would be invalid when I ran it with WebGL, but valid with Shadertoy



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source