Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.9 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. ;------------------------------------------------------------------------------
  4. ; Shader specific constant:
  5. ; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
  6. ;------------------------------------------------------------------------------
  7. #include "macros.vsh"
  8. ;------------------------------------------------------------------------------
  9. ; Vertex blending
  10. ;------------------------------------------------------------------------------
  11. &AllocateRegister( \$worldPos );
  12. ; Transform position from object to world
  13. dp4 $worldPos.x, $vPos, $cModel0
  14. dp4 $worldPos.y, $vPos, $cModel1
  15. dp4 $worldPos.z, $vPos, $cModel2
  16. &AllocateRegister( \$projPos );
  17. ; Transform position from object to projection space
  18. dp4 $projPos.x, $vPos, $cModelViewProj0
  19. dp4 $projPos.y, $vPos, $cModelViewProj1
  20. dp4 $projPos.z, $vPos, $cModelViewProj2
  21. dp4 $projPos.w, $vPos, $cModelViewProj3
  22. mov oPos, $projPos
  23. ;------------------------------------------------------------------------------
  24. ; Fog
  25. ;------------------------------------------------------------------------------
  26. &CalcFog( $worldPos, $projPos );
  27. &FreeRegister( \$projPos );
  28. ;------------------------------------------------------------------------------
  29. ; Lighting
  30. ;------------------------------------------------------------------------------
  31. ; Transform tangent space basis vectors to env map space (world space)
  32. ; This will produce a set of vectors mapping from tangent space to env space
  33. ; We'll use this to transform normals from the normal map from tangent space
  34. ; to environment map space.
  35. ; NOTE: use dp3 here since the basis vectors are vectors, not points
  36. dp3 oT1.x, $vTangentS, $cModel0
  37. dp3 oT2.x, $vTangentS, $cModel1
  38. dp3 oT3.x, $vTangentS, $cModel2
  39. dp3 oT1.y, $vTangentT, $cModel0
  40. dp3 oT2.y, $vTangentT, $cModel1
  41. dp3 oT3.y, $vTangentT, $cModel2
  42. dp3 oT1.z, $vNormal, $cModel0
  43. dp3 oT2.z, $vNormal, $cModel1
  44. dp3 oT3.z, $vNormal, $cModel2
  45. ; Compute the vector from vertex to camera
  46. &AllocateRegister( \$worldEyeVect );
  47. sub $worldEyeVect.xyz, $cEyePos, $worldPos
  48. &FreeRegister( \$worldPos );
  49. ; Move it into the w component of the texture coords, as the wacky
  50. ; pixel shader wants it there.
  51. mov oT1.w, $worldEyeVect.x
  52. mov oT2.w, $worldEyeVect.y
  53. mov oT3.w, $worldEyeVect.z
  54. alloc $tangentEyeVect
  55. ; transform the eye vector to tangent space
  56. dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
  57. dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
  58. dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
  59. &FreeRegister( \$worldEyeVect );
  60. &Normalize( $tangentEyeVect );
  61. ; stick the tangent space eye vector into oD0
  62. mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
  63. &FreeRegister( \$tangentEyeVect );
  64. ;------------------------------------------------------------------------------
  65. ; Texture coordinates
  66. ;------------------------------------------------------------------------------
  67. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  68. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1