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.

39 lines
1.0 KiB

  1. ps.1.4
  2. ; Get the 3-vector from the normal map
  3. texld r0, t0
  4. ; Get environment matrix
  5. texcrd r1.rgb, t1
  6. texcrd r2.rgb, t2
  7. texcrd r3.rgb, t3
  8. ; Normalize eye-ray vector through normalizer cube map
  9. texld r4, t4 ; <---- CUBE MAP here!!!
  10. ; Transform normal
  11. dp3 r5.r, r1, r0_bx2
  12. dp3 r5.g, r2, r0_bx2
  13. dp3 r5.b, r3, r0_bx2
  14. ; Reflection calculatiom
  15. dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
  16. mul r3.rgb, r5, r3 ; 2N(N.Eye)
  17. dp3 r2.rgb, r5, r5 ; N.N
  18. mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
  19. phase
  20. ; Sample environment map
  21. texld r3, r2
  22. texld r4, t5 ; Normalize the tangent-space eye vector
  23. ; dot eye-vector with per-pixel normal from r0
  24. dp3_sat r1, r4_bx2, r0_bx2
  25. ; run Fresnel approx. on it: R0 + (1-R0) (1-cos(q))^5 in alpha channel
  26. mul r0.a, 1-r1.a, 1-r1.a ; squared
  27. mul r0.a, r0.a, r0.a ; quartic
  28. mul_sat r1.a, r0.a, 1-r1.a ; quintic
  29. ; multiply color by reflecttint
  30. mul r0, r3, c1
  31. ; blend between reflected color and fog color based on fresnel
  32. lrp r0.rgb, r1.a, r0, c0