From 91159a090dee7229c95839ccf082e1404c63bfcc Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 15 Feb 2010 18:47:04 +1300 Subject: [PATCH] all shaders compile & validate --- chrome-rgba.fx | 53 ++++++++++----------------------- chrome-shp.fx | 79 +++++++++++++++----------------------------------- 2 files changed, 38 insertions(+), 94 deletions(-) diff --git a/chrome-rgba.fx b/chrome-rgba.fx index e118112e07..9fc0532280 100644 --- a/chrome-rgba.fx +++ b/chrome-rgba.fx @@ -2,24 +2,16 @@ // Author: C. Forbes //-------------------------------------------------------- -shared texture DiffuseTexture; -shared float2 r1, r2; // matrix elements +float2 r1, r2; // matrix elements -sampler s_DiffuseTexture = sampler_state { - Texture = ; - MinFilter = None; - MagFilter = None; - MipFilter = None; - - AddressU = Wrap; - AddressV = Wrap; - AddressW = Wrap; +sampler2D DiffuseTexture = sampler_state { + MinFilter = Nearest; + MagFilter = Nearest; }; struct VertexIn { float4 Position: POSITION; - float2 Tex0: TEXCOORD0; - float2 Tex1: TEXCOORD1; + float4 Tex0: TEXCOORD0; }; struct VertexOut { @@ -35,40 +27,25 @@ VertexOut Simple_vp(VertexIn v) { VertexOut o; float2 p = v.Position.xy * r1 + r2; o.Position = float4(p.x,p.y,0,1); - o.Tex0 = v.Tex0; + o.Tex0 = v.Tex0.xy; return o; } float4 Simple_fp(FragmentIn f) : COLOR0 { - float4 r = tex2D(s_DiffuseTexture, f.Tex0.xy); + float4 r = tex2D(DiffuseTexture, f.Tex0); 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 { pass p0 { - AlphaBlendEnable = true; - ZWriteEnable = false; - ZEnable = false; - CullMode = None; - FillMode = Solid; - VertexShader = compile vs_2_0 Simple_vp(); - PixelShader = compile ps_2_0 Simple_fp(); + BlendEnable = true; + DepthTestEnable = false; +// CullMode = None; +// FillMode = Solid; + VertexProgram = compile arbvp1 Simple_vp(); + FragmentProgram = compile arbfp1 Simple_fp(); - SrcBlend = SrcAlpha; - DestBlend = InvSrcAlpha; + //SrcBlend = SrcAlpha; + //DestBlend = InvSrcAlpha; } } diff --git a/chrome-shp.fx b/chrome-shp.fx index 3a47816c2e..d689f71f54 100644 --- a/chrome-shp.fx +++ b/chrome-shp.fx @@ -2,36 +2,26 @@ // Author: C. Forbes //-------------------------------------------------------- -shared texture DiffuseTexture, Palette; -shared float2 Scroll; +float2 Scroll; +float2 r1, r2; // matrix elements -shared float2 r1, r2; // matrix elements - -sampler s_DiffuseTexture = sampler_state { - Texture = ; - MinFilter = None; - MagFilter = None; - MipFilter = None; - - AddressU = Wrap; - AddressV = Wrap; - AddressW = Wrap; +sampler2D DiffuseTexture = sampler_state { + MinFilter = Nearest; + MagFilter = Nearest; + WrapS = Repeat; + WrapT = Repeat; }; -sampler s_PaletteTexture = sampler_state { - Texture = ; - MinFilter = None; - MagFilter = None; - MipFilter = None; - - AddressU = Clamp; - AddressV = Clamp; +sampler2D Palette = sampler_state { + MinFilter = Nearest; + MagFilter = Nearest; + WrapS = Repeat; + WrapT = Repeat; }; struct VertexIn { float4 Position: POSITION; - float2 Tex0: TEXCOORD0; - float2 Tex1: TEXCOORD1; + float4 Tex0: TEXCOORD0; }; struct VertexOut { @@ -40,11 +30,6 @@ struct VertexOut { float4 ChannelMask: TEXCOORD1; }; -struct FragmentIn { - float3 Tex0: TEXCOORD0; - float4 ChannelMask: TEXCOORD1; -}; - float4 DecodeChannelMask( float x ) { if (x > 0) @@ -55,45 +40,27 @@ float4 DecodeChannelMask( float x ) VertexOut Simple_vp(VertexIn v) { VertexOut o; - float2 p = v.Position.xy * r1 + r2; o.Position = float4(p.x,p.y,0,1); - o.Tex0 = float3(v.Tex0.x, v.Tex0.y, v.Tex1.x); - o.ChannelMask = DecodeChannelMask( v.Tex1.y ); + o.Tex0 = float3(v.Tex0.x, v.Tex0.y, v.Tex0.z); + o.ChannelMask = DecodeChannelMask( v.Tex0.w ); return o; } const float2 texelOffset = float2( 0, 1.0f/32.0f ); -float4 Palette_fp(FragmentIn f) : COLOR0 { - float4 x = tex2D(s_DiffuseTexture, f.Tex0.xy); +float4 Palette_fp(VertexOut f) : COLOR0 { + float4 x = tex2D(DiffuseTexture, f.Tex0.xy); float2 p = float2( dot(x, f.ChannelMask), f.Tex0.z ); - return tex2D(s_PaletteTexture, p + texelOffset); + return tex2D(Palette, p + texelOffset); } 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 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; + BlendEnable = false; + DepthTestEnable = false; + CullFaceEnable = false; + VertexProgram = compile arbvp1 Simple_vp(); + FragmentProgram = compile arbfp1 Palette_fp(); } }