Skip to main content
GameDev.net gamedev.net
🔒 Locked

d3dlight attenuation

Started by tomek_zielinski Jul 9, 2004 at 1:11 PM 4 replies 900+ views
Original Post
tomek_zielinski
tomek_zielinski
Hey! I've got a quiestion about attenution - I understand basics but I couldn't get proper results... I want my light to be at full brightness in its position and totally black at D3DLIGHT8::Range, and to attenuate like x^2. So, are these proper settings: Attenuation0 = 0 Attenuation1 = 0 Attenuation2 = 1.0 no matter of what value Range is? thx in advance
www.tmreality.com
RenderTarget
RenderTarget
You won't be able to specify a smooth transition from 0 to 1 over 1/d^2, but you can get close. The range is just the cutoff distance, but 1/d^2 will never actually hit zero. By playing with att2, you can approach the range, but it's a matter of tweaking values that make things look right.
[sub]My spoon is too big.[/sub]
tomek_zielinski
tomek_zielinski
thanx, so it isn't possible to calculate exact attenuation factors?
www.tmreality.com
RenderTarget
RenderTarget
Well, yeah, do the math:

1 / (att0 + att1 * d + att2 * d2 )

What values of att0, att1, and att2 will bring that to zero? Only 0's for all of them, which of course would just turn the light off. For any other values (all of which have to be positive or zero), you'll never fall off to exactly zero. You can get close enough to look good, depending on the values and the range.
[sub]My spoon is too big.[/sub]
tomek_zielinski
tomek_zielinski
I've got lightmapped static world and dynamic character. And I want these characters to be lit comparably to objects in the world. Lightmapping uses quadratic attenuation:

(light_range^2 - dist_from_light_to-lumel^2)/(light_range^2)

and I would like to achieve similar effect with D3D lighting...

anyway, thx for the reply!
www.tmreality.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.