Lighting attenuation

Started by
4 comments, last by ArnoAtWork 19 years ago
Does a mathematical function exist to convert near/far plane of light to constant/linear/quadratic value?
Advertisement
Um, you mean the distance formula coupled with

1/(ConstAtten + LinAtten * Distance + QuadAtten * Distance^2)?
Exactly!

In 3DS file, light attenuation is given with inner and outer distance... So how to convert into opengl attenuation?
Wow, that's weird...anyways, I would wager a guess that inner refers to quadratic, and outer refers to linear.
I would guess that near and far refer to distances at which the light is K and 0, respectively, for some useful value of K (such as 255 or 1.0).

In the linear case, L(D) = a*D + b (L = light, D = distance)

K = a*near + b
0 = a*far + b

which solves to

a = K/(near-far)
b = -a*far

In the quadratic case L(D) = a/(D^2) + b*D (distance squared plus a linear term,;a reasonable guess)

K = a/(near^2) + b*near
0 = a/(far^2) + b*far

the solution is a litte more complex:

a = K/ [near * (1/near^3 + 1/far^3) ]
b = -a/(far^3)

Hope that gives you a good starting point.

Tom
"E-mail is for geeks and pedophiles." -Cruel Intentions
Hummm, in quadratic case it's not:

K = a*(near^2) + b*near
0 = a*(far^2) + b*far

rather than

K = a/(near^2) + b*near
0 = a/(far^2) + b*far

???



This topic is closed to new replies.

Advertisement