light attenuation
The current method I use for light attenuation produces a slightly abrupt transition between the central area of the light(with a brightness of 1.0) and the beginning of the falloff region which attenuates the light from 1.0 to the scene's ambient light.
Here's what I'm talking about:
![[Image: lighting.jpg]](http://i642.photobucket.com/albums/uu150/ari556655/lighting.jpg)
My code looks something like this:
I've tried several other similar methods I've found through google but they've all produced similar or worse results.
I'd really appreciate any suggestions.
Here's what I'm talking about:
![[Image: lighting.jpg]](http://i642.photobucket.com/albums/uu150/ari556655/lighting.jpg)
My code looks something like this:
Code:
typedef struct
{
float falloff;
float central_radius;
}light_type;
float object_atten = 1.0 - (obj_dist_from_light - light->central_radius) / light->falloff;I've tried several other similar methods I've found through google but they've all produced similar or worse results.
I'd really appreciate any suggestions.
Anyone want to give it a try?
I have come across this problem quite often, and have done a few things that usually help.
First have a look at this excellent article explaining various interpolation techniques:
http://sol.gfxile.net/interpolation/
Instead of having an area of flat white suddenly hitting a linear interpolation fade off, you could have the fade start slowly at the center and increase as you reach the edges. A higher power or sin curve might help.
Also adding some noise or complexity with the interaction between the light and the world can help. This may or may not be possible for your engine, but using perlin noise to add texture to the light, or adding as well as multiplying the light with the background but with different algorithms or textures may also be an option.
First have a look at this excellent article explaining various interpolation techniques:
http://sol.gfxile.net/interpolation/
Instead of having an area of flat white suddenly hitting a linear interpolation fade off, you could have the fade start slowly at the center and increase as you reach the edges. A higher power or sin curve might help.
Also adding some noise or complexity with the interaction between the light and the world can help. This may or may not be possible for your engine, but using perlin noise to add texture to the light, or adding as well as multiplying the light with the background but with different algorithms or textures may also be an option.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Transforming directional light to eye space in GLSL | Coyote | 4 | 4,761 |
Dec 8, 2009 03:16 PM Last Post: Coyote |
|
| OpenGL Blending for 2D Light Effects | metacollin | 10 | 10,547 |
Jun 6, 2009 12:51 AM Last Post: NelsonMandella |
|
| Point distance attenuation with OGL-extension - how? | mcMike | 6 | 4,910 |
May 21, 2008 10:58 PM Last Post: mcMike |
|
| 2d light shadows | KiroNeem | 2 | 2,950 |
Sep 9, 2005 01:12 PM Last Post: KiroNeem |
|
| Vissible Light (Volumetric?) | hangt5 | 6 | 3,895 |
Mar 28, 2005 02:25 PM Last Post: OneSadCookie |
|

