home *** CD-ROM | disk | FTP | other *** search
/ NVIDIA Tech Demo: DAWN / NVIDIA_demo.iso / Dawn.exe / Disk1 / data1.cab / Program_Executable_Files / shaders_ultra / eye_outerb1bv1.vp30 < prev    next >
Encoding:
Text File  |  2003-02-11  |  1.7 KB  |  53 lines

  1. // v2fConnector.HPOS is set to be the homogenous space coordinate
  2. // v2f.diffCol is set to be the texture coordinate
  3. // v2f.worldEyeDir is set to be the eye direction (from eye) in world space
  4. // v2f.worldNormal is set to be the normal in world space
  5. // InverseTransposes not used, as we assume no nonuniform scales.
  6.  
  7.  
  8. // vecMul(matrix, float3) multiplies like a vector instead of point (no translate)
  9. float3 vecMul(const float4x4 matrix, const float3 vec){
  10.     return(float3(dot(vec, matrix._11_12_13),
  11.                   dot(vec, matrix._21_22_23),
  12.                   dot(vec, matrix._31_32_33)));
  13. }
  14.  
  15. struct a2vConnector : application2vertex {
  16.     float4 coord;
  17.     float3 normal;
  18.     float boneWeight0;
  19.     float boneIndex0;
  20.     float2 diffCol;
  21. };
  22.  
  23. struct v2fConnector : vertex2fragment {
  24.   float4 HPOS        :HPOS;
  25.     float2 diffCol    :TEX0;
  26.     float3 worldEyeDir    :TEX1;
  27.     float3 worldNormal    :TEX2;
  28. };
  29.  
  30. v2fConnector main(a2vConnector a2v,
  31.                   const uniform float4x4 model[1],
  32.                   const uniform float4 globalCamPos,
  33.                   const uniform float4x4 viewProj){
  34.     v2fConnector v2f;
  35.  
  36.     v2f.diffCol = a2v.diffCol;
  37.  
  38.     float4 objectCoord = a2v.coord;
  39.     float4 worldCoord = a2v.boneWeight0.x * mul(model[a2v.boneIndex0.x], objectCoord);
  40.     float4 worldEyePos = globalCamPos;
  41.     float3 worldEyeDir = normalize(worldCoord.xyz - worldEyePos.xyz);
  42.     v2f.worldEyeDir = worldEyeDir;
  43.  
  44.     float3 objectNormal = a2v.normal;
  45.     float3 worldNormal = a2v.boneWeight0.x * vecMul(model[a2v.boneIndex0.x], objectNormal.xyz);
  46.     worldNormal = normalize(worldNormal);
  47.     v2f.worldNormal = worldNormal;
  48.  
  49.     float4 hpos = mul(viewProj, worldCoord);
  50.     v2f.HPOS = hpos;
  51.  
  52.     return v2f;
  53. }