fragment shader Webgl ERROR: 0:7: 'return' : function return is not matching type:

Viewed 86

I don't understand why the return type doesn't match.

working with webgl ERROR: 0:7: 'return' : function return is not matching type:

precision mediump float;
uniform sampler2D previousState;

  float NablaAHelper(vec2 coord){
    if (coord.x < 0.0 || 64.0 < coord.x || coord.y < 0.0 || 64.0 < coord.y) return 0;
    vec4 px = texture2D(previousState, coord/64.0);
    return px.r;<--------
   }

  void main(void) {
    vec2 coord = vec2(gl_FragCoord);
    float NablaA =
        NablaAHelper(coord+vec2(0.,0.))*-1.0+
        ....  
1 Answers

I think you are mislead by the line number. Maybe whatever you use to upload the shader will add some lines at the beginning, likely a #version directive.

The issue is clearly

if (coord.x < 0.0 [...]) return 0;

as there are no implicit type conversions in GLSL 1.0 ES.

Related