diff options
Diffstat (limited to '')
-rw-r--r-- | src/extras/shaders/leedsDefault_PS_x.hlsl (renamed from src/extras/shaders/leedsVehicle_add_PS.hlsl) | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/extras/shaders/leedsVehicle_add_PS.hlsl b/src/extras/shaders/leedsDefault_PS_x.hlsl index 943926cf..0b546523 100644 --- a/src/extras/shaders/leedsVehicle_add_PS.hlsl +++ b/src/extras/shaders/leedsDefault_PS_x.hlsl @@ -1,7 +1,9 @@ struct VS_out { float4 Position : POSITION; float3 TexCoord0 : TEXCOORD0; +#if defined(PASS_BLEND) || defined(PASS_ADD) float2 TexCoord1 : TEXCOORD1; +#endif float4 Color : COLOR0; }; @@ -10,25 +12,38 @@ sampler2D envTex : register(s1); float4 fogColor : register(c0); -float4 fxparams : register(c1); +float4 colorscale : register(c1); +float4 fxparams : register(c2); #define shininess (fxparams.x) float4 main(VS_out input) : COLOR { - float4 pass1 = input.Color*tex2D(diffTex, input.TexCoord0.xy); + float4 pass1 = input.Color*tex2D(diffTex, input.TexCoord0.xy)*colorscale; + pass1.rgb = clamp(pass1.rgb, 0.0, 1.0); + pass1.rgb = lerp(fogColor.rgb, pass1.rgb, input.TexCoord0.z); + + float4 color; +#if defined(PASS_BLEND) || defined(PASS_ADD) float4 pass2 = tex2D(envTex, input.TexCoord1.xy); pass2.a *= shininess; - - pass1.rgb = lerp(fogColor.rgb, pass1.rgb, input.TexCoord0.z); pass2.rgb = lerp(float3(0.0, 0.0, 0.0), pass2.rgb, input.TexCoord0.z); // We simulate drawing this in two passes. +#if defined(PASS_ADD) // First pass with standard blending, second with addition // We premultiply alpha so render state should be one. - float4 color; color.rgb = pass1.rgb*pass1.a + pass2.rgb*pass2.a; color.a = pass1.a; +#elif defined(PASS_BLEND) + // We premultiply alpha so render state should be one. + color.rgb = pass1.rgb*pass1.a*(1.0-pass2.a) + pass2.rgb*pass2.a; + color.a = pass1.a*(1.0-pass2.a) + pass2.a; +#endif + +#else + color = pass1; +#endif return color; } |