PDA

View Full Version : Area of light influence and deferred shading



satan
11-09-2008, 09: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?

sqrt[-1]
11-09-2008, 11:11 PM
I can't speak for everyone, but I typically use fixed attenuation when doing deferred rendering - something like 1 - D^2.

I use that attenuation in my deferred render demo:
http://code.google.com/p/lightindexed-deferredrender/

Jan
11-10-2008, 02:17 AM
I think no one really uses the physically correct attenuation, because it covers a huge area, that is not lit very noticeably.

As sqrt[-1] said, use fixed attenuation. Linear or 1-D^2 both work well, it only depends on what your artistic desires are. You can even invent your very own attenuation function, if that suits you better.

Jan.

satan
11-10-2008, 06:35 PM
Thanks for the input. So I will use att = 1-f*dē even if the results are visually less pleasing.

@sqrt[1]: Nice demo.

@Jan: Are you really sure that OpenGLs light attenuation function is physically correct? AFAIK light attenuation is an exponential function of at least the medium which the light travels through, the lights (or more correctly photons) energy and of course the distance. But I could be wrong.

Jan
11-11-2008, 02:16 AM
I didn't mean that OpenGLs built in light-function is physically correct (note that computer graphics is one huge pile of hacks and approximations anyway). I meant, that you can implement your own lighting function through shaders. And that is where no one tries to implement a physically correct function, because it would mean that lights would have an infinite area of influence.

I honestly don't know what OpenGL's fixed function pipeline uses for attenuation, i never used the built in stuff (which is now deprecated anyway).

Jan.

Brolingstanz
11-11-2008, 02:50 AM
Besides, once we can actually solve the rendering equation in realtime, there'll be no where to go but in directions our artistic desires take us, anyway. (Not that we're in any danger of that just yet!)