POV-Ray : Newsgroups : povray.newusers : The Mathematics Behind Spotlights Server Time
30 Jul 2024 02:26:13 EDT (-0400)
  The Mathematics Behind Spotlights (Message 1 to 3 of 3)  
From: Captain Chemistry
Subject: The Mathematics Behind Spotlights
Date: 4 Dec 2004 16:30:00
Message: <web.41b22c441545c1176fa80cd40@news.povray.org>
I am interested in exactly how spotlights work.

If you chuck a spotlight through some scattering media you get a nice effect
but it takes ages.

What if I told you that the SAME EFFECT could be obtained by creating some
functions that *simulate* spotlight intensity at all points in it's cone
and then using those functions in some EMITTING media which can be maybe
100 times faster than scattering media in a slightly detailed image (no
joke).

You can express any 3D function as a pattern and then chuck that pattern in
a deinsity{} section in a media{} block.

For the following functions I assume the spotlight points up in the positive
y direction and starts as a point at the origin.

At this point, I need to know several functions:
* a 3D function to assign a value between 0 and 1 for all points in a
spotlight cone given these parameters: radius, falloff, tightness

* a light fading function. This is (i think) in the pov documentation so
that's not as important.

I am mainly interested in the first function. At all points in the radius
cone (where the angle between the point and the y axis is less than the
"radius") the light intensity multiplier is 1.

At all points in the falloff section the light intensity multiplier falls
off from 1 and reaches zero by the time the angle reaches "falloff"
degrees.

I am guessing that there is an exponential decay here (something like an
s-bend thing) but the documentation doesn't go into the actual formula.

I should like to know that formula.

If anyone could help (even dudes on the pov-team that made this stuff) I
would be very grateful.

Nathan Jolly (Captain Chemistry)


Post a reply to this message

From: Slime
Subject: Re: The Mathematics Behind Spotlights
Date: 4 Dec 2004 17:34:56
Message: <41b23b90$1@news.povray.org>
> What if I told you that the SAME EFFECT could be obtained by creating some
> functions that *simulate* spotlight intensity at all points in it's cone
> and then using those functions in some EMITTING media which can be maybe
> 100 times faster than scattering media in a slightly detailed image (no
> joke).

This is a trick that I use fairly often to create media lighting effects.
There is, however, one crucial difference: the lack of shadows. Not just
shadows of objects, but self-shadowing of the media. In a dense scattering
media, you'll notice that parts farther away from the light are darker
because they are shadowed by the media closer to the light. That effect
doesn't happen with emitting media. If you're willing to live with this (and
often that's not a problem for me), then the shortcut is fine.

This is probably the biggest reason for the slowness of scattering media;
each sample (and there are many samples for each ray), requires a shadow ray
which also takes a number of samples.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Captain Chemistry
Subject: Re: The Mathematics Behind Spotlights
Date: 4 Dec 2004 23:35:00
Message: <web.41b28f31329b38cf9db93570@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> ... you'll notice that parts farther away from the light are darker
> because they are shadowed by the media closer to the light. That effect
> doesn't happen with emitting media. If you're willing to live with this (and
> often that's not a problem for me), then the shortcut is fine.

Yes, I don't believe I care about that and I think the use of "extinction 0"
in the scattering section turns that wonderful feature off anyway...?

> This is a trick that I use fairly often to create media lighting effects.

That sounds great!!!!

Now how would you go about doing that? I want the emitting media to look
exacly like a spotlight would in scattering media and I would even like to
have parameters like "radius", "falloff", and "tightness".

I would love to hear any suggestions on how to make this happen!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.