vs_2_0 dcl_position v0 dcl_normal v1 dcl_texcoord0 v3 dcl_tangent v7 dcl_binormal v8 dcl_texcoord4 v9 #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Geometry transform ;------------------------------------------------------------------------------ ; Copy model-space geometry to pipeline registers mov pPos, vPos mov pNormal, vNormal ; Copy model-space basis vectors to pipeline registers mov pBasisU, vBasisU mov pBasisV, vBasisV ; Transform position to projection space m4x4 OPOS, vPos, C_PROJECTION_MATRIX FIXUP_OPOS #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Diffuse color ;------------------------------------------------------------------------------ ; Initialize diffuse light mov rFinalDiffuse, C_AMBIENT_DIFFUSE ; Add diffuse spot and point lights AddDiffuseSpotLight(C_LIGHT_POSITION_1, C_LIGHT_COLOR_1, C_LIGHT_ATTEN_1, C_LIGHT_DIRECTION_1, C_LIGHT_CONE_1, rFinalDiffuse) AddDiffuseSpotLight(C_LIGHT_POSITION_2, C_LIGHT_COLOR_2, C_LIGHT_ATTEN_2, C_LIGHT_DIRECTION_2, C_LIGHT_CONE_2, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_3, C_LIGHT_COLOR_3, C_LIGHT_ATTEN_3, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_4, C_LIGHT_COLOR_4, C_LIGHT_ATTEN_4, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_5, C_LIGHT_COLOR_5, C_LIGHT_ATTEN_5, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_6, C_LIGHT_COLOR_6, C_LIGHT_ATTEN_6, rFinalDiffuse) #if defined(_XBOX) || defined(_VS_2_0) AddDiffusePointLight(C_LIGHT_POSITION_7, C_LIGHT_COLOR_7, C_LIGHT_ATTEN_7, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_8, C_LIGHT_COLOR_8, C_LIGHT_ATTEN_8, rFinalDiffuse) #endif ; Combine final diffuse light and material color mul oD0, rFinalDiffuse, C_MATERIAL_COLOR #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Fog calculation ;------------------------------------------------------------------------------ ; Calculate fog factor and copy to fog register CalculateLayeredFog(pPos, oFog) #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Defines ;------------------------------------------------------------------------------ #define C_LIGHT_POSITION c10 #define C_INVERSE_RADIUS c11 #define C_HALF c12 ;------------------------------------------------------------------------------ ; Texture coordinates ;------------------------------------------------------------------------------ ; Calculate the vertex-to-light vector add rVertexToLight, C_LIGHT_POSITION, -pPos ; For light attenuation, store scaled and biased vertex-to-light vector in texture stages mul rTemp, rVertexToLight, C_INVERSE_RADIUS mad oT0.xy, rTemp.xy, C_HALF, C_HALF mad oT1.x, rTemp.z, C_HALF, C_HALF mov oT1.y, C_HALF ; Transform L vector into texture space and store as a texture stage dp3 oT2.x, rVertexToLight, pBasisU dp3 oT2.y, rVertexToLight, pBasisV dp3 oT2.z, rVertexToLight, pNormal ; Last texture stage is the normal map mul oT3.xy, vTexCoords, C_TEXCOORD_DECOMPRESS