• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders Frag Shader error '='

ajrdesign

Member
Getting this error with a shader and I don't know what it means:

Fragment Shader: shd_shield at line 20: '='

Here's the frag shader:
GML:
varying vec2 fragCoord;
uniform float res;

uniform float time;

const float HEX_SCALE = 36.0;
const float BORDER = 0.99;
const float GLOW = 1.03;

const vec3 color = vec3(0.48,0.72,0.71);


vec2  hex(vec2 uv )
{
    const vec3 hexProportions = vec3(1.0, 1.0 / sqrt(3.0), sqrt(3.0));  /// line 20 where the error is supposed to be.
    vec2 hexIndex = floor(uv * hexProportions.xz);
    vec2 r        = fract(hexIndex * 0.5) ;
    vec2 cmp      = vec2(r.y > r.x, r.x > r.y);
    vec4 useIndex = vec4(hexIndex + cmp, hexIndex + 1.0 - cmp );
    vec4 delta    = uv.xyxy - useIndex  * hexProportions.xyxy;
    return mix(useIndex.zw, useIndex.xy,  ( dot(delta.xy, delta.xy) < dot(delta.zw, delta.zw) ) ? 1.0 : 0.0 );
}


void main(void)
{
    vec2 iResolution = vec2(res,res);
    vec2 uv = fragCoord.xy*2. / iResolution-vec2(1.);
    //vec2 mouse_pos = mouseCoord;

    /// Fisheye Distortion ///
   
    float d=length(uv*1.0);
    float z = sqrt(1.0 - d * d);
    float r = atan(d, z) / 3.14159;
    float phi = atan(uv.y, uv.x);
   
    uv = vec2(r*cos(phi)+.5,r*sin(phi)+.5);
   
   
    /////////////////////////
    vec2 h = hex( uv * HEX_SCALE );
   
    //float m_dist = smoothstep(0.1,1.0,distance(mouse_pos,uv));
   
        // black out everything outside the circle
    //Also you can use step which checks if d<1.0 (returning 1.0).
    float pulse_time = abs(cos(time*0.001));
    float inner_alpha = step(d,BORDER) * (max(0.25,(smoothstep(0.25,BORDER,d)*0.75)));
    float border_alpha = (step(BORDER,d) - (0.1*pulse_time)) - step(1.0,d);
    //float glow_amt = smoothstep(MAX_GLOW,GLOW, abs(sin(time*0.001)));
    float glow_alpha = max(0.0,smoothstep(GLOW + (0.04*pulse_time),1.0,d) - step(d,1.0) - (0.5));
    float alpha =  (inner_alpha + border_alpha + glow_alpha);

   
    vec3 c = vec3((sin(h.y * h.x * 1.0) + 1.0) * 0.25);
    vec3 final = vec3(0.0);
    final = mix(color,c,0.25);
   
    gl_FragColor=vec4(final,alpha);          
}
 

Nidoking

Member
I don't see anything about your hexProportions variable that requires it to be declared in the function. Why have you declared it inside the function instead of where all the other consts are declared?
 

rytan451

Member
Put the const vec3 hexProportions declaration outside the method. If that doesn't work, then remove the const from the declaration.
 

Xor

@XorDev
rytan451 is right. In GMS, you can't currently set a const to any value using a function like sqrt, even if it's value was constant. Just remove the const and it should work fine!
 
Top