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.

105 lines
2.8 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. # DYNAMIC: "SKINNING" "0..1"
  4. ;------------------------------------------------------------------------------
  5. ; Constants specified by the app
  6. ; c0 = (0, 1, 2, 0.5)
  7. ; c1 = (1/2.2, 0, 0, 0)
  8. ; c2 = camera position *in world space*
  9. ; c4-c7 = modelViewProj matrix (transpose)
  10. ; c8-c11 = ViewProj matrix (transpose)
  11. ; c12-c15 = model->view matrix (transpose)
  12. ; c16 = [fogStart, fogEnd, fogRange, undefined]
  13. ;
  14. ; Vertex components (as specified in the vertex DECL)
  15. ; $vPos = Position
  16. ; $vTexCoord0.xy = TexCoord0
  17. ;------------------------------------------------------------------------------
  18. #include "macros.vsh"
  19. ; Vertex components
  20. ; $vPos = Position
  21. ; $vNormal = normal
  22. ; $vTexCoord0.xy = TexCoord0
  23. ; $vTangentS = S axis of Texture space
  24. ; $vTangentT = T axis of Texture space
  25. ;------------------------------------------------------------------------------
  26. ; Transform the position from world to view space
  27. ;------------------------------------------------------------------------------
  28. alloc $worldPos
  29. alloc $worldNormal
  30. alloc $worldTangentS
  31. alloc $worldTangentT
  32. &SkinPositionNormalAndTangentSpace( $worldPos, $worldNormal,
  33. $worldTangentS, $worldTangentT );
  34. alloc $projPos
  35. ; Transform position from world to projection space
  36. dp4 $projPos.x, $worldPos, $cViewProj0
  37. dp4 $projPos.y, $worldPos, $cViewProj1
  38. dp4 $projPos.z, $worldPos, $cViewProj2
  39. dp4 $projPos.w, $worldPos, $cViewProj3
  40. &CalcFog( $worldPos, $projPos );
  41. alloc $worldEyeVect
  42. ; Get the eye vector in world space
  43. add $worldEyeVect.xyz, -$worldPos, $cEyePos
  44. alloc $tangentEyeVect
  45. ; transform the eye vector to tangent space
  46. dp3 oT3.x, $worldEyeVect, $worldTangentS
  47. dp3 oT3.y, $worldEyeVect, $worldTangentT
  48. dp3 oT3.z, $worldEyeVect, $worldNormal
  49. alloc $bumpTexCoord
  50. dp4 $bumpTexCoord.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
  51. dp4 $bumpTexCoord.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
  52. ; dudv map
  53. mov oT0.xy, $bumpTexCoord
  54. ; refract tint + alpha channel
  55. mov oT2.xy, $bumpTexCoord
  56. mov oT3.xy, $bumpTexCoord
  57. free $bumpTexCoord
  58. mov oPos, $projPos
  59. ; special case perspective correct texture projection so that the texture fits exactly on the screen
  60. ; flip Y by multiplying by -1
  61. mul $projPos.y, $projPos.y, $SHADER_SPECIFIC_CONST_4.w
  62. ; transform from [-w,w] to [0,2*w]
  63. ; The reason this is w is because we are in perspective space/homogenous clip space.
  64. add $projPos.xy, $projPos.xy, $projPos.w
  65. ; transform from [0,2*w] to [0,w]
  66. ; We'll end up dividing by w in the pixel shader to get to [0,1]
  67. mul $projPos.xy, $projPos.xy, $cHalf
  68. mov oT1.xy, $projPos.xy
  69. ; emit w to both z and w in case the driver screws up and divides by z
  70. mov oT1.z, $projPos.w
  71. mov oT1.w, $projPos.w
  72. free $projPos
  73. free $worldPos
  74. free $worldEyeVect
  75. free $tangentEyeVect
  76. free $w
  77. free $worldNormal
  78. free $worldTangentS
  79. free $worldTangentT