Quote:Original post by Promit
For point lights, the standard approach is the compute the distance from the light per-vertex, then pass it on to the PS, letting it get interpolated along the way.
You can do more or less the same thing with the entire position rather than just a radial distance, but computing the distance per pixel is a complete waste of time.
I wouldn't exactly call it a "waste of time". It's far more accurate. Radial distance is just a scalar, it will not get interpolated correctly with low tesselation. A point light lighting a big flat quad would result in a completely incorrect image(assuming the distance is used for attenuation); because the distance calculated in all the vertices would be big, the whole surface will get very little light.
Tsumuji: All you have to do is calculate in the VS the vertex-to-light vector, and pass it to the PS. There, you calculate the length of interpolated vector, and that's the distance between the light position and the pixel position.