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.

97 lines
3.1 KiB

  1. vs.1.1
  2. # STATIC: "INTRO" "0..1"
  3. # STATIC: "HALF_LAMBERT" "0..1"
  4. # DYNAMIC: "DOWATERFOG" "0..1"
  5. # DYNAMIC: "LIGHT_COMBO" "0..21"
  6. # DYNAMIC: "SKINNING" "0..1"
  7. ;------------------------------------------------------------------------------
  8. ; $SHADER_SPECIFIC_CONST_0 = xyz = mouth forward direction vector, w = illum factor
  9. ;------------------------------------------------------------------------------
  10. #include "macros.vsh"
  11. $WARPPARAM = $SHADER_SPECIFIC_CONST_2;
  12. $ENTITY_ORIGIN = $SHADER_SPECIFIC_CONST_3;
  13. ;------------------------------------------------------------------------------
  14. ; Vertex blending
  15. ;------------------------------------------------------------------------------
  16. alloc $worldPos
  17. alloc $worldNormal
  18. &SkinPositionAndNormal( $worldPos, $worldNormal );
  19. ;------------------------------------------------------------------------------
  20. ; Optional intro warping
  21. ;------------------------------------------------------------------------------
  22. if ( $INTRO == 1 )
  23. {
  24. alloc $tmp
  25. sub $tmp.xyz, $worldPos, $ENTITY_ORIGIN
  26. mul $tmp.xy, $tmp, $WARPPARAM
  27. add $worldPos.xyz, $tmp, $ENTITY_ORIGIN
  28. free $tmp
  29. }
  30. ;------------------------------------------------------------------------------
  31. ; Transform the position from world to view space
  32. ;------------------------------------------------------------------------------
  33. alloc $projPos
  34. dp4 $projPos.x, $worldPos, $cViewProj0
  35. dp4 $projPos.y, $worldPos, $cViewProj1
  36. dp4 $projPos.z, $worldPos, $cViewProj2
  37. dp4 $projPos.w, $worldPos, $cViewProj3
  38. mov oPos, $projPos
  39. ;------------------------------------------------------------------------------
  40. ; Fog
  41. ;------------------------------------------------------------------------------
  42. &CalcFog( $worldPos, $projPos );
  43. free $projPos
  44. ;------------------------------------------------------------------------------
  45. ; Lighting
  46. ;------------------------------------------------------------------------------
  47. alloc $linearColor
  48. &DoDynamicLightingToLinear( $worldPos, $worldNormal, $linearColor );
  49. ;------------------------------------------------------------------------------
  50. ; Factor in teeth darkening factors
  51. ;------------------------------------------------------------------------------
  52. alloc $tmp
  53. mul $linearColor.xyz, $SHADER_SPECIFIC_CONST_0.w, $linearColor ; FIXME Color darkened by illumination factor
  54. dp3 $tmp, $worldNormal, $SHADER_SPECIFIC_CONST_0 ; Figure out mouth forward dot normal
  55. max $tmp, $cZero, $tmp ; clamp from 0 to 1
  56. mul $linearColor.xyz, $tmp, $linearColor ; Darken by forward dot normal too
  57. ;------------------------------------------------------------------------------
  58. ; Output color (gamma correction)
  59. ;------------------------------------------------------------------------------
  60. alloc $gammaColor
  61. &LinearToGamma( $linearColor, $gammaColor );
  62. free $linearColor
  63. mul oD0.xyz, $gammaColor.xyz, $cOverbrightFactor
  64. mov oD0.w, $cOne ; make sure all components are defined
  65. free $gammaColor
  66. free $worldPos
  67. free $worldNormal
  68. free $tmp
  69. ;------------------------------------------------------------------------------
  70. ; Texture coordinates
  71. ;------------------------------------------------------------------------------
  72. mov oT0, $vTexCoord0