// LFS Pixel Shader : CAR1 #define SHINY // Vertex shader output structure struct VS_OUTPUT { float4 oPos : POSITION; float4 oD0 : COLOR0; float4 oD1 : COLOR1; #ifdef SHINY float2 EnvA : TEXCOORD3; // using TEXCOORD3 to pass envmap alpha to pixel shader #endif float2 oT0 : TEXCOORD0; float2 oT1 : TEXCOORD1; #ifdef SHINY float2 oT2 : TEXCOORD2; #endif float oFog : FOG; }; // Pixel shader output structure struct PS_OUTPUT { float4 Colour : COLOR0; }; // Global variables sampler2D s_T0 : register(s0); // lightmap sampler2D s_T1 : register(s1); // texture #ifdef SHINY sampler2D s_T2 : register(s2); // envmap #endif // Main function PS_OUTPUT ps_main( in VS_OUTPUT In ) { PS_OUTPUT Out; float4 lightmap_col = tex2D(s_T0, In.oT0); float4 texture_col = tex2D(s_T1, In.oT1); #ifdef SHINY float4 envmap_col = tex2D(s_T2, In.oT2); #endif // multiply by alpha because, when alpha is enabled, SRC_BLEND is SRC_ONE (not reduced by alpha) float3 total_lighting = (In.oD0.rgb * lightmap_col.rgb + In.oD1.rgb) * texture_col.a; Out.Colour.rgb = total_lighting * texture_col.rgb; Out.Colour.a = texture_col.a; // destination pixel is reduced by this value #ifdef SHINY Out.Colour.rgb += envmap_col.rgb * In.EnvA.x; // add environment map #endif return Out; }