POV-Ray : Newsgroups : povray.advanced-users : The Mathematics Behind Spotlights Server Time
27 Dec 2024 06:13:04 EST (-0500)
  The Mathematics Behind Spotlights (Message 1 to 8 of 8)  
From: Captain Chemistry
Subject: The Mathematics Behind Spotlights
Date: 4 Dec 2004 15:50:00
Message: <web.41b222651545c117fe72e0f10@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).

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: Alain
Subject: Re: The Mathematics Behind Spotlights
Date: 4 Dec 2004 17:30:04
Message: <41b23a6c$1@news.povray.org>
Captain Chemistry nous apporta ses lumieres ainsi en ce 2004-12-04 
15:47... :

>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).
>
>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)
>
>
>  
>
What realy take long, is the media itself, not the spotlight. If the 
media is not important for the rest of your scene, try containing it in 
some invisible (rgbt 1) object like a cone slightly larger than the beam 
of your spotlight.
A problem with the method you describe: you don't get any light to shine 
on anything that the spotlight is suposed to light up, even with 
radiosity and media on.
Emiting madia is not faster than a scattering one, and solving your 
function will take some extra time making your scene longer to render.

Alain


Post a reply to this message

From: Captain Chemistry
Subject: Re: The Mathematics Behind Spotlights
Date: 5 Dec 2004 02:20:00
Message: <web.41b2b5bb329b38cf86cba9e10@news.povray.org>
Alain <aze### [at] qwertygov> wrote:
> What realy take long, is the media itself, not the spotlight. If the
> media is not important for the rest of your scene, try containing it in
> some invisible (rgbt 1) object like a cone slightly larger than the beam
> of your spotlight.
> A problem with the method you describe: you don't get any light to shine
> on anything that the spotlight is suposed to light up, even with
> radiosity and media on.
> Emiting madia is not faster than a scattering one, and solving your
> function will take some extra time making your scene longer to render.
>
> Alain

That's all sweeet -- I don't care about the emitting media "spotlight"
lighting up anything; I simply don't like scattering media because it is
too slow on my computer (and it is a A64 3000+ computer).

More to the point, I simply want to model what a spotlight does inside
scatting media and use that model in emitting media because emitting media
has less problems.

Some of these problems include:
* all hell breaks loose if you intersect two or more scattering media
containers (like the cones you suggested) - the brightness changes when it
shouldn't and this is not a problem with the quality of the media, it is a
problem with the scattering media itself. With emitting media you can
intersect as many containers as you like and it makes no difference because
WE ARE NOT TRACING THE PATH OF A SPOTLIGHT ANYMORE. *That* is the problem I
want to avoid (tracing the spotlight)

* it is hard (and render-time consuming) to get the quality of the media
good with spotlights shining through it

I do not care about the spotlight itself as a light; I only care about the
EFFECT that spotlight happens to have in scattering media. I can chuck 100
spotlights with media_interaction_off to light up the scene and it would
*still* take less time than some cheap scattering media!

Perhaps I am exaggerating but the above is a long description of why I want
to use emitting media...

(and I am still open to suggestions of how to model this spotlight!)


Post a reply to this message

From: Leonardo
Subject: Re: The Mathematics Behind Spotlights
Date: 5 Dec 2004 18:05:00
Message: <web.41b3920a329b38cf27bbadf50@news.povray.org>
"Captain Chemistry" <njj### [at] studentmonasheduau> wrote:
>
> 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).
>

Well... that might work, but you won't have any volumetric shadows, which is
the greatest thing in scattering media... :(


Post a reply to this message

From: Mike Raiford
Subject: Re: The Mathematics Behind Spotlights
Date: 6 Dec 2004 08:02:25
Message: <41b45861@news.povray.org>
Captain Chemistry wrote:
  > That's all sweeet -- I don't care about the emitting media "spotlight"
> lighting up anything; I simply don't like scattering media because it is
> too slow on my computer (and it is a A64 3000+ computer).

Big deal, there are lots of us here who use scattering media despite it 
being "too slow". My suggestion: If you're too impatient for raytracing, 
then don't do it. Generally, with careful containment of the media (As 
Alain suggested) and good selection of media parameters, a 
constant-density scattering media effect isn't all that slow. It may 
take 10 minutes or so to get  a desktop-sized image out of it, but 
that's not really a big deal. Instant picture generator a raytracer is not.

