#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