2

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.