> More to the point, I simply want to model what a spotlight does inside
> scatting media and use that model in emitting media because emitting media
> has less problems.

Others have mentioned the deficiencies of this approach. Scattering 
media will model everything that happens when light interacts with it, 
including visible umbra of shadows, etc. Using a mathematical approach, 
you still cannot get the proper sampling of the light.

> Some of these problems include:
> * all hell breaks loose if you intersect two or more scattering media
> containers (like the cones you suggested) - the brightness changes when it
> shouldn't and this is not a problem with the quality of the media, it is a
> problem with the scattering media itself. With emitting media you can
> intersect as many containers as you like and it makes no difference because
> WE ARE NOT TRACING THE PATH OF A SPOTLIGHT ANYMORE. *That* is the problem I
> want to avoid (tracing the spotlight)

Why? Tracing a spotlight is trivial compared to sampling media. If 
you're concerned about the overlap problem there's two solutions: "If it 
hurts when you do that then don't do it", and use a merge. Problem 
solved. The inner edges are swallowed up when using a merge, and two: 
the merge itself would be the media container, not each individual cone.

> * it is hard (and render-time consuming) to get the quality of the media
> good with spotlights shining through it

All things equal its not that time consuming. Try media without a 
constant density, then whine about the amount of time it takes.

> I do not care about the spotlight itself as a light; I only care about the
> EFFECT that spotlight happens to have in scattering media. I can chuck 100
> spotlights with media_interaction_off to light up the scene and it would
> *still* take less time than some cheap scattering media!

Then use a cone, and f_cone as a density function for your emitting media.

> Perhaps I am exaggerating but the above is a long description of why I want
> to use emitting media...

It sounds to me like the above description was a justification for your 
whining.

> (and I am still open to suggestions of how to model this spotlight!)

Simple: Use a partially transparent cone can get reasonably close to 
looking like what you want. You don't even have to use emitting media, 
unless you want to.

I hate it when people ask for advice, then when they don't get the 
answer they want to hear they go on some long, drawn out diatribe about 
how they were right in the first place, and anyone who advises them are 
wrong.

-- 
~Mike


Post a reply to this message

From: Slime
Subject: Re: The Mathematics Behind Spotlights
Date: 6 Dec 2004 13:17:56
Message: <41b4a254$1@news.povray.org>
> Big deal, there are lots of us here who use scattering media despite it
> being "too slow". My suggestion: If you're too impatient for raytracing,
> then don't do it.

Now, hold on. He has good reasons for wanting to use emitting media instead
of scattering. One of those reasons is speed, to which your only argument
seems to be "it's not that bad" or "it could be worse." Well, he's looked at
the tradeoff between speed and quality/accuracy of his two options, and he's
made a choice. Personally, I think it's a very reasonable choice. I also
agree with him on the difficulty of getting spotlights to look nice in
scattering media.

> I hate it when people ask for advice, then when they don't get the
> answer they want to hear they go on some long, drawn out diatribe about
> how they were right in the first place, and anyone who advises them are
> wrong.

He didn't ask for advice on what type of media to use. He asked for help on
writing a function to describe the light cone of a spotlight. When
challenged on his choice of media types, he gave an explanation for his
decision. It's not something we need to get hostile about.

It's fine to encourage him to reconsider, but this isn't a case of right or
wrong.

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


Post a reply to this message

From: Mike Raiford
Subject: Re: The Mathematics Behind Spotlights
Date: 6 Dec 2004 13:56:06
Message: <41b4ab46$1@news.povray.org>
Slime wrote:

