Mercurial > LightClone
diff Data/Shaders/TexturedQuad.fx @ 0:7e3a0ae9c016
Initial commit
author | koryspansel <koryspansel@bendbroadband.com> |
---|---|
date | Wed, 07 Sep 2011 12:36:37 -0700 |
parents | |
children | efd2b1ca5b77 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Data/Shaders/TexturedQuad.fx Wed Sep 07 12:36:37 2011 -0700 @@ -0,0 +1,123 @@ +extern uniform float4x4 kProjection; +extern uniform float4x4 kWorld; +extern uniform texture kTexture; +extern uniform float4 kColor; + +/* + * TextureSampler + */ +sampler TextureSampler = sampler_state +{ + Texture = <kTexture>; + MinFilter = POINT; + MagFilter = POINT; + AddressU = CLAMP; + AddressV = CLAMP; +}; + +/* + * VertexInput + */ +struct VertexInput +{ + /* + * Position + */ + float3 Position : POSITION0; + + /* + * TextureCoordinate + */ + float2 TextureCoordinate : TEXCOORD0; +}; + +/* + * VertexOutput + */ +struct VertexOutput +{ + /* + * Position + */ + float4 Position : POSITION0; + + /* + * TextureCoordinate + */ + float2 TextureCoordinate : TEXCOORD0; +}; + +/* + * PixelInput + */ +struct PixelInput +{ + /* + * TextureCoordinate + */ + float2 TextureCoordinate : TEXCOORD0; + + /* + * Color + */ + float4 Color : COLOR0; +}; + +/* + * PixelOutput + */ +struct PixelOutput +{ + /* + * Color + */ + float4 Color : COLOR0; +}; + +/* + * TexturedQuadVS + */ +VertexOutput TexturedQuadVS(VertexInput kInput) +{ + VertexOutput kOutput; + + kOutput.Position = mul(float4(kInput.Position, 1.0f), mul(kWorld, kProjection)); + kOutput.TextureCoordinate = kInput.TextureCoordinate; + + return kOutput; +} + +/* + * TexturedQuadPS + */ +PixelOutput TexturedQuadPS(PixelInput kInput) +{ + PixelOutput kOutput; + + float4 kTexture = tex2D(TextureSampler, kInput.TextureCoordinate); + + kOutput.Color = float4(kTexture.rgb * kColor.rgb, kTexture.a); + //kOutput.Color = kColor; + + return kOutput; +} + +technique Default +{ + pass Opaque + { + vertexShader = compile vs_2_0 TexturedQuadVS(); + pixelShader = compile ps_2_0 TexturedQuadPS(); + + /* + ZEnable = true; + ZWriteEnable = true; + ZFunc = LessEqual; + */ + + AlphaBlendEnable = true; + AlphaFunc = LessEqual; + SrcBlend = SrcAlpha; + DestBlend = InvSrcAlpha; + } +} \ No newline at end of file