# radius and brightness, how to attenuate?

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

## Recommended Posts

Hi. After stuying the OpenGL lighting attenuation formula, and with help on the OpenGL forum I found out how it works. Now there's another problem, I want to calculate the 3 attenuation values: CONSTANT, LINEAR and QUADRATICAL, from 3 user input values: RADIUS, BRIGHTNESS NEAR POSITION, BRIGHTNESS HALFWAY. Radius is the distance from where the brightness should be 0,0. Brightness is the maximum brightness near the light's position. Brightness halfway is the brightness halfway the position and max. radius. This is the correct openGL formula: 1.0 / (constant+linear*d + quadratic*d*d) Now for example I want a positional lightsource with: - radius = 10 - brightness = 10 - brightness halfway = 5 Can someone explain too me how I can make a working formula to calculate this? (I tried lots of things using excel, but it just doesn't work) Thanks in advance.

##### Share on other sites
The attenuation factor will never reach zero. It approaches zero as d approaches infinity. So technically, every light always have an infinite radius, it just reaches an low enough value at some point to not have any effect the scene.

##### Share on other sites
As Brother Bob said.

Practically,
Solve that
for d
(accurate for non-HDR)

In general case, you can use,
where minimal_brightness_you_care_about may be 1/256 or 1/128, etc.

##### Share on other sites
If you have 3 brightness values (b0, b1, b2) at 3 distances (d0, d1, d2), you basically have a system of three equations with three unknowns (c0, c1, c2):
b0 = 1/( c0 + c1d0 + c2d02 )b1 = 1/( c0 + c1d1 + c2d12 )b2 = 1/( c0 + c1d2 + c2d22 )
or:
c0 + c1d0 + c2d02 = 1/b0c0 + c1d1 + c2d12 = 1/b1c0 + c1d2 + c2d22 = 1/b2
or in matrix form:
| 1 d0 d02 | | c0 |   | 1/b0 || 1 d1 d12 | | c1 | = | 1/b1 || 1 d2 d22 | | c2 |   | 1/b2 |

Solve by standard methods.

1. 1
2. 2
3. 3
4. 4
frob
12
5. 5

• 16
• 13
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632172
• Total Posts
3004563

×