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.

94 lines
2.5 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. ;------------------------------------------------------------------------------
  4. ; Constants specified by the app
  5. ; c0 = (0, 1, 2, 0.5)
  6. ; c1 = (1/2.2, 0, 0, 0)
  7. ; c2 = camera position *in world space*
  8. ; c4-c7 = modelViewProj matrix (transpose)
  9. ; c8-c11 = ViewProj matrix (transpose)
  10. ; c12-c15 = model->view matrix (transpose)
  11. ; c16 = [fogStart, fogEnd, fogRange, undefined]
  12. ;
  13. ; $SHADER_SPECIFIC_CONST_0..$SHADER_SPECIFIC_CONST_3 - special proj matrix
  14. ;
  15. ; Vertex components (as specified in the vertex DECL)
  16. ; $vPos = Position
  17. ; $vTexCoord0.xy = TexCoord0
  18. ;------------------------------------------------------------------------------
  19. #include "macros.vsh"
  20. ; Vertex components
  21. ; $vPos = Position
  22. ; $vNormal = normal
  23. ; $vTexCoord0.xy = TexCoord0
  24. ; $vTangentS = S axis of Texture space
  25. ; $vTangentT = T axis of Texture space
  26. ;------------------------------------------------------------------------------
  27. ; Transform the position from world to view space
  28. ;------------------------------------------------------------------------------
  29. alloc $projPos
  30. ; Transform position from object to projection space
  31. dp4 $projPos.x, $vPos, $cModelViewProj0
  32. dp4 $projPos.y, $vPos, $cModelViewProj1
  33. dp4 $projPos.z, $vPos, $cModelViewProj2
  34. dp4 $projPos.w, $vPos, $cModelViewProj3
  35. mov oPos, $projPos
  36. alloc $worldPos
  37. ; Transform position from object to world space
  38. dp4 $worldPos.x, $vPos, $cModel0
  39. dp4 $worldPos.y, $vPos, $cModel1
  40. dp4 $worldPos.z, $vPos, $cModel2
  41. &CalcFog( $worldPos, $projPos );
  42. alloc $worldEyeVect
  43. ; Get the eye vector in world space
  44. add $worldEyeVect.xyz, -$worldPos, $cEyePos
  45. alloc $tangentEyeVect
  46. ; transform the eye vector to tangent space
  47. dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
  48. dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
  49. dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
  50. mov $tangentEyeVect.w, $cZero
  51. mov oT5, $tangentEyeVect
  52. ; base coordinates
  53. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
  54. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_2
  55. ; reflection
  56. alloc $projPosReflect
  57. mov $projPosReflect, $projPos
  58. add $projPosReflect.xy, $projPosReflect, $projPosReflect.w
  59. mul $projPosReflect.xy, $projPosReflect, $cHalf
  60. mov oT1, $projPosReflect
  61. ; refraction
  62. mov $projPos.y, -$projPos.y
  63. add $projPos.xy, $projPos, $projPos.w
  64. mul $projPos.xy, $projPos, $cHalf
  65. mov oT2, $projPos
  66. ; reflectionscale, refractionscale
  67. mov oT4, $SHADER_SPECIFIC_CONST_4
  68. free $worldEyeVect
  69. free $tangentEyeVect
  70. free $projPosReflect
  71. free $worldPos
  72. free $projPos