Archived

This topic is now archived and is closed to further replies.

Funkodysse

How do i set Attenuation?

Recommended Posts


Try setting the:

float Attenuation0;
float Attenuation1;
float Attenuation2;

members of D3DLIGHT8 to:

0,1,0


Those describe the curve of the falloff over distance.

The Attenuation is:

A - 1/(att0 + att1*d + att2*d*d)

Where d is the distance.



--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
yes. That''s how you set the attenuation values.

The formula is what D3D does internally with those values. Knowing that it uses that particular formula, you can work out the attenuation curve which suits your needs the most.

It will only work if the rest of the light and material values are set up correctly though.


The 0,1,0 is simply linear falloff, plug the values into the formula:
A = 1/(0 + 1*d + 0*d*d)

Which is really just:

A = 1/(1*d)

or simply:

A= 1/d

Where d is the distance between the vertex and the light source.


D3D multiplies the intensity of the light by A to do the attenuation.



There is also a teeny mistake in what I posted - the minus should be an = sign:

A = 1/(att0 + att1*d + att2*d*d)




--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites