3
\$\begingroup\$

In my (UE4) scene I have an object and several (point) light sources. The object can move around, getting closer and away from all those light sources. Now I need to calculate for each light source how much it affects the object at its current position (i.e. distance from the light).

Every light source has three important values:

  • Intensity: How bright the light shines (integer vlaue 0..10000)
  • Attenuation: Radius around light, how far it visibly influences the scene
  • Falloff exponent: Radial falloff around light (inverse squared by default, or can be an integer between 2 and 8)

Now, depending on how far the object is from a light source, it is more or less affected by the light. If the object is outside the attenuation radius, it is not affected at all by the light. I am not so much interested in the light intensity, but more in the distance between the object and a light.

For each light I am interested in a value between 0 and 1. So the easy way would be to simply calc: 1 - distance / attenuation. But I would like to take the falloff exponent into account. Any ideas how to accomplish that?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Take a look at a few of these and see if they match what you're looking for. I let attenuation = 10 for the purpose of demonstrating, but you should play around with all the numbers involved. WolframAlpha is very good at visualizing this sort of thing.

Keep in mind, negative exponents probably are not what you're looking for. Inverse squares, or negative exponents of any magnitude, will produce asymptotic functions.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks, but your link is broken :-( \$\endgroup\$
    – Matthias
    Aug 16, 2015 at 23:51
  • \$\begingroup\$ Sorry about that, should be fixed now I think. \$\endgroup\$ Aug 17, 2015 at 1:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .