View previous topic :: View next topic |
Author |
Message |
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Sun Dec 05, 2004 8:07 am Post subject: Attenuation For Dummies |
|
|
i never quiete understood this attenuation model, even though I have to use it when I code in opengl. I end up fiddling with it forever until it looks right. I even have an opengl book that explains this.
Can anyone explain how the 3 attenuations work together, and how they map to world units in deled? Failing that, a good tutorial somewhere? |
|
Back to top |
|
|
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Sun Dec 05, 2004 8:34 am Post subject: |
|
|
I don't know much about the lighting implementation (that was PJ's job ) but have you checked the Help? We've included links to DeleD lighting tutorials in there. They will be on our site too after we redesigned parts of it. |
|
Back to top |
|
|
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Sun Dec 05, 2004 8:41 am Post subject: |
|
|
Yes I've read the help. Nice job on that. Better than the old one. But you could have chosen a better color for the map file spec where you use the same shade almost in bold to desbribe the parts of the file as the background. Hard on the eyes.
PErhaps I'll try reading and rereading the explanations in my book. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Sun Dec 05, 2004 11:02 am Post subject: |
|
|
Attenuation is a simple formula that relates the strength of the light to the distance (in DeleD units) to the light source. The exact formula can be found here:
http://www.delgine.com/index.php?filename=reference_lighting#PointLight
This attenuation factor is then simply multiplied with the colour of the light to get the final colour.
The problem with the large size of DeleD words (as 1 DeleD units is 1 OpenGL Unit) is that you'll need fairly small values for especially the quadratic part of the attenuation. We realise this requires a lot of trial-and-error at the moment, that is why we'll have a quick preview of the light area in future versions of DeleD as a visual aid.
If there is anything specific about the attenuation equation you don't understand, please ask! |
|
Back to top |
|
|
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Sun Dec 05, 2004 11:10 am Post subject: |
|
|
Paul-Jan wrote: |
Attenuation is a simple formula that relates the strength of the light to the distance (in DeleD units) to the light source. The exact formula can be found here:
http://www.delgine.com/index.php?filename=reference_lighting#PointLight
This attenuation factor is then simply multiplied with the colour of the light to get the final colour.
The problem with the large size of DeleD words (as 1 DeleD units is 1 OpenGL Unit) is that you'll need fairly small values for especially the quadratic part of the attenuation. We realise this requires a lot of trial-and-error at the moment, that is why we'll have a quick preview of the light area in future versions of DeleD as a visual aid.
If there is anything specific about the attenuation equation you don't understand, please ask! |
The part I don't get is what the constant, linear, and quadric parts do.
Linear 1.0 means what?
Quadric 0.000030 means what? |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Sun Dec 05, 2004 12:15 pm Post subject: |
|
|
Let's fill it into the formula. Let's start with a combination of a constant of 1 (don't mess with this constant unless you know what you are doing) and a linear of 0.5 (no quadratic). The formula would then become:
attenuation = 1 / ( 1 + 0.5 * distance ). At a distance of 2 units the attenuation factor would be 1/2, so the light would already have lost half it's strength. At a distance of 64 units the attenuation factor would be 1 / 32, so light would be diminished a lot, and at a distance of 256 units the light would be barely visible. As you can see, the light drops off quickly at short distance, and then slowly fades away the further away you get. As a sidenote, in DeleD you better take a much smaller value for linear, because a light that is at half it's power at 2 units distance won't do you much good
Now let's drop the linear factor, and pick a quadratic of 0.0003. Now the formula is attenuation = 1/ ( 1 + 0.0003 * distance * distance ). At a distance of 2 units the light would still be at full strength, with a factor of only ( 1 / 1.0012 ). At a distance of 64 units, the light would still be going strong ( 1 / 1.2288 ), but at a distance of 256 it would be 1/20.
I just released you probably understand all this in a purely acadamic way, but have problems _visiualising_ what the formule looks like. Just had a brainwave for a new DeleD feature: a little graph in the Object Inspector showing you immediately how distance and attenuation relate, given the factors. Would that help? |
|
Back to top |
|
|
granada Team member
Joined: 07 Aug 2004 Posts: 1955 Location: England
|
Posted: Sun Dec 05, 2004 12:19 pm Post subject: |
|
|
Quote: |
Just had a brainwave for a new DeleD feature: a little graph in the Object Inspector showing you immediately how distance and attenuation relate, given the factors. Would that help? |
Sounds good to me
dave _________________ AMD Phenom(tm)IIx6 1090t Processor 3.20 GHS
8.00 GB memory
Windows 7 64 bit
Nvida Geforce GTX 580 |
|
Back to top |
|
|
|