lion0406 / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

The shader cannot be compiled #394

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This has been reported to mozilla: 
https://bugzilla.mozilla.org/show_bug.cgi?id=798919

uniform sampler2D samp,csamp;
uniform float h;
varying vec2 tc;

void main(void) {
    gl_FragColor = texture2D(samp,tc);
    vec2 mtc = tc;  //modified texture coord, considering the boundary condition
    if(gl_FragColor.b > 0.){
        mtc.r += (fract(tc.r/2./h)>0.5 && texture2D(samp,vec2(tc.r+h,tc.g)).b==0.) ? 0.5*h : 0.;
        mtc.r -= (fract(tc.r/2./h)<0.5 && texture2D(samp,vec2(tc.r-h,tc.g)).b==0.) ? 0.5*h : 0.;
        mtc.g += (fract(tc.g/2./h)>0.5 && texture2D(samp,vec2(tc.r,tc.g+h)).b==0.) ? 0.5*h : 0.;
        mtc.g -= (fract(tc.g/2./h)<0.5 && texture2D(samp,vec2(tc.r,tc.g-h)).b==0.) ? 0.5*h : 0.;
        gl_FragColor.g += texture2D(csamp,mtc).g*4.;
    }
}

Original issue reported on code.google.com by wild...@gmail.com on 10 Jan 2013 at 1:14

GoogleCodeExporter commented 9 years ago
Thanks for reporting this!

It appears to be a bug in the way we rewrite the code to support 
short-circuiting behavior for the && operator. A quick workaround is to rewrite 
the shader as follows:

uniform sampler2D samp,csamp;
uniform float h;
varying vec2 tc;

void main(void) {
    gl_FragColor = texture2D(samp,tc);
    vec2 mtc = tc;  //modified texture coord, considering the boundary condition
    if(gl_FragColor.b > 0.){
        {mtc.r += (fract(tc.r/2./h)>0.5 && texture2D(samp,vec2(tc.r+h,tc.g)).b==0.) ? 0.5*h : 0.;}
        {mtc.r -= (fract(tc.r/2./h)<0.5 && texture2D(samp,vec2(tc.r-h,tc.g)).b==0.) ? 0.5*h : 0.;}
        {mtc.g += (fract(tc.g/2./h)>0.5 && texture2D(samp,vec2(tc.r,tc.g+h)).b==0.) ? 0.5*h : 0.;}
        {mtc.g -= (fract(tc.g/2./h)<0.5 && texture2D(samp,vec2(tc.r,tc.g-h)).b==0.) ? 0.5*h : 0.;}
        gl_FragColor.g += texture2D(csamp,mtc).g*4.;
    }
}

Note the added curly brackets.

We'll see what can be done to fix this within ANGLE...

Original comment by nicolas....@gmail.com on 10 Jan 2013 at 5:00

GoogleCodeExporter commented 9 years ago
Issue 412 has been merged into this issue.

Original comment by nicolas....@gmail.com on 19 Feb 2013 at 2:25

GoogleCodeExporter commented 9 years ago
Let's make sure to add one or more WebGL conformance tests covering this issue 
once a fix is found.

Original comment by kbr@chromium.org on 19 Feb 2013 at 10:08

GoogleCodeExporter commented 9 years ago

Original comment by nicolas....@gmail.com on 21 Feb 2013 at 3:38

GoogleCodeExporter commented 9 years ago
Fixed in r1835.

Original comment by nicolas....@gmail.com on 28 Feb 2013 at 10:32