Send TS terrain depth data to the GPU.

This commit is contained in:
Paul Chote
2015-04-16 23:25:04 +01:00
parent d5fd8e5828
commit 9a5483fea7
3 changed files with 29 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ uniform sampler2D DiffuseTexture, Palette;
varying vec4 TexCoord;
varying vec4 ChannelMask;
varying vec4 DepthMask;
void main()
{

View File

@@ -3,19 +3,40 @@ uniform vec2 r1,r2; // matrix elements
varying vec4 TexCoord;
varying vec4 ChannelMask;
varying vec4 DepthMask;
vec4 DecodeChannelMask( float x )
vec4 DecodeChannelMask(float x)
{
float y = abs(x);
if (y > 0.7)
return vec4(0,0,0,1);
if (y > 0.5)
return vec4(0,0,1,0);
if (y > 0.3)
return vec4(0,1,0,0);
else
return vec4(1,0,0,0);
}
vec4 DecodeDepthChannelMask(float x)
{
if (x > 0.0)
return (x > 0.5) ? vec4(1,0,0,0) : vec4(0,1,0,0);
return vec4(0,0,0,0);
if (x < -0.7)
return vec4(1,0,0,0);
if (x < -0.5)
return vec4(0,0,0,1);
if (x < -0.3)
return vec4(0,0,1,0);
else
return (x < -0.5) ? vec4(0,0,0,1) : vec4(0,0,1,0);
return vec4(0,1,0,0);
}
void main()
{
vec2 p = (gl_Vertex.xy - Scroll.xy)*r1 + r2;
vec2 p = (gl_Vertex.xy - Scroll.xy) * r1 + r2;
gl_Position = vec4(p.x,p.y,0,1);
TexCoord = gl_MultiTexCoord0;
ChannelMask = DecodeChannelMask(gl_MultiTexCoord0.w);
DepthMask = DecodeDepthChannelMask(gl_MultiTexCoord0.w);
}