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" ;------------------------------------------------------------------------------ ; Defines ;------------------------------------------------------------------------------ #define C_EYE_POSITION c10 #define C_LIGHT_POSITION c11 #define C_LIGHT_ATTEN c12 #define C_HALF c13 ;------------------------------------------------------------------------------ ; Diffuse color ;------------------------------------------------------------------------------ ; Calculate normalized light vector add rVertexToLight, C_LIGHT_POSITION, -pPos NormalizeVector(rVertexToLight) ; Calculate attenuation factor dst rTemp, rTemp.wwww, rVertexToLight.wwww dp3 rTemp.w, rTemp, C_LIGHT_ATTEN rcp rAtten.w, rTemp.w ; Calculate normalized eye vector add rVertexToEye, C_EYE_POSITION, -pPos NormalizeVector(rVertexToEye) ; Calculate normalized half vector add rHalfVector, rVertexToEye, rVertexToLight NormalizeVector(rHalfVector) ; Calculate self-shadowing term dp3 rTemp, pNormal, rHalfVector sge rTemp, rTemp, C_ZERO ; Store attenuated material color in diffuse channel mov oD0.xyz, C_MATERIAL_COLOR mul oD0.w, rAtten.w, rTemp.w ; Transform H vector into texture space and store in the specular channel dp3 rTemp.x, rHalfVector, pBasisU dp3 rTemp.y, rHalfVector, pBasisV dp3 rTemp.z, rHalfVector, pNormal mad oD1.xyz, rTemp, C_HALF, C_HALF #ifdef _PCBUILD mov oD1.w, C_ONE #endif #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Fog calculation ;------------------------------------------------------------------------------ #include "..\..\VertexShader.h" ;------------------------------------------------------------------------------ ; Defines ;------------------------------------------------------------------------------ #define C_EYE_POSITION c10 #define C_LIGHT_POSITION c11 #define C_LIGHT_ATTEN c12 ;------------------------------------------------------------------------------ ; Texture coordinates ;------------------------------------------------------------------------------ ; Base texture is the normal map mul oT0.xy, vTexCoords, C_TEXCOORD_DECOMPRESS ; Copy gloss map coords mul oT1.xy, vTexCoords, C_TEXCOORD_DECOMPRESS