Jump to content
  • Advertisement

Archived

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

Funkodysse

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!