Closed
Bug 894231
Opened 12 years ago
Closed 6 years ago
[ANGLE] WebGLES shader renders incorrectly
Categories
(Core :: Graphics: CanvasWebGL, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: iquilezles, Unassigned)
References
()
Details
(Keywords: testcase, Whiteboard: webgl-angle)
Attachments
(1 file)
|
2.94 KB,
text/html
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36
Steps to reproduce:
Go to www.shadertoy.com, then hit the "New" button, and enter the following code:
void main(void)
{
vec2 uv = (gl_FragCoord.xy - iResolution.xy/2.0) / iResolution.xy;
vec3 d = normalize( vec3(uv, 1.0) );
float f = dot(d.xy, d.xy);
gl_FragColor = vec4(f,f,f,1.0);
}
Actual results:
The image rendered all white (as if the swizzling in the line "float f = dot(d.xy, d.xy);" was wrong and z into account in the dot product).
Expected results:
The image should render a radial gradient from black in the center to white in the borders of the viewport.
I tested with an old version (FF8), same issue. Is it possible to have a standalone testcase (a simple HTML file) attached to the bug, please.
Flags: needinfo?(iquilezles)
Keywords: testcase-wanted
Yes, here: http://www.iquilezles.org/trastero/bug.htm
I copy it here for reference too:
<html>
<head>
<title>Bug</title>
<script type="text/javascript">
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
var vsSource = [
"attribute vec2 pos;",
"void main()",
"{",
"gl_Position = vec4(pos.x,pos.y,0.0,1.0);",
"}"
].join("\n");
var fsSource = [
"#ifdef GL_ES",
"precision highp float;",
"#endif",
"void main(void)",
"{",
"vec2 uv = -1.0 + 2.0 * gl_FragCoord.xy / 512.0;",
"vec3 d = normalize( vec3(uv, 1.0) );",
"float f = dot(d.xy, d.xy);",
"gl_FragColor = vec4(f,f,f,1.0);",
"}"
].join("\n");
function myInit()
{
var canvas = document.getElementById("animatedLogo");
var gl = null;
try { gl = canvas.getContext("experimental-webgl", {alpha: true}); }
catch (e) { gl = null; }
if( gl==null )
{
var div = document.createElement("div");
div.innerHTML = "WebGL not found";
var canvasParent = canvas.parentNode;
canvasParent.replaceChild(div, canvas);
return;
}
//----------------------------------------------------
var vertices = new Float32Array([ -1., -1., 1., -1., -1., 1., 1., -1., 1., 1., -1., 1.]);
var quadVBO = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, quadVBO);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
//----------------------------------------------------
var program = gl.createProgram();
var vs = gl.createShader(gl.VERTEX_SHADER);
var fs = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(vs, vsSource);
gl.shaderSource(fs, fsSource);
gl.compileShader(vs);
gl.compileShader(fs);
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.deleteShader(vs);
gl.deleteShader(fs);
gl.linkProgram(program);
gl.colorMask( true, true, true, true );
//----------------------------------------------------
function renderLoop()
{
requestAnimFrame(renderLoop);
gl.viewport( 0, 0, 512, 512 );
gl.useProgram(program);
var al = gl.getAttribLocation(program, "pos");
gl.bindBuffer(gl.ARRAY_BUFFER, quadVBO);
gl.vertexAttribPointer(al, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(al);
gl.drawArrays(gl.TRIANGLES, 0, 6);
gl.disableVertexAttribArray(al);
}
renderLoop();
}
</script>
</head>
<body onload="myInit()" style="background-color:#000000;color:#ffffff">
<canvas id="animatedLogo" width="512" height="512" style="cursor:pointer"></canvas>
<br>
You should see a black to white radial gradient
</body>
</html>
Flags: needinfo?(iquilezles)
It works alright in Firefox Linux, Chrome Windows and Chrome Linux. It's in Firefox Windows that it fails. My guess is it's a bug in the version of ANGLE parser?
Comment 6•12 years ago
|
||
Confirmed with Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0 ID:20131003030203 CSet: 0e26e6f12ad9.
Works with set native OpenGL per webgl.prefer-native-gl;true
Updated•11 years ago
|
Whiteboard: webgl-angle
Comment 7•11 years ago
|
||
FWIW, when re-trying attachment 776628 [details] with native gl I get a crash nowadays. See Bug 849038 Comment 5.
Comment 8•11 years ago
|
||
(In reply to XtC4UaLL [:xtc4uall] from comment #7)
> FWIW, when re-trying attachment 776628 [details] with native gl I get a
> crash nowadays. See Bug 849038 Comment 5.
Known issue. I have a fix.
Comment 9•11 years ago
|
||
(In reply to Jeff Gilbert [:jgilbert] from comment #8)
> (In reply to XtC4UaLL [:xtc4uall] from comment #7)
> > FWIW, when re-trying attachment 776628 [details] with native gl I get a
> > crash nowadays. See Bug 849038 Comment 5.
>
> Known issue. I have a fix.
This is now bug 960319.
Updated•6 years ago
|
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•