vs_2_0 dcl_position v0 dcl_normal v1 dcl_texcoord0 v3 dcl_texcoord6 v14 dcl_texcoord7 v15 dcl_tangent v7 dcl_binormal v8 dcl_texcoord4 v9 #include "../../VertexShader.h" ;------------------------------------------------------------------------------ ; Geometry transform ;------------------------------------------------------------------------------ ; Calculate bone indices mad r7, vIndices, c23.x, c23.y ; Initialize w-coordinate mov r0.w, C_ONE ; Calculate the second bone weight from the first sub r8.x, C_ONE, vWeights.x ; Skin position by bone 0 MOVA a0.x, r7.x m4x3 r0.xyz, vPos, c[a0.x] mul pPos, r0, vWeights.x ; Skin position by bone 1 MOVA a0.x, r7.y m4x3 r0.xyz, vPos, c[a0.x] mad pPos, r0, r8.x, pPos ; Skin normal by bone 0 MOVA a0.x, r7.x m3x3 pNormal.xyz, vNormal, c[a0.x] NormalizeVector(pNormal) ; Skin basis u by bone 0 m3x3 pBasisU.xyz, vBasisU, c[a0.x] NormalizeVector(pBasisU) ; Skin basis v by bone 0 m3x3 pBasisV.xyz, vBasisV, c[a0.x] NormalizeVector(pBasisV) ; Transform skinned position to projection space m4x4 OPOS, pPos, C_PROJECTION_MATRIX FIXUP_OPOS #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Diffuse color ;------------------------------------------------------------------------------ ; Initialize diffuse light mov rFinalDiffuse, C_AMBIENT_DIFFUSE ; Add diffuse point lights AddDiffusePointLight(C_LIGHT_POSITION_1, C_LIGHT_COLOR_1, C_LIGHT_ATTEN_1, rFinalDiffuse) AddDiffusePointLight(C_LIGHT_POSITION_2, C_LIGHT_COLOR_2, C_LIGHT_ATTEN_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 ;------------------------------------------------------------------------------ #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Defines ;------------------------------------------------------------------------------ #define C_LIGHT_POSITION c10 #define C_LIGHT_ATTEN c11 #define C_LIGHT_DIRECTION c12 #define C_LIGHT_CONE c13 ;------------------------------------------------------------------------------ ; Texture coordinates ;------------------------------------------------------------------------------ ; Base texture is the normal map mul oT0.xy, vTexCoords, C_TEXCOORD_DECOMPRESS ; Transform L vector into texture space and store as a texture stage add rVertexToLight, C_LIGHT_POSITION, -pPos dp3 oT1.x, rVertexToLight, pBasisU dp3 oT1.y, rVertexToLight, pBasisV dp3 oT1.z, rVertexToLight, pNormal ; Store per-vertex light attenuation in diffuse alpha dp3 rTemp.w, rVertexToLight, rVertexToLight /* Calc light vector */ rsq rVertexToLight.w, rTemp.w dst rTemp, rTemp.wwww, rVertexToLight.wwww /* Calc attenuation */ dp3 rTemp.w, rTemp, C_LIGHT_ATTEN rcp rLightCoeff.x, rTemp.w mul rVertexToLight.xyz, rVertexToLight, rVertexToLight.w /* Normalize light vector */ dp3 rTemp.w, rVertexToLight, -C_LIGHT_DIRECTION /* Scale by spotlight cone */ mad rTemp.w, rTemp.w, C_LIGHT_CONE.x, C_LIGHT_CONE.y mul oD0.a, rLightCoeff.x, rTemp.w