Pass depth scale factors to vertex shaders.
This commit is contained in:
@@ -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 vTexCoord;
|
||||
|
||||
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);
|
||||
vTexCoord = aVertexTexCoord;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
uniform sampler2D DiffuseTexture, Palette;
|
||||
|
||||
uniform bool EnableDepthPreview;
|
||||
uniform float DepthTextureScale;
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
@@ -17,9 +18,24 @@ void main()
|
||||
discard;
|
||||
|
||||
if (EnableDepthPreview && length(vDepthMask) > 0.0)
|
||||
{
|
||||
float depth = dot(x, vDepthMask);
|
||||
gl_FragColor = vec4(depth, depth, depth, 1);
|
||||
{
|
||||
if (abs(DepthTextureScale) > 0.0)
|
||||
{
|
||||
// Preview vertex aware depth
|
||||
float depth = gl_FragCoord.z + DepthTextureScale * dot(x, vDepthMask);
|
||||
|
||||
// Convert to window coords
|
||||
depth = 0.5 * depth + 0.5;
|
||||
|
||||
// Front of the depth buffer is at 0, but we want to render it as bright
|
||||
gl_FragColor = vec4(vec3(1.0 - depth), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Preview boring sprite-only depth
|
||||
float depth = dot(x, vDepthMask);
|
||||
gl_FragColor = vec4(depth, depth, depth, 1.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
gl_FragColor = c;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
uniform vec2 Scroll;
|
||||
uniform vec2 r1,r2; // matrix elements
|
||||
uniform vec3 Scroll;
|
||||
uniform vec3 r1, r2;
|
||||
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
@@ -36,8 +36,7 @@ vec4 DecodeDepthChannelMask(float x)
|
||||
|
||||
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);
|
||||
vTexCoord = aVertexTexCoord;
|
||||
vChannelMask = DecodeChannelMask(aVertexTexCoord.w);
|
||||
vDepthMask = DecodeDepthChannelMask(aVertexTexCoord.w);
|
||||
|
||||
Reference in New Issue
Block a user