Counter Strike : Global Offensive Source Code
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.

137 lines
3.5 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. # DYNAMIC: "SKINNING" "0..1"
  4. # STATIC: "TEETH" "0..1"
  5. #include "macros.vsh"
  6. local( $worldPos, $worldNormal, $projPos );
  7. alloc $worldPos
  8. alloc $worldNormal
  9. alloc $projPos
  10. if( 0 )
  11. {
  12. ; NOTE: Don't do this optimization anymore since it would mean a gazillion combos
  13. ; Special case for static prop lighting. We can go directly from
  14. ; world to proj space for position, with the exception of z, which
  15. ; is needed for fogging *if* height fog is enabled.
  16. ; NOTE: We don't use this path if $envmap is defined since we need
  17. ; worldpos for envmapping.
  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. ; normal
  23. dp3 $worldNormal.x, $vNormal, $cModel0
  24. dp3 $worldNormal.y, $vNormal, $cModel1
  25. dp3 $worldNormal.z, $vNormal, $cModel2
  26. ; Need this for height fog if it's enabled and for height clipping
  27. dp4 $worldPos.z, $vPos, $cModel2
  28. }
  29. else
  30. {
  31. &SkinPositionAndNormal( $worldPos, $worldNormal );
  32. if( $SKINNING == 1 )
  33. {
  34. &Normalize( $worldNormal );
  35. }
  36. ;------------------------------------------------------------------------------
  37. ; Transform the position from world to view space
  38. ;------------------------------------------------------------------------------
  39. dp4 $projPos.x, $worldPos, $cViewProj0
  40. dp4 $projPos.y, $worldPos, $cViewProj1
  41. dp4 $projPos.z, $worldPos, $cViewProj2
  42. dp4 $projPos.w, $worldPos, $cViewProj3
  43. }
  44. mov oPos, $projPos
  45. ;------------------------------------------------------------------------------
  46. ; Fog
  47. ;------------------------------------------------------------------------------
  48. &CalcFog( $worldPos, $projPos );
  49. ; base tex coords
  50. dp4 oT1.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_6
  51. dp4 oT1.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_7
  52. ; normal map coords
  53. ;dp4 oT3.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_8
  54. ;dp4 oT3.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_9
  55. ; spotlight texcoords
  56. dp4 oT0.x, $worldPos, $SHADER_SPECIFIC_CONST_1
  57. dp4 oT0.y, $worldPos, $SHADER_SPECIFIC_CONST_2
  58. dp4 oT0.z, $worldPos, $SHADER_SPECIFIC_CONST_3
  59. dp4 oT0.w, $worldPos, $SHADER_SPECIFIC_CONST_4
  60. local( $worldPosToLightVector, $distFactors );
  61. alloc $worldPosToLightVector
  62. sub $worldPosToLightVector, $SHADER_SPECIFIC_CONST_0, $worldPos
  63. mov oT2, $worldPosToLightVector
  64. local( $distatten );
  65. alloc $distatten
  66. ; $distatten = [ 1, 1/dist, 1/distsquared ]
  67. ; dist squared
  68. dp3 $distatten.z, $worldPosToLightVector, $worldPosToLightVector
  69. ; oodist
  70. rsq $distatten.y, $distatten.z
  71. mov $distatten.x, $cOne
  72. local( $dist );
  73. alloc $dist
  74. mul $dist.x, $distatten.z, $distatten.y
  75. rcp $distatten.z, $distatten.z ; 1/distsquared
  76. local( $endFalloffFactor );
  77. alloc $endFalloffFactor
  78. ; ( dist - farZ )
  79. sub $endFalloffFactor.x, $dist.x, $SHADER_SPECIFIC_CONST_5.w
  80. ; 1 / ( (0.6f * farZ) - farZ)
  81. mul $endFalloffFactor, $endFalloffFactor.x, $SHADER_SPECIFIC_CONST_0.w
  82. max $endFalloffFactor, $endFalloffFactor, $cZero
  83. min $endFalloffFactor, $endFalloffFactor, $cOne
  84. local( $vertAtten );
  85. alloc $vertAtten
  86. dp3 $vertAtten, $distatten, $SHADER_SPECIFIC_CONST_5
  87. mul $vertAtten, $vertAtten, $endFalloffFactor
  88. if( $TEETH )
  89. {
  90. alloc $mouthAtten
  91. dp3 $mouthAtten, $worldNormal.xyz, $SHADER_SPECIFIC_CONST_10.xyz
  92. max $mouthAtten, $cZero, $mouthAtten
  93. mul $mouthAtten, $mouthAtten, $SHADER_SPECIFIC_CONST_10.w
  94. mul $vertAtten, $vertAtten, $mouthAtten
  95. free $mouthAtten
  96. }
  97. mov oD0, $vertAtten
  98. mov oT3.xyz, $worldNormal.xyz
  99. free $dist
  100. free $endFalloffFactor
  101. free $worldPos
  102. free $worldNormal
  103. free $projPos
  104. free $worldPosToLightVector
  105. free $distatten
  106. free $vertAtten