| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- //////////////////////////////////////////////////////////////////////////////
- // ©2006 Electronic Arts Inc
- //
- // FX Shader for rendering the terrain tracks left by vehicle
- //////////////////////////////////////////////////////////////////////////////
- #include "Common.fxh"
- #include "Gamma.fxh"
- // ----------------------------------------------------------------------------
- // Transformations
- // ----------------------------------------------------------------------------
- #if defined(_WW3D_)
- #if !defined(USE_INDIRECT_CONSTANT)
- float4x4 ViewProjection
- <
- string UIWidget = "None";
- string SasBindAddress = "Sas.Camera.WorldToProjection";
- >;
- #endif // #if !defined(USE_INDIRECT_CONSTANT)
- float4x4 GetViewProjection()
- {
- return ViewProjection;
- }
- #else
- float4x4 View : View;
- float4x4 Projection : Projection;
- float4x4 GetViewProjection()
- {
- return mul(View, Projection);
- }
- #endif
- // ----------------------------------------------------------------------------
- // Textures declaration
- // ----------------------------------------------------------------------------
- SAMPLER_2D_BEGIN(Texture_0,
- string UIWidget = "None";
- string SasBindAddress = "WW3D.MiscTexture";
- int WW3DDynamicSet = DS_CUSTOM_FIRST;
- )
- AddressU = Clamp;
- AddressV = Clamp;
- MinFilter = Linear;
- MagFilter = Linear;
- MipFilter = Linear;
- SAMPLER_2D_END
- // ---------------------------------------------------------------------------
- struct VSOutput
- {
- float4 Position : POSITION;
- float4 DiffuseColor : COLOR0;
- float2 BaseTexCoord : TEXCOORD0;
- };
- // ---------------------------------------------------------------------------
- VSOutput VS(float3 Position : POSITION, float2 TexCoord0 : TEXCOORD0, float4 color : COLOR0 )
- {
- VSOutput Out;
-
- Out.Position = mul(float4(Position, 1), GetViewProjection());
- Out.DiffuseColor = color;
-
- Out.BaseTexCoord = TexCoord0;
-
- return Out;
- }
- // ---------------------------------------------------------------------------
- float4 PS(VSOutput In) : COLOR
- {
- // Get vertex color
- float4 color = In.DiffuseColor;
- // Apply texture
- float4 baseTextureColor = tex2D(SAMPLER(Texture_0), In.BaseTexCoord);
- baseTextureColor.xyz = GammaToLinear(baseTextureColor.xyz);
- color *= baseTextureColor;
- return color;
- }
- // ---------------------------------------------------------------------------
- technique Default
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS();
- ZEnable = true;
- ZFunc = ZFUNC_INFRONT;
- ZWriteEnable = false;
- CullMode = CW;
- ColorWriteEnable = RGB;
-
- AlphaBlendEnable = true;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
-
- AlphaTestEnable = false;
- }
- }
- // ---------------------------------------------------------------------------
- float4 PS_M(VSOutput In) : COLOR
- {
- // Get vertex color
- float4 color = In.DiffuseColor;
- // Apply texture
- float4 baseTextureColor = tex2D(SAMPLER(Texture_0), In.BaseTexCoord);
- color *= baseTextureColor;
- return color;
- }
- // ---------------------------------------------------------------------------
- technique Default_M
- {
- pass P0
- {
- VertexShader = compile VS_2_0 VS();
- PixelShader = compile PS_2_0 PS_M();
- ZEnable = true;
- ZFunc = ZFUNC_INFRONT;
- ZWriteEnable = false;
- CullMode = CW;
- ColorWriteEnable = RGB;
-
- AlphaBlendEnable = true;
- SrcBlend = SrcAlpha;
- DestBlend = InvSrcAlpha;
-
- AlphaTestEnable = false;
- }
- }
|