#### Archived

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

# How do i set Attenuation?

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

## Recommended Posts

i would like to have the light reflection from my object vary if the diastance from the object and the camera is greater. how do i do that, and how should i then set the attenuation?

##### Share on other sites

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 on other sites
is this correct?.

D3DLIGHT8 Light;

Light.Attenuation0 = 0.0f;
Light.Attenuation1 = 1.0f;
Light.Attenuation2 = 0.0f;

or do i have to calculate it with that formula u gave me?.

##### 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

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×