| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- //////////////////////////////////////////////////////////////////////////////
- // ©2006 Electronic Arts Inc
- //
- // FX Shader for Render2D
- //////////////////////////////////////////////////////////////////////////////
- #include "Common.fxh"
- // ----------------------------------------------------------------------------
- // Textures declaration
- // ----------------------------------------------------------------------------
- SAMPLER_2D_BEGIN(BaseTexture,
- string SasBindAddress = "WW3D.MiscTexture";
- int WW3DDynamicSet = DS_CUSTOM_FIRST;
- )
- AddressU = Clamp;
- AddressV = Clamp;
- MinFilter = Linear;
- MagFilter = Linear;
- MipFilter = Linear;
- SAMPLER_2D_END
- // ----------------------------------------------------------------------------
- // Transformations
- // ----------------------------------------------------------------------------
- float4x4 World : World;
- // ---------------------------------------------------------------------------
- struct VSOutput
- {
- float4 Position : POSITION;
- float4 Color : COLOR0;
- float2 BaseTexCoord : TEXCOORD0;
- };
- // ---------------------------------------------------------------------------
- VSOutput VS(float3 Position : POSITION, float2 TexCoord0 : TEXCOORD0, float4 color : COLOR0 )
- {
- VSOutput Out;
-
- Out.Position = mul(float4(Position, 1), World);
- Out.Color = color;
- Out.BaseTexCoord = TexCoord0;
-
- return Out;
- }
- // ---------------------------------------------------------------------------
- float4 PS(VSOutput In) : COLOR
- {
- // Get vertex color
- float4 color = In.Color;
- // Apply texture
- color *= tex2D(SAMPLER(BaseTexture), In.BaseTexCoord);
- return color;
- }
- // ---------------------------------------------------------------------------
- float4 PSGray(VSOutput In) : COLOR
- {
- // Get vertex color
- float4 color = In.Color;
- // Get texture
- float4 textureSample = tex2D(SAMPLER(BaseTexture), In.BaseTexCoord);
-
- // Convert texture to gray scale
- float3 grayMix = float3(0.30, 0.59, 0.11);
- color.xyz *= dot(textureSample.xyz, grayMix);
- // Multiply alpha
- color.w *= textureSample.w;
- return color;
- }
- // ---------------------------------------------------------------------------
- float4 PSIgnoreTextureAlpha(VSOutput In) : COLOR
- {
- // Get vertex color
- float4 color = In.Color;
- // Apply texture
- color.xyz *= tex2D(SAMPLER(BaseTexture), In.BaseTexCoord);
- return color;
- }
- // ---------------------------------------------------------------------------
- technique Copy
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- }
- }
- technique Additive
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = true;
- SrcBlend = One;
- DestBlend = One;
- AlphaTestEnable = false;
- }
- }
- technique AlphaBlend
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = true;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
- AlphaTestEnable = false;
- }
- }
- technique Gray
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PSGray();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = true;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
- AlphaTestEnable = false;
- }
- }
- technique GrayCopy
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PSGray();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = false;
- }
- }
- technique AlphaTestCopy
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = false;
- AlphaTestEnable = true;
- AlphaFunc = GreaterEqual;
- AlphaRef = DEFAULT_ALPHATEST_THRESHOLD;
- }
- }
- technique AlphaWithSolidTexture
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PSIgnoreTextureAlpha();
-
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = false;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
- AlphaTestEnable = false;
- }
- }
- technique AptRenderer
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
- ZEnable = false;
- ZWriteEnable = false;
- CullMode = None;
-
- AlphaBlendEnable = true;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
-
- AlphaTestEnable = false;
- }
- }
|