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.

104 lines
3.5 KiB

  1. # DYNAMIC: "SKINNING" "0..1"
  2. vs.1.1
  3. #include "macros.vsh"
  4. ;------------------------------------------------------------------------------
  5. ; Vertex blending
  6. ;------------------------------------------------------------------------------
  7. &AllocateRegister( \$worldPos );
  8. &AllocateRegister( \$worldNormal );
  9. &AllocateRegister( \$projPos );
  10. &SkinPositionAndNormal( $worldPos, $worldNormal );
  11. if( $SKINNING == 1 )
  12. {
  13. &Normalize( $worldNormal );
  14. }
  15. ;------------------------------------------------------------------------------
  16. ; Transform the position from world to view space
  17. ;------------------------------------------------------------------------------
  18. dp4 $projPos.x, $worldPos, $cViewProj0
  19. dp4 $projPos.y, $worldPos, $cViewProj1
  20. dp4 $projPos.z, $worldPos, $cViewProj2
  21. dp4 $projPos.w, $worldPos, $cViewProj3
  22. mov oPos, $projPos
  23. ;------------------------------------------------------------------------------
  24. ; Fog - don't bother with water fog for intro effects
  25. ;------------------------------------------------------------------------------
  26. &DepthFog( $projPos, "oFog" );
  27. ;------------------------------------------------------------------------------
  28. ; Refract uv's (Code copied from predator.vsh)
  29. ;------------------------------------------------------------------------------
  30. ; NOTE: projPos isn't projPos after this point. :)
  31. &AllocateRegister( \$projNormal );
  32. ; only do X and Y since that's all we care about
  33. dp3 $projNormal.x, $worldNormal, $cViewProj0
  34. dp3 $projNormal.y, $worldNormal, $cViewProj1
  35. ; divide by z
  36. rcp $projPos.w, $projPos.w
  37. mul $projPos.xy, $projPos.w, $projPos.xy
  38. ; map from -1..1 to 0..1
  39. mad $projPos.xy, $projPos.xy, $cHalf, $cHalf
  40. ; tweak with the texcoords based on the normal and $refractionamount
  41. mad $projPos.xy, $projNormal.xy, -$SHADER_SPECIFIC_CONST_4.xy, $projPos.xy ; FIXME
  42. ; invert y
  43. add $projPos.y, $cOne, -$projPos.y
  44. ; hack scale for nvidia (Power of two texcoords are screwed.)
  45. mul oT0.xy, $projPos.xy, $SHADER_SPECIFIC_CONST_5.xy
  46. ; YUCK! This is to make texcoords continuous for mat_softwaretl
  47. mov oT2, $cZero
  48. &FreeRegister( \$projPos );
  49. &FreeRegister( \$projNormal );
  50. ;------------------------------------------------------------------------------
  51. ; Refract mask
  52. ;------------------------------------------------------------------------------
  53. ; // float flFresnel = 1.0f - saturate( dot( i.vWorldNormal.xyz, normalize( -i.vWorldViewVector.xyz ) ) );
  54. &AllocateRegister( \$flFresnel );
  55. &AllocateRegister( \$tmp1 );
  56. sub $flFresnel, $worldPos, $cEyePos
  57. &Normalize( $flFresnel );
  58. dp3 $flFresnel, -$flFresnel, $worldNormal
  59. max $flFresnel, $flFresnel, $cZero
  60. sub $flFresnel, $cOne, $flFresnel
  61. ; // float flCloakLerpFactor = saturate( lerp( 1.0f, flFresnel - 1.35f, saturate( g_flCloakFactor ) ) );
  62. &AllocateRegister( \$flCloakLerpFactor );
  63. sub $flCloakLerpFactor, $flFresnel, $SHADER_SPECIFIC_CONST_3.x ; // flFresnel - 1.35f
  64. mov $tmp1, $cOne
  65. sub $flCloakLerpFactor, $flCloakLerpFactor, $tmp1
  66. mad $flCloakLerpFactor, $flCloakLerpFactor, $SHADER_SPECIFIC_CONST_3.y, $tmp1
  67. max $flCloakLerpFactor, $flCloakLerpFactor, $cZero
  68. min $flCloakLerpFactor, $flCloakLerpFactor, $cOne
  69. ; // flCloakLerpFactor = 1.0f - smoothstep( 0.4f, 0.425f, flCloakLerpFactor );
  70. sub $flCloakLerpFactor, $flCloakLerpFactor, $SHADER_SPECIFIC_CONST_3.z
  71. mul $flCloakLerpFactor, $flCloakLerpFactor, $SHADER_SPECIFIC_CONST_3.w
  72. sub $flCloakLerpFactor, $cOne, $flCloakLerpFactor
  73. mov oD0, $flCloakLerpFactor
  74. &FreeRegister( \$tmp1 );
  75. &FreeRegister( \$flFresnel );
  76. &FreeRegister( \$flCloakLerpFactor );
  77. &FreeRegister( \$worldPos );
  78. &FreeRegister( \$worldNormal );