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.

92 lines
2.8 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. ;------------------------------------------------------------------------------
  4. ; Shader specific constant:
  5. ; $SHADER_SPECIFIC_CONST_5 = [sOffset, tOffset, 0, 0]
  6. ;------------------------------------------------------------------------------
  7. #include "macros.vsh"
  8. ;------------------------------------------------------------------------------
  9. ; Vertex blending
  10. ;------------------------------------------------------------------------------
  11. &AllocateRegister( \$worldPos );
  12. ; Transform position from object to world
  13. dp4 $worldPos.x, $vPos, $cModel0
  14. dp4 $worldPos.y, $vPos, $cModel1
  15. dp4 $worldPos.z, $vPos, $cModel2
  16. &AllocateRegister( \$projPos );
  17. ; Transform position from object to projection space
  18. dp4 $projPos.x, $vPos, $cModelViewProj0
  19. dp4 $projPos.y, $vPos, $cModelViewProj1
  20. dp4 $projPos.z, $vPos, $cModelViewProj2
  21. dp4 $projPos.w, $vPos, $cModelViewProj3
  22. mov oPos, $projPos
  23. ;------------------------------------------------------------------------------
  24. ; Fog
  25. ;------------------------------------------------------------------------------
  26. &CalcFog( $worldPos, $projPos );
  27. &FreeRegister( \$projPos );
  28. ;------------------------------------------------------------------------------
  29. ; Lighting
  30. ;------------------------------------------------------------------------------
  31. ; Transform tangent space basis vectors to env map space (world space)
  32. ; This will produce a set of vectors mapping from tangent space to env space
  33. ; We'll use this to transform normals from the normal map from tangent space
  34. ; to environment map space.
  35. ; NOTE: use dp3 here since the basis vectors are vectors, not points
  36. dp3 oT1.x, $vTangentS, $cModel0
  37. dp3 oT2.x, $vTangentS, $cModel1
  38. dp3 oT3.x, $vTangentS, $cModel2
  39. dp3 oT1.y, $vTangentT, $cModel0
  40. dp3 oT2.y, $vTangentT, $cModel1
  41. dp3 oT3.y, $vTangentT, $cModel2
  42. dp3 oT1.z, $vNormal, $cModel0
  43. dp3 oT2.z, $vNormal, $cModel1
  44. dp3 oT3.z, $vNormal, $cModel2
  45. ; Compute the vector from vertex to camera
  46. &AllocateRegister( \$worldEyeVect );
  47. sub $worldEyeVect.xyz, $cEyePos, $worldPos
  48. &FreeRegister( \$worldPos );
  49. ; eye vector
  50. mov oT4.xyz, $worldEyeVect
  51. alloc $tangentEyeVect
  52. ; transform the eye vector to tangent space
  53. dp3 $tangentEyeVect.x, $worldEyeVect, $vTangentS
  54. dp3 $tangentEyeVect.y, $worldEyeVect, $vTangentT
  55. dp3 $tangentEyeVect.z, $worldEyeVect, $vNormal
  56. &FreeRegister( \$worldEyeVect );
  57. &Normalize( $tangentEyeVect );
  58. ; stick the tangent space eye vector into oD0
  59. mad oD0.xyz, $tangentEyeVect, $cHalf, $cHalf
  60. &FreeRegister( \$tangentEyeVect );
  61. ;------------------------------------------------------------------------------
  62. ; Texture coordinates
  63. ;------------------------------------------------------------------------------
  64. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  65. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1