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.

96 lines
2.9 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. ; eye vector
  46. mov oT4.xyz, $worldEyeVect
  47. alloc $tangentEyeVect
  48. ; transform the eye vector to tangent space
  49. dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
  50. dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
  51. dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
  52. ; Get the magnitude of worldEyeVect
  53. dp3 $worldEyeVect.w, $worldEyeVect, $worldEyeVect
  54. rsq $worldEyeVect.w, $worldEyeVect.w
  55. rcp $worldEyeVect.w, $worldEyeVect.w
  56. ; calculate the cheap water blend factor and stick it into oD0.a
  57. ; NOTE: This won't be perspective correct!!!!!
  58. ; OPTIMIZE: This could turn into a mad.
  59. add $worldEyeVect.w, $worldEyeVect.w, -$SHADER_SPECIFIC_CONST_2.x
  60. mul oD0, $worldEyeVect.w, $SHADER_SPECIFIC_CONST_2.y
  61. ; stick the tangent space eye vector into oT5.xyz
  62. mov oT5.xyz, $tangentEyeVect
  63. &FreeRegister( \$worldEyeVect );
  64. &FreeRegister( \$tangentEyeVect );
  65. ;------------------------------------------------------------------------------
  66. ; Texture coordinates
  67. ;------------------------------------------------------------------------------
  68. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  69. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1