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.1
  2. ;------------------------------------------------------------------------------
  3. ; Sphere-lit particle pixel shader.
  4. ;
  5. ; The ParticleSphere lighting equation is:
  6. ; A + [[N dot |L - P|] * 0.5 + 0.5] * C * r / ||L - P||
  7. ;
  8. ; where:
  9. ; A = ambient light color
  10. ; N = particle normal (stored in the texture)
  11. ; L = light position
  12. ; P = point on surface
  13. ; C = directional light color
  14. ; r = directional light intensity
  15. ;
  16. ; This shader takes as input:
  17. ; t0 = Normal map texture coordinates (N)
  18. ; t1 = Light vector Normalize(L - P) * 0.5 in range [0,1]
  19. ; v0 = Directional color (C * r / ||L - P||^2) * 0.5
  20. ; t2 = Ambient light color (A)
  21. ; c0 = 0.5
  22. ;
  23. ; and outputs [v1 + (sample(t0) dot t1) * 0.5f + 0.5f]
  24. ;------------------------------------------------------------------------------
  25. tex t0 ; Get the 3-vector from the normal map
  26. texcoord t1 ; Interpret tcoord t1 as color data.
  27. texcoord t2 ; Ambient light color
  28. dp3 r1, t0_bx2, t1_bx2 ; r0 = sample(t0) dot t1
  29. add r0, r1, c0 ; + 0.5
  30. mul r1, v0, r0 ; scale the dot product by the dirlight's actual color
  31. add r0.rgb, r1, t2 ; add the ambient color in v1
  32. mul r0.a, t0, v0 ; Alpha = normal map alpha * vertex alpha