Attenuation and scale problems.

Apr 16, 2011 at 7:40 PM
Edited Jun 1, 2011 at 10:24 PM

I love the fact that xnanimation includes specular and normal map options.  Seriously, it's a godsend. 

One thing that's been confusing to me is how the units I put in for the light position seem to be different than the model units.  For instance, if you go to the Attach Model sample and move the gun sideways (x) by 10 then it's about a body's length away from the character.  But to move the light from the characters feet to his head only appears to be about 1 (I'm just going by visual approximation there).  It's almost as if the light position is a percentage of the model size and not an actual position in space?

Essentially I'm trying to find a way to add attenuation.  I've added a float called falloff to the pointLight class and everything, but in the HLSL I'm having trouble calculating it correctly.  The inPosition value in the pixel shader seems to describe the position on the map, not the world space.  So I'm not sure how to check the distance between a pixel and a light.

Any help appreciated.

May 30, 2011 at 8:04 AM
Edited May 31, 2011 at 10:58 PM