sampler2D Tex0; sampler2D Tex1; sampler2D Tex2; sampler2D Tex7; sampler2D Tex8; sampler2D Tex10; samplerCUBE ReflectionTex; samplerCUBE RealtimeReflectionTex; float4 Ambient; //float3 ReflectionMult; float3x3 View; float3 WorldReflectionMult; float WorldReflectionPower; float3 CarReflectionMult; float CarReflectionPower; float Timer; #define NOMOTION #include "dcSuperShader_Data.HLSL" #ifndef DiffuseComponent #define DiffuseComponent rgba #endif #ifndef SpecularComponent #define SpecularComponent rgba #endif #ifndef ReflectionPower #define ReflectionPower 1 #endif #ifndef ReflectionMult #define ReflectionMult 1 #endif struct PS_INPUT{ dcShaderData Data : TEXCOORD0; }; #define Output0(x) Out.RT0 = x struct PS_OUTPUT{ float4 RT0 : COLOR0; }; float4 ComputeDiffuse(const PS_INPUT Input){ #ifdef DIFFUSE float4 Diffuse = tex2D(DiffuseTex, DiffuseUV); #else float4 Diffuse = 0; #endif #ifdef DIFFUSE_DETAILTEX0 float3 DirtTexColor0 = tex2D(DiffuseDetailTex0, Detail0UV).rgb; Diffuse.rgb = (Diffuse.rgb + DirtTexColor0) - 0.5f; #endif #ifdef DIFFUSE_DETAILTEX1 float3 DirtTexColor1 = tex2D(DiffuseDetailTex1, Detail1UV).rgb; Diffuse.rgb = (Diffuse.rgb + DirtTexColor1) - 0.5f; #endif return Diffuse; } float4 ComputeSpecular(const PS_INPUT Input){ #ifdef SPECULAR float4 Specular = tex2D(SpecularTex, SpecularUV); #else float4 Specular = 0; #endif #ifdef SPECULAR_DETAILTEX0 float3 DirtTexColor0 = tex2D(DiffuseDetailTex0, Detail0UV).rgb; Specular.rgb *= DirtTexColor0; #endif #ifdef SPECULAR_DETAILTEX1 float3 DirtTexColor1 = tex2D(DiffuseDetailTex1, Detail1UV).rgb; Specular.rgb *= DirtTexColor1; #endif return Specular; } float3 ComputeNormal(const PS_INPUT Input){ #if defined(FACENORMAL) float3 Normal = Input.Data.Normal; #elif defined(NORMALMAP) #ifndef COMPRESSEDNORMAL float3 Normal = (tex2D(NormalTex, NormalUV).xyz - 0.5f) * 2; #else float3 Normal; Normal.xy = (tex2D(NormalTex, NormalUV).xy - 0.5f) * 2.0f; Normal.z = -sqrt(1.0f - dot(Normal.xy, Normal.xy)); #endif #ifdef WATERSHADER float2 BumpTex0 = NormalUV + float2(Timer / 15.1f, 0); float2 BumpTex1 = NormalUV + float2(0, Timer / 17.4f); float3 N0 = (tex2D(NormalTex, BumpTex0) - 0.5f); float3 N1 = (tex2D(NormalTex, BumpTex1) - 0.5f); Normal = normalize(N0 + N1); #endif Normal = mul(Normal, Input.Data.NormalMatrix); #else float3 Normal = 0; #endif return Normal; } float3 ComputeReflectionNormal(const PS_INPUT Input){ #if defined(FACENORMAL) float3 Normal = Input.Data.Normal; #elif defined(NORMALMAP) #ifndef COMPRESSEDNORMAL float3 Normal = (tex2D(ReflectionNormalTex, ReflectionNormalUV).xyz - 0.5f) * 2; #else float3 Normal; Normal.xy = (tex2D(ReflectionNormalTex, ReflectionNormalUV).xy - 0.5f) * 2.0f; Normal.z = -sqrt(1.0f - dot(Normal.xy, Normal.xy)); #endif #ifdef WATERSHADER float2 BumpTex0 = ReflectionNormalUV + float2(Timer / 15.1f, 0); float2 BumpTex1 = ReflectionNormalUV + float2(0, Timer / 17.4f); float3 N0 = (tex2D(ReflectionNormalTex, BumpTex0) - 0.5f); float3 N1 = (tex2D(ReflectionNormalTex, BumpTex1) - 0.5f); Normal = normalize(N0 + N1); #endif Normal = mul(Normal, Input.Data.NormalMatrix); #else float3 Normal = 0; #endif Normal = mul(Normal, transpose(View)); return Normal; } float3 ComputeReflectionVector(const PS_INPUT Input){ #ifdef REFLECTIVE #if defined(FACENORMAL) float3 R = Input.Data.R; #elif defined(NORMALMAP) float3 N = ComputeReflectionNormal(Input); float3 V = Input.Data.V; float3 R = 2 * dot(N, V) * N - V; #endif return R; #else return 0; #endif } float3 ComputeReflection(const PS_INPUT Input){ #ifdef REFLECTIVE float4 Specular = ComputeSpecular(Input); float3 R = ComputeReflectionVector(Input); float3 Reflection = texCUBE(ReflectiveTex, R).rgb;; Reflection = pow(Reflection, ReflectionPower) * Specular.rgb; Reflection *= ReflectionMult; return Reflection; #else return 0; #endif } PS_OUTPUT main(const PS_INPUT Input){ float4 Diffuse = ComputeDiffuse(Input); float4 Specular = ComputeSpecular(Input); float3 Normal = ComputeNormal(Input); float3 Reflection = ComputeReflection(Input); PS_OUTPUT Out; Output0(float4((Diffuse.rgb * Diffuse.a) + Reflection, Diffuse.a)); return Out; }