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.

80 lines
3.0 KiB

  1. vs.1.1
  2. ;------------------------------------------------------------------------------
  3. ; $SHADER_SPECIFIC_CONST_0 = eyeball origin
  4. ; $SHADER_SPECIFIC_CONST_1 = eyeball up * 0.5
  5. ; $SHADER_SPECIFIC_CONST_2 = iris projection U
  6. ; $SHADER_SPECIFIC_CONST_3 = iris projection V
  7. ; $SHADER_SPECIFIC_CONST_4 = glint projection U
  8. ; $SHADER_SPECIFIC_CONST_5 = glint projection V
  9. ;------------------------------------------------------------------------------
  10. # STATIC: "HALF_LAMBERT" "0..1"
  11. # DYNAMIC: "DOWATERFOG" "0..1"
  12. # DYNAMIC: "LIGHT_COMBO" "0..21"
  13. # DYNAMIC: "SKINNING" "0..1"
  14. #include "macros.vsh"
  15. ;------------------------------------------------------------------------------
  16. ; Vertex blending (whacks r1-r7, positions in r7)
  17. ;------------------------------------------------------------------------------
  18. &AllocateRegister( \$worldPos );
  19. &SkinPosition( $worldPos );
  20. ;------------------------------------------------------------------------------
  21. ; Transform the position from world to view space
  22. ;------------------------------------------------------------------------------
  23. &AllocateRegister( \$projPos );
  24. dp4 $projPos.x, $worldPos, $cViewProj0
  25. dp4 $projPos.y, $worldPos, $cViewProj1
  26. dp4 $projPos.z, $worldPos, $cViewProj2
  27. dp4 $projPos.w, $worldPos, $cViewProj3
  28. mov oPos, $projPos
  29. ;------------------------------------------------------------------------------
  30. ; Normal is based on vertex position
  31. ;------------------------------------------------------------------------------
  32. &AllocateRegister( \$worldNormal );
  33. &AllocateRegister( \$normalDotUp );
  34. sub $worldNormal, $worldPos, $SHADER_SPECIFIC_CONST_0 ; Normal = (Pos - Eye origin)
  35. dp3 $normalDotUp, $worldNormal, $SHADER_SPECIFIC_CONST_1 ; Normal -= 0.5f * (Normal dot Eye Up) * Eye Up
  36. mul $normalDotUp, $normalDotUp, $cHalf
  37. mad $worldNormal, -$normalDotUp, $SHADER_SPECIFIC_CONST_1, $worldNormal
  38. &FreeRegister( \$normalDotUp );
  39. ; normalize the normal
  40. &Normalize( $worldNormal );
  41. ;------------------------------------------------------------------------------
  42. ; Lighting
  43. ;------------------------------------------------------------------------------
  44. &DoLighting( $worldPos, $worldNormal );
  45. &FreeRegister( \$worldNormal );
  46. ;------------------------------------------------------------------------------
  47. ; Fog
  48. ;------------------------------------------------------------------------------
  49. &CalcFog( $worldPos, $projPos );
  50. &FreeRegister( \$projPos );
  51. ;------------------------------------------------------------------------------
  52. ; Texture coordinates
  53. ; Texture 0 is the base texture
  54. ; Texture 1 is a planar projection used for the iris
  55. ; Texture 2 is a planar projection used for the glint
  56. ;------------------------------------------------------------------------------
  57. mov oT0, $vTexCoord0
  58. dp4 oT1.x, $SHADER_SPECIFIC_CONST_2, $worldPos
  59. dp4 oT1.y, $SHADER_SPECIFIC_CONST_3, $worldPos
  60. dp4 oT2.x, $SHADER_SPECIFIC_CONST_4, $worldPos
  61. dp4 oT2.y, $SHADER_SPECIFIC_CONST_5, $worldPos
  62. &FreeRegister( \$worldPos );