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.

83 lines
2.6 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. ;------------------------------------------------------------------------------
  4. ; Shader specific constant:
  5. ; $SHADER_SPECIFIC_CONST_4, $SHADER_SPECIFIC_CONST_5 = normal map transform
  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. ; Lighting
  25. ;------------------------------------------------------------------------------
  26. ; Transform tangent space basis vectors to env map space (world space)
  27. ; This will produce a set of vectors mapping from tangent space to env space
  28. ; We'll use this to transform normals from the normal map from tangent space
  29. ; to environment map space.
  30. ; NOTE: use dp3 here since the basis vectors are vectors, not points
  31. dp3 oT1.x, $vTangentS, $cModel0
  32. dp3 oT2.x, $vTangentS, $cModel1
  33. dp3 oT3.x, $vTangentS, $cModel2
  34. dp3 oT1.y, $vTangentT, $cModel0
  35. dp3 oT2.y, $vTangentT, $cModel1
  36. dp3 oT3.y, $vTangentT, $cModel2
  37. dp3 oT1.z, $vNormal, $cModel0
  38. dp3 oT2.z, $vNormal, $cModel1
  39. dp3 oT3.z, $vNormal, $cModel2
  40. &AllocateRegister( \$worldToEye );
  41. ; Compute the vector from vertex to camera
  42. sub $worldToEye.xyz, $cEyePos, $worldPos
  43. ;------------------------------------------------------------------------------
  44. ; Fog
  45. ;------------------------------------------------------------------------------
  46. &CalcFog( $worldPos, $projPos );
  47. &FreeRegister( \$worldPos );
  48. ; Move it into the w component of the texture coords, as the wacky
  49. ; pixel shader wants it there.
  50. mov oT1.w, $worldToEye.x
  51. mov oT2.w, $worldToEye.y
  52. mov oT3.w, $worldToEye.z
  53. &FreeRegister( \$worldToEye );
  54. ;------------------------------------------------------------------------------
  55. ; Texture coordinates (normal map)
  56. ;------------------------------------------------------------------------------
  57. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_4
  58. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_5
  59. &FreeRegister( \$projPos );