Advertisement Jump to content
Sign in to follow this  

Real world attenuation.

This topic is 4965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi people. I'm trying simulation real world lights such as car lights but I'm having trouble determining what attenuation values will give me the best results. Are there any general equations for coming up with constant, linear and quadratic bast on size and voltage of a light? How do most people here come up with attenuations values?

Share this post

Link to post
Share on other sites
attenuation = 1/distance isnt it?

I'm just working on this myself!


Share this post

Link to post
Share on other sites
Original post by Grasshopper
attenuation = 1/(a*distance*distance + b*distance + c)

The question I have is how do I come up with a, b and c.

I believe this equation is commonly used by general purpose graphics libraries because it allows the programmer to choose between linear and quadratic attenuation, or any combination of the two. The values of a, b and c will thus depend on how you want to model attenuation, which will in turn probably depend on what you're drawing and how you're drawing it.

In the real world, though, the light intensity at a point is inversely proportional to the square of the distance of the point from the light. That is, intensity = k/distance^2.

EDIT: Sorry, I think I misinterpreted your post. Putting it down to exam stress.

If you do want to work with the equation you mention, then the constants you choose will probably depend on your rendering methods. If you're using some HDR techniques, then you could try to approximate the properties of the lights in the real world. Otherwise, you'll have to work out whether quadratic attenuation is too fast a falloff, and whether linear attenuation is too slow, and find some combination of the two that works.

The constant c will allow you to approximate the attenuation types without having the intensity tending to infinity close to the light.

Personally, I give all lights a radius and intensity, and then use the equation

intensity = light_intensity * (1.0 - SqrDistance(point_pos, light_pos)/(light_radius*light_radius))

where SqrDistance(v1, v2) is the square of the distance between v1 and v2.

This gives quite pleasant results, and has the added advantage that you can cull all objects outside of the light's radius, since all points outside of the radius will receive no light (with the equation you're using, there isn't this cut off). Unfortunately, it's probably not easy to implement this using a fixed function pipeline.

Blah. Must be a record number of edits on this post. The number of stupid mistakes I made is amazing.

[Edited by - MumbleFuzz on June 16, 2005 10:41:03 AM]

Share this post

Link to post
Share on other sites
There's nothing real world about
attenuation = 1/(a*distance^2 + b * distance + c)
at all. It's a cheap hack to give more control to lighting artists. If you use a point light, which again, is not real at all, then attenuation is
1/(4pi * distance^2)

However, if you truly want something physically based, then you'll have to implement area lights, where attenuation is calculated by finding the projected solid angle subtended by the light over the unit hemisphere.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!