Send TS terrain depth data to the GPU.
This commit is contained in:
@@ -19,7 +19,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
// yes, our channel order is nuts.
|
||||
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
||||
static readonly float[] ChannelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||
static readonly float[] ChannelSelect = { 0.2f, 0.4f, 0.6f, 0.8f };
|
||||
|
||||
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, float paletteTextureIndex, int nv, float2 size)
|
||||
{
|
||||
@@ -32,6 +32,8 @@ namespace OpenRA.Graphics
|
||||
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, float paletteTextureIndex, int nv)
|
||||
{
|
||||
var attribC = ChannelSelect[(int)r.Channel];
|
||||
if (r.Sheet.Type == SheetType.DualIndexed)
|
||||
attribC *= -1;
|
||||
|
||||
vertices[nv] = new Vertex(a, r.Left, r.Top, paletteTextureIndex, attribC);
|
||||
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, paletteTextureIndex, attribC);
|
||||
|
||||
@@ -2,6 +2,7 @@ uniform sampler2D DiffuseTexture, Palette;
|
||||
|
||||
varying vec4 TexCoord;
|
||||
varying vec4 ChannelMask;
|
||||
varying vec4 DepthMask;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user