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.

47 lines
1.1 KiB

  1. ;------------------------------------------------------------------------------
  2. ; Computes the diffuse component of lighting using lightmap + bumpmap
  3. ; t0 - Normalmap
  4. ; t1 - Lightmap1
  5. ; t2 - Lightmap2
  6. ; t3 - Lightmap3
  7. ; t4 - Base1
  8. ; t5 - Base2
  9. ;
  10. ; The texture coordinates need to be defined as follows:
  11. ; tc0 - Normalmap and lightmap texture coordinates
  12. ; c0, c1, c2 - Axes of the lightmap coordinate system in tangent space
  13. ;------------------------------------------------------------------------------
  14. ps.1.4
  15. ; output = (lightmapColor[0] * ( ( N dot basis[0] )^2 ) +
  16. ; lightmapColor[1] * ( ( N dot basis[1] )^2 ) +
  17. ; lightmapColor[2] * ( ( N dot basis[2] )^2 ) ) * lerp(base1, base2, lightmapColor[0].a)
  18. ; Get the 3-vector from the normal map
  19. texld r0, t0
  20. dp3 r5.r, r0_bx2, c0
  21. dp3 r5.g, r0_bx2, c1
  22. dp3 r5.b, r0_bx2, c2
  23. mul r5.rgb, r5, r5
  24. phase
  25. ; Sample the lightmaps
  26. texld r1, t1
  27. texld r2, t2
  28. texld r3, t3
  29. ; Sample the base textures
  30. texld r4, t4
  31. texld r5, t5
  32. mul r1, r1, r5.r
  33. mad r1, r2, r5.g, r1
  34. mad r1, r3, r5.g, r1
  35. ; blend base textures
  36. lrp r4, r4, r5, r1.a
  37. ; assume overbright_2 !!!
  38. mul_x2 r0, r1, r4