#line 2 "D:\RUNTIMES\SXR2\Data\Common\Shaders\Generated\CwStandardMaterial\01000199-00000000-52000000-00000000-V.hlsl" /* Shader description: TRANSFORM = 1 OUTPUTWORLDPOS = 0 OUTPUTWORLDNBT = 1 OUTPUTWORLDVIEW = 1 OUTPUTTANGENTVIEW = 0 NORMAL = 2 SPECULAR = 1 FOGTYPE = 0 ENVMAPTYPE = 0 PROJLIGHTMAPCOUNT = 0 PROJLIGHTMAPTYPES = 0 PROJSHADOWMAPCOUNT = 0 PROJSHADOWMAPTYPES = 0 OUTPUTUVCOUNT = 1 UVSET00 = 0 UVSET00TEXOUTPUT = 0 UVSET01 = 0 UVSET01TEXOUTPUT = 0 UVSET02 = 0 UVSET02TEXOUTPUT = 0 UVSET03 = 0 UVSET03TEXOUTPUT = 0 UVSET04 = 0 UVSET04TEXOUTPUT = 0 UVSET05 = 0 UVSET05TEXOUTPUT = 0 UVSET06 = 0 UVSET06TEXOUTPUT = 0 UVSET07 = 0 UVSET07TEXOUTPUT = 0 UVSET08 = 0 UVSET08TEXOUTPUT = 0 UVSET09 = 0 UVSET09TEXOUTPUT = 0 UVSET10 = 0 UVSET10TEXOUTPUT = 0 UVSET11 = 0 UVSET11TEXOUTPUT = 0 POINTLIGHTCOUNT = 0 SPOTLIGHTCOUNT = 0 DIRLIGHTCOUNT = 0 VERTEXCOLORS = 0 VERTEXLIGHTSONLY = 1 AMBDIFFEMISSIVE = 0 LIGHTINGMODE = 1 APPLYMODE = 1 */ //--------------------------------------------------------------------------- // Constant variables: //--------------------------------------------------------------------------- float4x3 g_BoneMatrix3[30]; float4x4 g_SkinWorld; float4x4 g_ViewProj; float4 g_EyePos; float4 g_MaterialSpecular; float4 g_MaterialPower; float4 g_MaterialEmissive; float4 g_MaterialDiffuse; float4 g_MaterialAmbient; float4 g_AmbientLight; //--------------------------------------------------------------------------- // Functions: //--------------------------------------------------------------------------- /* This fragment is responsible for applying the view projection and skinning transform to the input position. Additionally, this fragment applies the computed world transform to the input position. The weighted world transform defined by the blendweights is output for use in normals or other calculations as the new world matrix. */ void TransformSkinnedPosition(float3 Position, int4 BlendIndices, float4 BlendWeights, float4x3 Bones[30], float4x4 SkinToWorldTransform, out float4 WorldPos, out float4x4 SkinBoneTransform) { // TransformSkinnedPosition ********************************************* // Transform the skinned position into world space // Composite the skinning transform which will take the vertex // and normal to world space. float fWeight3 = 1.0 - BlendWeights[0] - BlendWeights[1] - BlendWeights[2]; float4x3 ShortSkinBoneTransform; ShortSkinBoneTransform = Bones[BlendIndices[0]] * BlendWeights[0]; ShortSkinBoneTransform += Bones[BlendIndices[1]] * BlendWeights[1]; ShortSkinBoneTransform += Bones[BlendIndices[2]] * BlendWeights[2]; ShortSkinBoneTransform += Bones[BlendIndices[3]] * fWeight3; SkinBoneTransform = float4x4(ShortSkinBoneTransform[0], 0.0f, ShortSkinBoneTransform[1], 0.0f, ShortSkinBoneTransform[2], 0.0f, ShortSkinBoneTransform[3], 1.0f); // Transform into world space. WorldPos.xyz = mul(float4(Position, 1.0), ShortSkinBoneTransform); WorldPos = mul(float4(WorldPos.xyz, 1.0), SkinToWorldTransform); } //--------------------------------------------------------------------------- /* This fragment is responsible for applying the view projection transform to the input world position. */ void ProjectPositionWorldToProj(float4 WorldPosition, float4x4 ViewProjection, out float4 ProjPos) { ProjPos = mul(WorldPosition, ViewProjection); } //--------------------------------------------------------------------------- /* 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 computing the coefficients for the following equations: Kdiffuse = MatEmissive + MatAmbient * Summation(0...N){LightAmbientContribution[N]} + MatDiffuse * Summation(0..N){LightDiffuseContribution[N]} Kspecular = MatSpecular * Summation(0..N){LightSpecularContribution[N]} */ void ComputeShadingCoefficients(float3 MatEmissive, float3 MatDiffuse, float3 MatAmbient, float3 MatSpecular, float3 LightSpecularAccum, float3 LightDiffuseAccum, float3 LightAmbientAccum, bool Saturate, out float3 Diffuse, out float3 Specular) { Diffuse = MatEmissive + MatAmbient * LightAmbientAccum + MatDiffuse * LightDiffuseAccum; Specular = MatSpecular * LightSpecularAccum; if (Saturate) { Diffuse = saturate(Diffuse); Specular = saturate(Specular); } } //--------------------------------------------------------------------------- /* This fragment is responsible for applying the world transform to the normal, binormal, and tangent. */ void TransformNBT(float3 Normal, float3 Binormal, float3 Tangent, float4x4 World, out float3 WorldNrm, out float3 WorldBinormal, out float3 WorldTangent) { // Transform the normal into world space for lighting WorldNrm = mul( Normal, (float3x3)World ); WorldBinormal = mul( Binormal, (float3x3)World ); WorldTangent = mul( Tangent, (float3x3)World ); // Should not need to normalize here since we will normalize in the pixel // shader due to linear interpolation across triangle not preserving // normality. } //--------------------------------------------------------------------------- /* This fragment is responsible for normalizing a float3. */ void NormalizeFloat3(float3 VectorIn, out float3 VectorOut) { VectorOut = normalize(VectorIn); } //--------------------------------------------------------------------------- /* 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); } //--------------------------------------------------------------------------- /* This fragment is responsible for calculating the camera view vector. */ void CalculateViewVector(float4 WorldPos, float3 CameraPos, out float3 WorldViewVector) { WorldViewVector = CameraPos - WorldPos; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Input: //--------------------------------------------------------------------------- struct Input { float3 Position : POSITION0; float4 BlendWeights : BLENDWEIGHT0; int4 BlendIndices : BLENDINDICES0; float3 Normal : NORMAL0; float2 UVSet0 : TEXCOORD0; float3 Tangent : TANGENT0; float3 Binormal : BINORMAL0; }; //--------------------------------------------------------------------------- // Output: //--------------------------------------------------------------------------- struct Output { float4 PosProjected : POSITION0; float3 WorldNormal : TEXCOORD0; float3 WorldBinormal : TEXCOORD1; float3 WorldTangent : TEXCOORD2; float3 WorldView : TEXCOORD3; float4 DiffuseAccum : TEXCOORD4; float3 SpecularAccum : TEXCOORD5; float2 UVSet0 : TEXCOORD6; }; //--------------------------------------------------------------------------- // Main(): //--------------------------------------------------------------------------- Output Main(Input In) { Output Out; // Function call #0 float4 WorldPos_CallOut0; float4x4 SkinBoneTransform_CallOut0; TransformSkinnedPosition(In.Position, In.BlendIndices, In.BlendWeights, g_BoneMatrix3, g_SkinWorld, WorldPos_CallOut0, SkinBoneTransform_CallOut0); // Function call #1 ProjectPositionWorldToProj(WorldPos_CallOut0, g_ViewProj, Out.PosProjected); // Function call #2 float3 Color_CallOut2; float Opacity_CallOut2; SplitColorAndOpacity(g_MaterialDiffuse, Color_CallOut2, Opacity_CallOut2); // Function call #3 float3 Diffuse_CallOut3; ComputeShadingCoefficients(g_MaterialEmissive, Color_CallOut2, g_MaterialAmbient, g_MaterialSpecular, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), g_AmbientLight, bool(false), Diffuse_CallOut3, Out.SpecularAccum); // Function call #4 TransformNBT(In.Normal, In.Binormal, In.Tangent, SkinBoneTransform_CallOut0, Out.WorldNormal, Out.WorldBinormal, Out.WorldTangent); // Function call #5 float3 VectorOut_CallOut5; NormalizeFloat3(Out.WorldNormal, VectorOut_CallOut5); // Function call #6 CompositeFinalRGBAColor(Diffuse_CallOut3, Opacity_CallOut2, Out.DiffuseAccum); // Function call #7 CalculateViewVector(WorldPos_CallOut0, g_EyePos, Out.WorldView); Out.UVSet0 = In.UVSet0; // Function call #8 float3 VectorOut_CallOut8; NormalizeFloat3(Out.WorldView, VectorOut_CallOut8); return Out; }