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.2 KiB

  1. ps.1.4
  2. ;------------------------------------------------------------------------------
  3. ; Phase 1
  4. ;------------------------------------------------------------------------------
  5. ; Get the 3-vector from the normal map
  6. texld r0, t0
  7. ; Get environment matrix
  8. texcrd r1.rgb, t1
  9. texcrd r2.rgb, t2
  10. texcrd r3.rgb, t3
  11. ; Normalize eye-ray vector through normalizer cube map
  12. texld r4, t4 ; <---- CUBE MAP here!!!
  13. ; Transform normal
  14. dp3 r5.r, r1, r0_bx2
  15. dp3 r5.g, r2, r0_bx2
  16. dp3 r5.b, r3, r0_bx2
  17. ; Reflection calculatiom
  18. dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
  19. mul r3.rgb, r5, r3 ; 2N(N.Eye)
  20. dp3 r2.rgb, r5, r5 ; N.N
  21. mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
  22. ; Alpha gets lost after phase marker, so store it here
  23. mov r5, r0.a
  24. ;------------------------------------------------------------------------------
  25. ; Phase 2
  26. ;------------------------------------------------------------------------------
  27. phase
  28. ; Sample environment map
  29. texld r3, r2
  30. ; Result goes in output color (multiply by constant color c0)
  31. mul r0.rgb, r3, c0
  32. +mov r0.a, c0.a
  33. mul r1.rgb, r0, r0
  34. lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
  35. dp3 r1.rgb, r0, c3
  36. lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale