satan

11-09-2008, 08:29 PM

Hi,

having directional lights working via fullscreen quads in my deferred renderer, I just started with point lights. These I want to draw using spheres as suggested in many papers about this topic. My problem is how to get the size of these spheres?

As I could not find any information on the calculation I thought it would be straight forward.

So I calculate the sizes the following way:

d = distance

c,l,q are the attenuation factors as known by OpenGL

As the attenuation is defined as a = 1/(q*d*d+l*d+c), I solve the equation q*d*d+l*d+c = 255 for d (and take the smallest positive root) to get the distance where the light intensity is 1/255. This works reasonably well but the spheres are really huge. Using smaller values than 255 I can see the border of my light volume (at least with only 1 point light illuminating the scene).

To get small light bounding spheres I have to use huge values for the quadratic attenuation (q>>10).

Am I doing anything wrong? And how do you calculate the radii for your spheres of light influence?

having directional lights working via fullscreen quads in my deferred renderer, I just started with point lights. These I want to draw using spheres as suggested in many papers about this topic. My problem is how to get the size of these spheres?

As I could not find any information on the calculation I thought it would be straight forward.

So I calculate the sizes the following way:

d = distance

c,l,q are the attenuation factors as known by OpenGL

As the attenuation is defined as a = 1/(q*d*d+l*d+c), I solve the equation q*d*d+l*d+c = 255 for d (and take the smallest positive root) to get the distance where the light intensity is 1/255. This works reasonably well but the spheres are really huge. Using smaller values than 255 I can see the border of my light volume (at least with only 1 point light illuminating the scene).

To get small light bounding spheres I have to use huge values for the quadratic attenuation (q>>10).

Am I doing anything wrong? And how do you calculate the radii for your spheres of light influence?