#line 2 "D:\RUNTIMES\SXR2\Data\Common\Shaders\Generated\CwDepthOutputMaterial\00802349-00000800-00000000-000D0000-P.hlsl" /* Shader description: APPLYMODE = 1 WORLDPOSITION = 0 WORLDNORMAL = 0 WORLDNBT = 1 WORLDVIEW = 0 NORMALMAPTYPE = 2 PARALLAXMAPCOUNT = 0 BASEMAPCOUNT = 1 NORMALMAPCOUNT = 1 DARKMAPCOUNT = 0 DETAILMAPCOUNT = 0 BUMPMAPCOUNT = 0 GLOSSMAPCOUNT = 1 GLOWMAPCOUNT = 0 CUSTOMMAP00COUNT = 0 CUSTOMMAP01COUNT = 0 CUSTOMMAP02COUNT = 0 CUSTOMMAP03COUNT = 0 CUSTOMMAP04COUNT = 0 DECALMAPCOUNT = 0 FOGENABLED = 1 ENVMAPTYPE = 0 PROJLIGHTMAPCOUNT = 0 PROJLIGHTMAPTYPES = 0 PROJLIGHTMAPCLIPPED = 0 PROJSHADOWMAPCOUNT = 0 PROJSHADOWMAPTYPES = 0 PROJSHADOWMAPCLIPPED = 0 PERVERTEXLIGHTING = 1 UVSETFORMAP00 = 0 UVSETFORMAP01 = 0 UVSETFORMAP02 = 0 UVSETFORMAP03 = 0 UVSETFORMAP04 = 0 UVSETFORMAP05 = 0 UVSETFORMAP06 = 0 UVSETFORMAP07 = 0 UVSETFORMAP08 = 0 UVSETFORMAP09 = 0 UVSETFORMAP10 = 0 UVSETFORMAP11 = 0 POINTLIGHTCOUNT = 0 SPOTLIGHTCOUNT = 0 DIRLIGHTCOUNT = 0 SHADOWMAPFORLIGHT = 0 SPECULAR = 1 AMBDIFFEMISSIVE = 2 LIGHTINGMODE = 1 APPLYAMBIENT = 0 BASEMAPALPHAONLY = 0 APPLYEMISSIVE = 0 SHADOWTECHNIQUE = 0 ALPHATEST = 0 */ //--------------------------------------------------------------------------- // Constant variables: //--------------------------------------------------------------------------- sampler2D Normal; sampler2D Base; sampler2D Gloss; float4 g_FogColor; //--------------------------------------------------------------------------- // Functions: //--------------------------------------------------------------------------- /* This fragment is responsible for normalizing a float3. */ void NormalizeFloat3(float3 VectorIn, out float3 VectorOut) { VectorOut = normalize(VectorIn); } //--------------------------------------------------------------------------- /* This fragment is responsible for sampling a texture and returning its value as a RGB value and an A value. */ void TextureRGBASample(float2 TexCoord, sampler2D Sampler, bool Saturate, out float4 ColorOut) { ColorOut = tex2D(Sampler, TexCoord); if (Saturate) { ColorOut = saturate(ColorOut); } } //--------------------------------------------------------------------------- /* This fragment is responsible for sampling a texture and returning its value as a RGB value. */ void TextureRGBSample(float2 TexCoord, sampler2D Sampler, bool Saturate, out float3 ColorOut) { ColorOut.rgb = tex2D(Sampler, TexCoord).rgb; if (Saturate) { ColorOut.rgb = saturate(ColorOut.rgb); } } //--------------------------------------------------------------------------- /* This fragment is responsible for multiplying two float3's. */ void MultiplyFloat3(float3 V1, float3 V2, out float3 Output) { Output = V1 * V2; } //--------------------------------------------------------------------------- /* Separate a float4 into a float3 and a float. */ void SplitColorAndOpacity(float4 ColorAndOpacity, out float3 Color, out float Opacity) { Color.rgb = ColorAndOpacity.rgb; Opacity = ColorAndOpacity.a; } //--------------------------------------------------------------------------- /* This fragment is responsible for sampling a normal map to generate the new world-space normal. The normal map type is an enumerated value that indicates the following: 0 - Standard (rgb = normal/binormal/tangent) 1 - DXN (rg = normal.xy need to calculate z) 2 - DXT5 (ag = normal.xy need to calculate z) */ void CalculateNormalFromColor(float4 NormalMap, float3 WorldNormalIn, float3 WorldBinormalIn, float3 WorldTangentIn, int NormalMapType, out float3 WorldNormalOut) { NormalMap = NormalMap * 2.0 - 1.0; // Do nothing extra for Standard // Handle compressed types: if (NormalMapType == 1) // DXN { NormalMap.rgb = float3(NormalMap.r, NormalMap.g, sqrt(1 - NormalMap.r * NormalMap.r - NormalMap.g * NormalMap.g)); } else if (NormalMapType == 2) // DXT5 { NormalMap.rg = NormalMap.ag; NormalMap.b = sqrt(1 - NormalMap.r*NormalMap.r - NormalMap.g * NormalMap.g); } float3x3 xForm = float3x3(WorldTangentIn, WorldBinormalIn, WorldNormalIn); xForm = transpose(xForm); WorldNormalOut = mul(xForm, NormalMap.rgb); WorldNormalOut = normalize(WorldNormalOut); } //--------------------------------------------------------------------------- /* This fragment is responsible for computing the final RGB color. */ void CompositeFinalRGBColor(float3 DiffuseColor, float3 SpecularColor, out float3 OutputColor) { OutputColor.rgb = DiffuseColor.rgb + SpecularColor.rgb; } //--------------------------------------------------------------------------- /* This fragment is responsible for multiplying two floats. */ void MultiplyFloat(float V1, float V2, out float Output) { Output = V1 * V2; } //--------------------------------------------------------------------------- /* This fragment is responsible for applying the fog based on the calculations in the vertex shader. */ void ApplyFog(float3 UnfoggedColor, float3 FogColor, float FogAmount, out float3 FoggedColor) { FoggedColor = lerp(FogColor, UnfoggedColor, FogAmount); } //--------------------------------------------------------------------------- /* This fragment is responsible for computing the final RGBA color. */ void CompositeFinalRGBAColor(float3 FinalColor, float FinalOpacity, out float4 OutputColor) { OutputColor.rgb = FinalColor.rgb; OutputColor.a = FinalOpacity; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Input: //--------------------------------------------------------------------------- struct Input { float4 PosProjected : POSITION0; float3 WorldNormal : TEXCOORD0; float3 WorldBinormal : TEXCOORD1; float3 WorldTangent : TEXCOORD2; float4 DiffuseAccum : TEXCOORD3; float3 SpecularAccum : TEXCOORD4; float2 UVSet0 : TEXCOORD5; float DepthPassThrough : TEXCOORD6; float FogDepth : FOG0; }; //--------------------------------------------------------------------------- // Output: //--------------------------------------------------------------------------- struct Output { float4 Color0 : COLOR0; }; //--------------------------------------------------------------------------- // Main(): //--------------------------------------------------------------------------- Output Main(Input In) { Output Out; // Function call #0 float3 VectorOut_CallOut0; NormalizeFloat3(In.WorldNormal, VectorOut_CallOut0); // Function call #1 float3 VectorOut_CallOut1; NormalizeFloat3(In.WorldTangent, VectorOut_CallOut1); // Function call #2 float3 VectorOut_CallOut2; NormalizeFloat3(In.WorldBinormal, VectorOut_CallOut2); // Function call #3 float4 ColorOut_CallOut3; TextureRGBASample(In.UVSet0, Normal, bool(false), ColorOut_CallOut3); // Function call #4 float4 ColorOut_CallOut4; TextureRGBASample(In.UVSet0, Base, bool(false), ColorOut_CallOut4); // Function call #5 float3 ColorOut_CallOut5; TextureRGBSample(In.UVSet0, Gloss, bool(false), ColorOut_CallOut5); // Function call #6 float3 Output_CallOut6; MultiplyFloat3(In.SpecularAccum, ColorOut_CallOut5, Output_CallOut6); // Function call #7 float3 Color_CallOut7; float Opacity_CallOut7; SplitColorAndOpacity(In.DiffuseAccum, Color_CallOut7, Opacity_CallOut7); // Function call #8 float3 Color_CallOut8; float Opacity_CallOut8; SplitColorAndOpacity(ColorOut_CallOut4, Color_CallOut8, Opacity_CallOut8); // Function call #9 float3 Output_CallOut9; MultiplyFloat3(Color_CallOut7, Color_CallOut8, Output_CallOut9); // Function call #10 float3 WorldNormalOut_CallOut10; CalculateNormalFromColor(ColorOut_CallOut3, VectorOut_CallOut0, VectorOut_CallOut2, VectorOut_CallOut1, int(2), WorldNormalOut_CallOut10); // Function call #11 float3 OutputColor_CallOut11; CompositeFinalRGBColor(Output_CallOut9, Output_CallOut6, OutputColor_CallOut11); // Function call #12 float Output_CallOut12; MultiplyFloat(Opacity_CallOut7, Opacity_CallOut8, Output_CallOut12); // Function call #13 float3 FoggedColor_CallOut13; ApplyFog(OutputColor_CallOut11, g_FogColor, In.FogDepth, FoggedColor_CallOut13); // Function call #14 CompositeFinalRGBAColor(FoggedColor_CallOut13, In.DepthPassThrough, Out.Color0); return Out; }