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.

100 lines
3.0 KiB

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