>>Big deal, there are lots of us here who use scattering media despite it
>>being "too slow". My suggestion: If you're too impatient for raytracing,
>>then don't do it.
> 
> 
> Now, hold on. He has good reasons for wanting to use emitting media instead
> of scattering. One of those reasons is speed, to which your only argument
> seems to be "it's not that bad" or "it could be worse." Well, he's looked at
> the tradeoff between speed and quality/accuracy of his two options, and he's
> made a choice. Personally, I think it's a very reasonable choice. I also
> agree with him on the difficulty of getting spotlights to look nice in
> scattering media.
> 
> 
>>I hate it when people ask for advice, then when they don't get the
>>answer they want to hear they go on some long, drawn out diatribe about
>>how they were right in the first place, and anyone who advises them are
>>wrong.
> 
> 
> He didn't ask for advice on what type of media to use. He asked for help on
> writing a function to describe the light cone of a spotlight. When
> challenged on his choice of media types, he gave an explanation for his
> decision. It's not something we need to get hostile about.
> 
> It's fine to encourage him to reconsider, but this isn't a case of right or
> wrong.

Hmm. I may have jumped the gun, there.

... I do think my suggestion of f_cone with an appropriate density map 
would get him where he needs to be, though. The math behind it escapes 
me at the moment, though to get an exact representation given the 
parameters.

-- 
~Mike


Post a reply to this message

From: Captain Chemistry
Subject: Re: The Mathematics Behind Spotlights
Date: 7 Dec 2004 02:05:00
Message: <web.41b555d9329b38cf301d03a70@news.povray.org>
Mike Raiford <mra### [at] hotmailcom> wrote:
> Slime wrote:
>
> >>Big deal, there are lots of us here who use scattering media despite it
> >>being "too slow". My suggestion: If you're too impatient for raytracing,
> >>then don't do it.
> >
> >
> > Now, hold on. He has good reasons for wanting to use emitting media instead
> > of scattering. One of those reasons is speed, to which your only argument
> > seems to be "it's not that bad" or "it could be worse." Well, he's looked at
> > the tradeoff between speed and quality/accuracy of his two options, and he's
> > made a choice. Personally, I think it's a very reasonable choice. I also
> > agree with him on the difficulty of getting spotlights to look nice in
> > scattering media.
> >
> >
> >>I hate it when people ask for advice, then when they don't get the
> >>answer they want to hear they go on some long, drawn out diatribe about
> >>how they were right in the first place, and anyone who advises them are
> >>wrong.
> >
> >
> > He didn't ask for advice on what type of media to use. He asked for help on
> > writing a function to describe the light cone of a spotlight. When
> > challenged on his choice of media types, he gave an explanation for his
> > decision. It's not something we need to get hostile about.
> >
> > It's fine to encourage him to reconsider, but this isn't a case of right or
> > wrong.
>
> Hmm. I may have jumped the gun, there.
>
> ... I do think my suggestion of f_cone with an appropriate density map
> would get him where he needs to be, though. The math behind it escapes
> me at the moment, though to get an exact representation given the
> parameters.
>
> --
> ~Mike



Mike, you're right.
Slime, you're also right.

I needed to hear the "hostility" from Mike and be put in my place.
Scattering media IS good and if I didn't have the patience for raytracing,
I wouldn't have been doing it for the past 5 short years.

I just like to get the exact effects I need (or think I need) and nothing
else, and scattering media happens to give more than I needed, that's all.

The f_cone suggestion is good, and I think it's function is
val=1-min(y,sqrt(x*x+z*z))/y or something (I got it working before) but it
doesn't cut it.

There simply is no substitute for scattering media and you're also right
about merging two (or more) cone containers.

Basically, you helped me in quite a few ways so thankyou and please continue
to have a slightly scathing attitude because it actually tells people what
they need to hear.

Raytracing is Good!

Nathan


Post a reply to this message

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