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
2.2 KiB

  1. # STATIC: "UNLIT" "0..1"
  2. # STATIC: "HALF_LAMBERT" "0..1"
  3. # DYNAMIC: "LIGHT_COMBO" "0..21"
  4. # DYNAMIC: "SKINNING" "0..1"
  5. vs.1.1
  6. #include "macros.vsh"
  7. $WARPPARAM = $SHADER_SPECIFIC_CONST_2;
  8. $ENTITY_ORIGIN = $SHADER_SPECIFIC_CONST_3;
  9. ;------------------------------------------------------------------------------
  10. ; Vertex blending
  11. ;------------------------------------------------------------------------------
  12. &AllocateRegister( \$worldPos );
  13. &AllocateRegister( \$worldNormal );
  14. &AllocateRegister( \$projPos );
  15. &SkinPositionAndNormal( $worldPos, $worldNormal );
  16. alloc $tmp
  17. sub $tmp.xyz, $worldPos, $ENTITY_ORIGIN
  18. mul $tmp.xy, $tmp, $WARPPARAM
  19. add $worldPos.xyz, $tmp, $ENTITY_ORIGIN
  20. free $tmp
  21. if( $SKINNING == 1 )
  22. {
  23. &Normalize( $worldNormal );
  24. }
  25. ;------------------------------------------------------------------------------
  26. ; Transform the position from world to view space
  27. ;------------------------------------------------------------------------------
  28. dp4 $projPos.x, $worldPos, $cViewProj0
  29. dp4 $projPos.y, $worldPos, $cViewProj1
  30. dp4 $projPos.z, $worldPos, $cViewProj2
  31. dp4 $projPos.w, $worldPos, $cViewProj3
  32. mov oPos, $projPos
  33. ;------------------------------------------------------------------------------
  34. ; Fog - don't bother with water fog for intro effects
  35. ;------------------------------------------------------------------------------
  36. &DepthFog( $projPos, "oFog" );
  37. &FreeRegister( \$projPos );
  38. ;------------------------------------------------------------------------------
  39. ; Lighting
  40. ;------------------------------------------------------------------------------
  41. if( $UNLIT )
  42. {
  43. mov oD0, $cHalf
  44. }
  45. else
  46. {
  47. &DoLighting( $worldPos, $worldNormal );
  48. }
  49. if( !$envmap )
  50. {
  51. &FreeRegister( \$worldNormal );
  52. }
  53. ;------------------------------------------------------------------------------
  54. ; Texture coordinates
  55. ;------------------------------------------------------------------------------
  56. dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  57. dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
  58. alloc $tmp2
  59. dp4 $tmp2.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
  60. dp4 $tmp2.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
  61. add oT1.xy, $tmp2, $SHADER_SPECIFIC_CONST_4
  62. free $tmp2
  63. ; YUCK! This is to make texcoords continuous for mat_softwaretl
  64. mov oT2, $cZero
  65. &FreeRegister( \$worldPos );