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.

86 lines
2.8 KiB

  1. vs.1.1
  2. # DYNAMIC: "DOWATERFOG" "0..1"
  3. # DYNAMIC: "SKINNING" "0..1"
  4. ;------------------------------------------------------------------------------
  5. ; Constants specified by the app
  6. ; c0 = (0, 1, 2, 0.5)
  7. ; c1 = (1/2.2, 0, 0, 0)
  8. ; c2 = camera position *in world space*
  9. ; c4-c7 = modelViewProj matrix (transpose)
  10. ; c8-c11 = ViewProj matrix (transpose)
  11. ; c12-c15 = model->view matrix (transpose)
  12. ; c16 = [fogStart, fogEnd, fogRange, undefined]
  13. ;
  14. ; Vertex components (as specified in the vertex DECL)
  15. ; $vPos = Position
  16. ; $vTexCoord0.xy = TexCoord0
  17. ;------------------------------------------------------------------------------
  18. #include "macros.vsh"
  19. ;------------------------------------------------------------------------------
  20. ; Vertex blending
  21. ;------------------------------------------------------------------------------
  22. &AllocateRegister( \$worldPos );
  23. &AllocateRegister( \$worldNormal );
  24. &SkinPositionAndNormal( $worldPos, $worldNormal );
  25. ;------------------------------------------------------------------------------
  26. ; Transform the position from world to proj space
  27. ;------------------------------------------------------------------------------
  28. &AllocateRegister( \$projPos );
  29. dp4 $projPos.x, $worldPos, $cViewProj0
  30. dp4 $projPos.y, $worldPos, $cViewProj1
  31. dp4 $projPos.z, $worldPos, $cViewProj2
  32. dp4 $projPos.w, $worldPos, $cViewProj3
  33. mov oPos, $projPos
  34. ;------------------------------------------------------------------------------
  35. ; Fog
  36. ;------------------------------------------------------------------------------
  37. &CalcFog( $worldPos, $projPos );
  38. &FreeRegister( \$worldPos );
  39. ;------------------------------------------------------------------------------
  40. ; Transform the normal from world to proj space
  41. ;------------------------------------------------------------------------------
  42. &AllocateRegister( \$projNormal );
  43. ; only do X and Y since that's all we care about
  44. dp3 $projNormal.x, $worldNormal, $cViewProj0
  45. dp3 $projNormal.y, $worldNormal, $cViewProj1
  46. &FreeRegister( \$worldNormal );
  47. ;------------------------------------------------------------------------------
  48. ; Texture coordinates
  49. ;------------------------------------------------------------------------------
  50. ; NOTE: projPos isn't projPos after this point. :)
  51. ; divide by z
  52. rcp $projPos.w, $projPos.w
  53. mul $projPos.xy, $projPos.w, $projPos.xy
  54. ; map from -1..1 to 0..1
  55. mad $projPos.xy, $projPos.xy, $cHalf, $cHalf
  56. ; tweak with the texcoords based on the normal and $refractionamount
  57. mad $projPos.xy, $projNormal.xy, -$SHADER_SPECIFIC_CONST_4.xy, $projPos.xy ; FIXME
  58. ; invert y
  59. add $projPos.y, $cOne, -$projPos.y
  60. ; hack scale for nvidia (Power of two texcoords are screwed.)
  61. mul oT0.xy, $projPos.xy, $SHADER_SPECIFIC_CONST_5.xy
  62. &FreeRegister( \$projPos );
  63. &FreeRegister( \$projNormal );