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.

88 lines
2.7 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. ; Get the magnitude of worldEyeVect
  51. dp3 $worldEyeVect.w, $worldEyeVect, $worldEyeVect
  52. rsq $worldEyeVect.w, $worldEyeVect.w
  53. rcp $worldEyeVect.w, $worldEyeVect.w
  54. ; calculate the cheap water blend factor and stick it into oD0.a
  55. ; NOTE: This won't be perspective correct!!!!!
  56. ; OPTIMIZE: This could turn into a mad.
  57. add $worldEyeVect.w, $worldEyeVect.w, -$SHADER_SPECIFIC_CONST_2.x
  58. mul oD0, $worldEyeVect.w, $SHADER_SPECIFIC_CONST_2.y
  59. &FreeRegister( \$worldEyeVect );
  60. ;------------------------------------------------------------------------------
  61. ; Texture coordinates
  62. ;------------------------------------------------------------------------------
  63. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  64. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1