0

Basically I want f(x, min, max) = $\frac{1}{x*x}$ between min and max. I'm trying to make a light whose intensity falls off with 1 over the distance squared. It seems to have the following intensity when I do $1$ over distance square:

$0 = \infty $

$1 = 1 $

$4 = \dfrac 1{16} $

$8 = \dfrac 1{64} $

But I want to have an attenuation radius so that its least intensity is at the edge of the radius (0) and 1 at the centre.

I'm having trouble with this, and I think it may be because 1 / distance square is an asymptotic curve that I'm trying to map to 0(no light) to 1(maximum light). It makes less sense the more I think about it, I'm trying to map one set of values with no limits on either end to 0 and 1.

user577215664
  • 40,625
Zebrafish
  • 325
  • 1
    I think I understand your question, although you haven't made it easy. You want a function $f:[0,r]\to\Bbb R$ with $f(0)=1$ and $f(r)=0$, that is "kind of" inverse quadratic. Is this a fair summary? (BTW, is this for a video game, or what?) – TonyK Oct 07 '20 at 14:02
  • @TonyK Hi, yes, that's exactly right, I'm making light with OpenGL. One way I've seen a tutorial do it is have: 1 / (k * distance x distance), with k controlling how fast the falloff is. I guess the k constant controls the attenuation, but it's not a set radius. To find the radius I guess I could find what distance results in a really low value close to zero. IT's just I had mind the ability to set the radius for the light. – Zebrafish Oct 07 '20 at 14:40

0 Answers0