This bug was found using Godot, but it work even in minimal OpenGL3+ engine
Bug confirmed on Nvidia 750, Nvidia 960, Nvidia 1080 series, have not other test results
Windows and Linux, bug work
Test:
fastest way is launching Web-browser version with ANGLE disabled
chrome.exe --use-angle=gl
then open this link Web Bug Test link
(AMD do not have this bug, and Nvidia with ANGLE enabled on WIndows in DX11 mode also do not have this bug)
Bug result:
Correct result:
Shader code:
(this code is right quad on screenshot)
main.vert
#version 300 es
in vec4 position;
out mat4 mtx;
out mat4 tmtx;
void translate(inout mat4 m, vec3 d){
m[3][0] = d.x;
m[3][1] = d.y;
m[3][2] = d.z;
m[3].xyz=d; //does not matter, both does not work
}
void main() {
gl_Position = vec4(position.xyz,1.);
mtx=mat4(vec4(1.),vec4(1.),vec4(1.),vec4(1.));
tmtx=mat4(vec4(0.),vec4(0.),vec4(0.),vec4(0.));
tmtx=mtx;
vec3 a=vec3(1.,0.,0.);
vec3 b=vec3(0.,1.,0.);
//bug
translate(tmtx,a);
//tmtx[3].xyz=a; //fix
mtx[3].xyz=b;
}
main.frag
#version 300 es
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 u_resolution;
out vec4 glFragColor;
in mat4 mtx;
in mat4 tmtx;
void main() {
vec2 uv = gl_FragCoord.xy/u_resolution.xy;
vec3 col = vec3(0.);
if(uv.x<0.5)col = mtx[3].xyz;
else col = tmtx[3].xyz;
glFragColor = vec4(col,1.);
}
This bug very big and ruin lots of mat4 logic if mat4 calculated in the Vertex shader, this is an only minimal example, in large code this bug very unpredictable