If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
Table of contents
Description
This is a basic shortcut for calculating light attenuation based on the specified range. The attenuation is calculated so that you will have full light at 0% of the range which will diminish into nothing at 100% of the range.
For more information, read this great tutorial on Point Light Attenuation
.
Code
Using the logic based on the calculations made on the wiki page linked above:
3250, 1.0, 0.0014, 0.000007
600, 1.0, 0.007, 0.0002
325, 1.0, 0.014, 0.0007
200, 1.0, 0.022, 0.0019
160, 1.0, 0.027, 0.0028
100, 1.0, 0.045, 0.0075
65, 1.0, 0.07, 0.017
50, 1.0, 0.09, 0.032
32, 1.0, 0.14, 0.07
20, 1.0, 0.22, 0.20
13, 1.0, 0.35, 0.44
7, 1.0, 0.7, 1.8
You can determine the linear and quadratic values (or what is visually close enough) for any range you wish to use:
- Linear = 4.5 / LightRange
- Quadratic = 75.0 / LightRange^2
Here is a function to calculate attenuation based on the Light Range:
void setLightRange( Ogre::Light *L, Ogre::Real Range ) { L->setAttenuation( Range, 1.0f, 4.5/Range, 75.0f/(Range*Range) ); }
Note: Like in the page mentioned above, you won't get visual light much further than 20% of the specified range.
Contributors to this page: StrakeFengala
.
Page last modified on Tuesday 22 of February, 2011 15:38:11 UTC by StrakeFengala
.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.

