Lighting attenuation
Does a mathematical function exist to convert near/far plane of light to constant/linear/quadratic value?
Um, you mean the distance formula coupled with
1/(ConstAtten + LinAtten * Distance + QuadAtten * Distance^2)?
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement