all shaders compile & validate

This commit is contained in:
Chris Forbes
2010-02-15 18:47:04 +13:00
parent 68844e53c2
commit 91159a090d
2 changed files with 38 additions and 94 deletions

View File

@@ -2,24 +2,16 @@
// Author: C. Forbes // Author: C. Forbes
//-------------------------------------------------------- //--------------------------------------------------------
shared texture DiffuseTexture; float2 r1, r2; // matrix elements
shared float2 r1, r2; // matrix elements
sampler s_DiffuseTexture = sampler_state { sampler2D DiffuseTexture = sampler_state {
Texture = <DiffuseTexture>; MinFilter = Nearest;
MinFilter = None; MagFilter = Nearest;
MagFilter = None;
MipFilter = None;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
}; };
struct VertexIn { struct VertexIn {
float4 Position: POSITION; float4 Position: POSITION;
float2 Tex0: TEXCOORD0; float4 Tex0: TEXCOORD0;
float2 Tex1: TEXCOORD1;
}; };
struct VertexOut { struct VertexOut {
@@ -35,40 +27,25 @@ VertexOut Simple_vp(VertexIn v) {
VertexOut o; VertexOut o;
float2 p = v.Position.xy * r1 + r2; float2 p = v.Position.xy * r1 + r2;
o.Position = float4(p.x,p.y,0,1); o.Position = float4(p.x,p.y,0,1);
o.Tex0 = v.Tex0; o.Tex0 = v.Tex0.xy;
return o; return o;
} }
float4 Simple_fp(FragmentIn f) : COLOR0 { float4 Simple_fp(FragmentIn f) : COLOR0 {
float4 r = tex2D(s_DiffuseTexture, f.Tex0.xy); float4 r = tex2D(DiffuseTexture, f.Tex0);
return r; return r;
} }
/*
technique low_quality {
pass p0 {
AlphaBlendEnable = false;
ZWriteEnable = false;
ZEnable = false;
CullMode = None;
FillMode = Solid;
VertexShader = compile vs_2_0 Simple_vp();
PixelShader = compile ps_2_0 Simple_fp();
}
}
*/
technique high_quality { technique high_quality {
pass p0 { pass p0 {
AlphaBlendEnable = true; BlendEnable = true;
ZWriteEnable = false; DepthTestEnable = false;
ZEnable = false; // CullMode = None;
CullMode = None; // FillMode = Solid;
FillMode = Solid; VertexProgram = compile arbvp1 Simple_vp();
VertexShader = compile vs_2_0 Simple_vp(); FragmentProgram = compile arbfp1 Simple_fp();
PixelShader = compile ps_2_0 Simple_fp();
SrcBlend = SrcAlpha; //SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha; //DestBlend = InvSrcAlpha;
} }
} }

View File

@@ -2,36 +2,26 @@
// Author: C. Forbes // Author: C. Forbes
//-------------------------------------------------------- //--------------------------------------------------------
shared texture DiffuseTexture, Palette; float2 Scroll;
shared float2 Scroll; float2 r1, r2; // matrix elements
shared float2 r1, r2; // matrix elements sampler2D DiffuseTexture = sampler_state {
MinFilter = Nearest;
sampler s_DiffuseTexture = sampler_state { MagFilter = Nearest;
Texture = <DiffuseTexture>; WrapS = Repeat;
MinFilter = None; WrapT = Repeat;
MagFilter = None;
MipFilter = None;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
}; };
sampler s_PaletteTexture = sampler_state { sampler2D Palette = sampler_state {
Texture = <Palette>; MinFilter = Nearest;
MinFilter = None; MagFilter = Nearest;
MagFilter = None; WrapS = Repeat;
MipFilter = None; WrapT = Repeat;
AddressU = Clamp;
AddressV = Clamp;
}; };
struct VertexIn { struct VertexIn {
float4 Position: POSITION; float4 Position: POSITION;
float2 Tex0: TEXCOORD0; float4 Tex0: TEXCOORD0;
float2 Tex1: TEXCOORD1;
}; };
struct VertexOut { struct VertexOut {
@@ -40,11 +30,6 @@ struct VertexOut {
float4 ChannelMask: TEXCOORD1; float4 ChannelMask: TEXCOORD1;
}; };
struct FragmentIn {
float3 Tex0: TEXCOORD0;
float4 ChannelMask: TEXCOORD1;
};
float4 DecodeChannelMask( float x ) float4 DecodeChannelMask( float x )
{ {
if (x > 0) if (x > 0)
@@ -55,45 +40,27 @@ float4 DecodeChannelMask( float x )
VertexOut Simple_vp(VertexIn v) { VertexOut Simple_vp(VertexIn v) {
VertexOut o; VertexOut o;
float2 p = v.Position.xy * r1 + r2; float2 p = v.Position.xy * r1 + r2;
o.Position = float4(p.x,p.y,0,1); o.Position = float4(p.x,p.y,0,1);
o.Tex0 = float3(v.Tex0.x, v.Tex0.y, v.Tex1.x); o.Tex0 = float3(v.Tex0.x, v.Tex0.y, v.Tex0.z);
o.ChannelMask = DecodeChannelMask( v.Tex1.y ); o.ChannelMask = DecodeChannelMask( v.Tex0.w );
return o; return o;
} }
const float2 texelOffset = float2( 0, 1.0f/32.0f ); const float2 texelOffset = float2( 0, 1.0f/32.0f );
float4 Palette_fp(FragmentIn f) : COLOR0 { float4 Palette_fp(VertexOut f) : COLOR0 {
float4 x = tex2D(s_DiffuseTexture, f.Tex0.xy); float4 x = tex2D(DiffuseTexture, f.Tex0.xy);
float2 p = float2( dot(x, f.ChannelMask), f.Tex0.z ); float2 p = float2( dot(x, f.ChannelMask), f.Tex0.z );
return tex2D(s_PaletteTexture, p + texelOffset); return tex2D(Palette, p + texelOffset);
} }
technique low_quality { technique low_quality {
pass p0 { pass p0 {
AlphaBlendEnable = false; BlendEnable = false;
ZWriteEnable = false; DepthTestEnable = false;
ZEnable = false; CullFaceEnable = false;
CullMode = None; VertexProgram = compile arbvp1 Simple_vp();
FillMode = Solid; FragmentProgram = compile arbfp1 Palette_fp();
VertexShader = compile vs_2_0 Simple_vp();
PixelShader = compile ps_2_0 Palette_fp();
}
}
technique high_quality {
pass p0 {
AlphaBlendEnable = true;
ZWriteEnable = false;
ZEnable = false;
CullMode = None;
FillMode = Solid;
VertexShader = compile vs_2_0 Simple_vp();
PixelShader = compile ps_2_0 Palette_fp();
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
} }
} }