Add depth buffer support to RgbaColorRenderer.

This commit is contained in:
Paul Chote
2015-10-01 18:55:54 +01:00
parent d08cc10abb
commit 50da18cd22
7 changed files with 80 additions and 48 deletions

View File

@@ -1,6 +1,18 @@
varying vec4 vColor;
uniform bool EnableDepthPreview;
void main()
{
gl_FragColor = vColor;
float depth = gl_FragCoord.z;
// Convert to window coords
gl_FragDepth = 0.5 * depth + 0.5;
if (EnableDepthPreview)
{
// Front of the depth buffer is at 0, but we want to render it as bright
gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0);
}
else
gl_FragColor = vColor;
}

View File

@@ -1,5 +1,5 @@
uniform vec2 Scroll;
uniform vec2 r1, r2;
uniform vec3 Scroll;
uniform vec3 r1, r2;
attribute vec4 aVertexPosition;
attribute vec4 aVertexTexCoord;
@@ -7,7 +7,6 @@ varying vec4 vColor;
void main()
{
vec2 p = (aVertexPosition.xy - Scroll.xy)*r1 + r2;
gl_Position = vec4(p.x,p.y,0,1);
gl_Position = vec4((aVertexPosition.xyz - Scroll.xyz) * r1 + r2, 1);
vColor = aVertexTexCoord;
}