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.

85 lines
3.6 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. # DYNAMIC: "SKINNING" "0..1"
  4. ;------------------------------------------------------------------------------
  5. ; Constants specified by the app
  6. ; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_2 = Shadow texture matrix
  7. ; $SHADER_SPECIFIC_CONST_3 = Tex origin
  8. ; $SHADER_SPECIFIC_CONST_4 = Tex Scale
  9. ; $SHADER_SPECIFIC_CONST_5 = [Shadow falloff offset, 1/Shadow distance, Shadow scale, 0 ]
  10. ;------------------------------------------------------------------------------
  11. #include "macros.vsh"
  12. ;------------------------------------------------------------------------------
  13. ; Vertex blending (whacks r1-r7, positions in r7, normals in r8)
  14. ;------------------------------------------------------------------------------
  15. &AllocateRegister( \$worldPos );
  16. &AllocateRegister( \$worldNormal );
  17. &SkinPositionAndNormal( $worldPos, $worldNormal );
  18. ; Transform the position from world to view space
  19. &AllocateRegister( \$projPos );
  20. dp4 $projPos.x, $worldPos, $cViewProj0
  21. dp4 $projPos.y, $worldPos, $cViewProj1
  22. dp4 $projPos.z, $worldPos, $cViewProj2
  23. dp4 $projPos.w, $worldPos, $cViewProj3
  24. mov oPos, $projPos
  25. ;------------------------------------------------------------------------------
  26. ; Fog
  27. ;------------------------------------------------------------------------------
  28. &CalcFog( $worldPos, $projPos );
  29. &FreeRegister( \$projPos );
  30. ;------------------------------------------------------------------------------
  31. ; Transform position into texture space (from 0 to 1)
  32. ;------------------------------------------------------------------------------
  33. &AllocateRegister( \$texturePos );
  34. dp4 $texturePos.x, $worldPos, $SHADER_SPECIFIC_CONST_0
  35. dp4 $texturePos.y, $worldPos, $SHADER_SPECIFIC_CONST_1
  36. dp4 $texturePos.z, $worldPos, $SHADER_SPECIFIC_CONST_2
  37. &FreeRegister( \$worldPos );
  38. ;------------------------------------------------------------------------------
  39. ; Figure out the shadow fade amount
  40. ;------------------------------------------------------------------------------
  41. &AllocateRegister( \$shadowFade );
  42. sub $shadowFade, $texturePos.z, $SHADER_SPECIFIC_CONST_5.x
  43. mul $shadowFade, $shadowFade, $SHADER_SPECIFIC_CONST_5.y
  44. ;------------------------------------------------------------------------------
  45. ; Offset it into the texture
  46. ;------------------------------------------------------------------------------
  47. &AllocateRegister( \$actualTextureCoord );
  48. mul $actualTextureCoord.xyz, $SHADER_SPECIFIC_CONST_4, $texturePos
  49. add oT0.xyz, $actualTextureCoord, $SHADER_SPECIFIC_CONST_3
  50. ;mov oT0.xyz, $texturePos
  51. &FreeRegister( \$actualTextureCoord );
  52. ;------------------------------------------------------------------------------
  53. ; We're doing clipping by using texkill
  54. ;------------------------------------------------------------------------------
  55. mov oT1.xyz, $texturePos ; also clips when shadow z < 0 !
  56. sub oT2.xyz, $cOne, $texturePos
  57. sub oT2.z, $cOne, $shadowFade.z ; clips when shadow z > shadow distance
  58. &FreeRegister( \$texturePos );
  59. ;------------------------------------------------------------------------------
  60. ; We're doing backface culling by using texkill also (wow yucky)
  61. ;------------------------------------------------------------------------------
  62. ; Transform z component of normal in texture space
  63. ; If it's negative, then don't draw the pixel
  64. dp3 oT3, $worldNormal, -$SHADER_SPECIFIC_CONST_2
  65. &FreeRegister( \$worldNormal );
  66. ;------------------------------------------------------------------------------
  67. ; Shadow color, falloff
  68. ;------------------------------------------------------------------------------
  69. mov oD0, $cModulationColor
  70. mul oD0.w, $shadowFade.x, $SHADER_SPECIFIC_CONST_5.z
  71. &FreeRegister( \$shadowFade );