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.

96 lines
1.5 KiB

  1. ; STATIC: "REFLECT" "0..1"
  2. ; STATIC: "REFRACT" "0..1"
  3. ps.1.4
  4. ; T2 - refraction
  5. ; T3 - normal map
  6. ; T4 - reflection
  7. ; TC0 - normal map coords
  8. ; TC1 - proj tex coords (reflection)
  9. ; TC2 - proj tex coords (refraction)
  10. ; TC3 - tangent space view vec
  11. ; TC4 - displacement scale
  12. ; sample normal map
  13. texld r3, t0
  14. #if REFLECT
  15. ; reflection coords
  16. texcrd r4.xy, t1_dw.xyw
  17. #endif
  18. #if REFRACT
  19. ; refraction coords
  20. texcrd r2.xy, t2_dw.xyw
  21. #endif
  22. ; tangent space eye vector
  23. texld r1, t5 ; <---- Normalizing CUBE MAP here!!!
  24. ; reflection/refraction scale (x,y)
  25. texcrd r0.xyz, t4.xyz
  26. ; perturb coords by constant displacement
  27. ; and by normal map alpha (which has 1/(2**miplevel in it)
  28. mul r0.rg, r0, r3.a
  29. #if REFLECT
  30. mad r4.rg, r3_bx2, r0.x, r4
  31. #endif
  32. #if REFRACT
  33. mad r2.rg, r3_bx2, r0.y, r2
  34. #endif
  35. ; stuff something into z so that texld will deal
  36. #if REFLECT
  37. mov r4.b, c5
  38. #endif
  39. #if REFRACT
  40. mov r2.b, c5
  41. #endif
  42. phase
  43. #if REFLECT
  44. ; reflection
  45. texld r4, r4
  46. #endif
  47. #if REFRACT
  48. ; refraction
  49. texld r2, r2
  50. #endif
  51. #if REFLECT
  52. ; N.V
  53. dp3_sat r1.a, r3_bx2, r1_bx2
  54. #endif
  55. #if REFRACT
  56. ; tint refraction
  57. mul r2.rgb, r2, c1
  58. #endif
  59. #if REFLECT
  60. ; tint reflction
  61. mul r4.rgb, r4, c4
  62. ; (1-N.V) ^ 5
  63. +mul r0.a, 1-r1.a, 1-r1.a
  64. mul r0.a, r0.a, r0.a
  65. mul_sat r0.a, r0.a, 1-r1.a
  66. #endif
  67. #if !REFLECT && !REFRACT
  68. ; This is wrong!!!!
  69. mov r0.rgba, c0
  70. #endif
  71. #if !REFLECT && REFRACT
  72. mov r0.rgba, r2
  73. #endif
  74. #if REFLECT && !REFRACT
  75. mov r0.rgba, r4
  76. #endif
  77. #if REFLECT && REFRACT
  78. ; reflection * fresnel + refraction * ( 1 - fresnel )
  79. lrp r0.rgba, r0.a, r4, r2
  80. #endif