#line 2 "D:\RUNTIMES\SXR2\Data\Common\Shaders\Generated\CwStandardMaterial\05002359-00000800-00000000-10090000-P.hlsl" /* Shader description: APPLYMODE = 1 WORLDPOSITION = 0 WORLDNORMAL = 0 WORLDNBT = 1 WORLDVIEW = 1 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 = 0 ENVMAPTYPE = 5 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 = 0 LIGHTINGMODE = 1 APPLYAMBIENT = 0 BASEMAPALPHAONLY = 0 APPLYEMISSIVE = 0 SHADOWTECHNIQUE = 0 ALPHATEST = 1 */ //--------------------------------------------------------------------------- // Constant variables: //--------------------------------------------------------------------------- sampler2D Normal; sampler2D Base; sampler2D Gloss; float4x4 g_EnvironmentMapWorldProjectionTransform0; samplerCUBE EnvironmentMap; //--------------------------------------------------------------------------- // Functions: //--------------------------------------------------------------------------- /* This fragment is responsible for normalizing a float3. */ void NormalizeFloat3(float3 VectorIn, out float3 VectorOut) { VectorOut = normalize(VectorIn); } //--------------------------------------------------------------------------- /* 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 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; } //--------------------------------------------------------------------------- /* 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 reflection vector. The WorldViewVector is negated because the HLSL "reflect" function expects a world-to-camera vector, rather than a camera-to-world vector. */ void WorldReflect(float3 WorldNrm, float3 WorldViewVector, bool NormalizeNormal, out float3 WorldReflect) { if (NormalizeNormal) WorldNrm = normalize(WorldNrm); WorldReflect = reflect(-WorldViewVector, WorldNrm); } //--------------------------------------------------------------------------- /* 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 a projection to the input set of texture coordinates. */ void ProjectTextureCoordinates(float3 TexCoord, float4x4 TexTransform, out float4 TexCoordOut) { TexCoordOut = mul(float4(TexCoord, 1.0), TexTransform); } //--------------------------------------------------------------------------- /* This fragment is responsible for sampling a texture and returning its value as a RGB value. */ void TextureRGBCubeSample(float3 TexCoord, samplerCUBE Sampler, bool Saturate, out float3 ColorOut) { ColorOut.rgb = texCUBE(Sampler, TexCoord).rgb; if (Saturate) { ColorOut.rgb = saturate(ColorOut.rgb); } } //--------------------------------------------------------------------------- /* This fragment is responsible for adding two float3's. */ void AddFloat3(float3 V1, float3 V2, out float3 Output) { Output = V1 + V2; } //--------------------------------------------------------------------------- /* 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 computing the final RGBA color. */ void CompositeFinalRGBAColor(float3 FinalColor, float FinalOpacity, out float4 OutputColor) { OutputColor.rgb = FinalColor.rgb; OutputColor.a = saturate(FinalOpacity); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Input: //--------------------------------------------------------------------------- struct Input { float4 PosProjected : POSITION0; float3 WorldNormal : TEXCOORD0; float3 WorldBinormal : TEXCOORD1; float3 WorldTangent : TEXCOORD2; float3 WorldView : TEXCOORD3; float4 DiffuseAccum : TEXCOORD4; float3 SpecularAccum : TEXCOORD5; float2 UVSet0 : TEXCOORD6; }; //--------------------------------------------------------------------------- // 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 Color_CallOut2; float Opacity_CallOut2; SplitColorAndOpacity(In.DiffuseAccum, Color_CallOut2, Opacity_CallOut2); // Function call #3 float3 VectorOut_CallOut3; NormalizeFloat3(In.WorldBinormal, VectorOut_CallOut3); // Function call #4 float4 ColorOut_CallOut4; TextureRGBASample(In.UVSet0, Normal, bool(false), ColorOut_CallOut4); // Function call #5 float4 ColorOut_CallOut5; TextureRGBASample(In.UVSet0, Base, bool(false), ColorOut_CallOut5); // Function call #6 float3 ColorOut_CallOut6; TextureRGBSample(In.UVSet0, Gloss, bool(false), ColorOut_CallOut6); // Function call #7 float3 Output_CallOut7; MultiplyFloat3(In.SpecularAccum, ColorOut_CallOut6, Output_CallOut7); // Function call #8 float3 VectorOut_CallOut8; NormalizeFloat3(In.WorldView, VectorOut_CallOut8); // Function call #9 float3 Color_CallOut9; float Opacity_CallOut9; SplitColorAndOpacity(ColorOut_CallOut5, Color_CallOut9, Opacity_CallOut9); // Function call #10 float3 Output_CallOut10; MultiplyFloat3(Color_CallOut2, Color_CallOut9, Output_CallOut10); // Function call #11 float3 WorldNormalOut_CallOut11; CalculateNormalFromColor(ColorOut_CallOut4, VectorOut_CallOut0, VectorOut_CallOut3, VectorOut_CallOut1, int(2), WorldNormalOut_CallOut11); // Function call #12 float3 WorldReflect_CallOut12; WorldReflect(WorldNormalOut_CallOut11, VectorOut_CallOut8, bool(false), WorldReflect_CallOut12); // Function call #13 float Output_CallOut13; MultiplyFloat(Opacity_CallOut2, Opacity_CallOut9, Output_CallOut13); // Function call #14 float4 TexCoordOut_CallOut14; ProjectTextureCoordinates(WorldReflect_CallOut12, g_EnvironmentMapWorldProjectionTransform0, TexCoordOut_CallOut14); // Function call #15 float3 ColorOut_CallOut15; TextureRGBCubeSample(TexCoordOut_CallOut14, EnvironmentMap, bool(false), ColorOut_CallOut15); // Function call #16 float3 Output_CallOut16; MultiplyFloat3(ColorOut_CallOut6, ColorOut_CallOut15, Output_CallOut16); // Function call #17 float3 Output_CallOut17; AddFloat3(Output_CallOut16, Output_CallOut7, Output_CallOut17); // Function call #18 float3 OutputColor_CallOut18; CompositeFinalRGBColor(Output_CallOut10, Output_CallOut17, OutputColor_CallOut18); // Function call #19 CompositeFinalRGBAColor(OutputColor_CallOut18, Output_CallOut13, Out.Color0); return Out; }