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.

42 lines
1.3 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. ;mov r0.rgba, r4
  14. ; Transform normal
  15. dp3 r5.r, r1, r0_bx2
  16. dp3 r5.g, r2, r0_bx2
  17. dp3 r5.b, r3, r0_bx2
  18. ; Reflection calculatiom
  19. dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye)
  20. mul r3.rgb, r5, r3 ; 2N(N.Eye)
  21. dp3 r2.rgb, r5, r5 ; N.N
  22. mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N)
  23. ; Alpha gets lost after phase marker, so store it here
  24. mov r5, r0.a
  25. ;------------------------------------------------------------------------------
  26. ; Phase 2
  27. ;------------------------------------------------------------------------------
  28. phase
  29. ; Sample environment map
  30. texld r3, r2
  31. ; Result goes in output color (multiply by constant color c0)
  32. mul r0.rgb, r3, c0
  33. +mov r0.a, c0.a
  34. mul r1.rgb, r0, r0
  35. lrp r0.rgb, c1, r1, r0 ; blend between color and color * color
  36. dp3 r1.rgb, r0, c3
  37. lrp r0.rgb, c2, r0, r1 ; blend between color and greyscale
  38. ; mult by alpha
  39. mul r0.rgb, r0, r5