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.

105 lines
2.8 KiB

  1. #include "macros.vsh"
  2. ;------------------------------------------------------------------------------
  3. ; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform + envmap mask transform
  4. ; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Detail texture transform
  5. ;------------------------------------------------------------------------------
  6. sub ShatteredGlass
  7. {
  8. local( $detail ) = shift;
  9. local( $envmap ) = shift;
  10. local( $envmapcameraspace ) = shift;
  11. local( $envmapsphere ) = shift;
  12. local( $vertexcolor ) = shift;
  13. local( $worldPos, $worldNormal, $projPos, $reflectionVector );
  14. &AllocateRegister( \$projPos );
  15. dp4 $projPos.x, $vPos, $cModelViewProj0
  16. dp4 $projPos.y, $vPos, $cModelViewProj1
  17. dp4 $projPos.z, $vPos, $cModelViewProj2
  18. dp4 $projPos.w, $vPos, $cModelViewProj3
  19. mov oPos, $projPos
  20. &AllocateRegister( \$worldPos );
  21. if( $DOWATERFOG == 1 )
  22. {
  23. ; Get the worldpos z component only since that's all we need for height fog
  24. dp4 $worldPos.z, $vPos, $cModel2
  25. }
  26. &CalcFog( $worldPos, $projPos );
  27. &FreeRegister( \$projPos );
  28. ;------------------------------------------------------------------------------
  29. ; Texture coordinates
  30. ;------------------------------------------------------------------------------
  31. ; base texcoords
  32. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  33. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
  34. ; lightmap texcoords
  35. mov oT1, $vTexCoord1
  36. if( $envmap )
  37. {
  38. &AllocateRegister( \$worldNormal );
  39. ; Transform the position + normal to world space
  40. dp4 $worldPos.x, $vPos, $cModel0
  41. dp4 $worldPos.y, $vPos, $cModel1
  42. if( $DOWATERFOG == 0 )
  43. {
  44. dp4 $worldPos.z, $vPos, $cModel2
  45. }
  46. dp3 $worldNormal.x, $vNormal, $cModel0
  47. dp3 $worldNormal.y, $vNormal, $cModel1
  48. dp3 $worldNormal.z, $vNormal, $cModel2
  49. if( $envmapcameraspace )
  50. {
  51. &AllocateRegister( \$reflectionVector );
  52. &ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
  53. ; transform reflection vector into view space
  54. dp3 oT2.x, $reflectionVector, $cViewModel0
  55. dp3 oT2.y, $reflectionVector, $cViewModel1
  56. dp3 oT2.z, $reflectionVector, $cViewModel2
  57. &FreeRegister( \$reflectionVector );
  58. }
  59. elsif( $envmapsphere )
  60. {
  61. &AllocateRegister( \$reflectionVector );
  62. &ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
  63. &ComputeSphereMapTexCoords( $reflectionVector, "oT2" );
  64. &FreeRegister( \$reflectionVector );
  65. }
  66. else
  67. {
  68. &ComputeReflectionVector( $worldPos, $worldNormal, "oT2" );
  69. }
  70. &FreeRegister( \$worldNormal );
  71. }
  72. &FreeRegister( \$worldPos );
  73. if( $detail )
  74. {
  75. dp4 oT3.x, $vTexCoord2, $SHADER_SPECIFIC_CONST_2
  76. dp4 oT3.y, $vTexCoord2, $SHADER_SPECIFIC_CONST_3
  77. }
  78. if( $vertexcolor )
  79. {
  80. ; Modulation color
  81. mul oD0, $vColor, $cModulationColor
  82. }
  83. else
  84. {
  85. ; Modulation color
  86. mov oD0, $cModulationColor
  87. }
  88. }