POV-Ray : Newsgroups : povray.general : spherical light math help ... Server Time
31 Oct 2024 21:23:59 EDT (-0400)
  spherical light math help ... (Message 1 to 10 of 10)  
From: Paul Vanukoff
Subject: spherical light math help ...
Date: 7 Jan 2000 12:02:20
Message: <38761c1c@news.povray.org>
I am working on a spherical light, so far it looks something like this:

#declare STEP=0.2;

#declare M=-1;
#while (M<=1)
    #declare N=-1;
    #while (N<=1)
        #declare O=-1;
        #while (O<=1)

            #if ( (M*M+N*N+O*O) <= 1 )
                light_source
                {
                    < M, N, O> color White/DIVISOR
                }
            #end
        #declare O=O+STEP;
        #end
    #declare N=N+STEP;
    #end
#declare M=M+STEP;
#end

Only problem is, I don't know what to set DIVISOR to, in order for the
overall brightness to equal that of a single light_source.  I know it has
something to do with the volume of a sphere, and the value of STEP. Does
anyone know what formula to use?

--
Paul Vanukoff
van### [at] primenetcom


Post a reply to this message

From: Chris Huff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 12:45:49
Message: <chrishuff_99-2957B8.12455907012000@news.povray.org>
In article <38761c1c@news.povray.org>, "Paul Vanukoff" 
<van### [at] primenetcom> wrote:

> I am working on a spherical light, so far it looks something like this:
> 
> #declare STEP=0.2;
> 
> #declare M=-1;
> #while (M<=1)
>     #declare N=-1;
>     #while (N<=1)
>         #declare O=-1;
>         #while (O<=1)
> 
>             #if ( (M*M+N*N+O*O) <= 1 )
>                 light_source
>                 {
>                     < M, N, O> color White/DIVISOR
>                 }
>             #end
>         #declare O=O+STEP;
>         #end
>     #declare N=N+STEP;
>     #end
> #declare M=M+STEP;
> #end
> 
> Only problem is, I don't know what to set DIVISOR to, in order for the
> overall brightness to equal that of a single light_source.  I know it has
> something to do with the volume of a sphere, and the value of STEP. Does
> anyone know what formula to use?

Hmm, is this a spherical area light? I had planned on making a macro for 
this someday, I never got around to it. I would use a slightly different 
way of doing it, though.
There is a patch in MegaPOV that does something similar(circular area 
lights and reorienting area lights), and you might want to ask in 
povray.advanced-users for more help, since this seems to be a math 
question. I will look at this code later and see what I can do.

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Chris Huff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 12:53:21
Message: <chrishuff_99-2D8216.12533107012000@news.povray.org>
In article <38762474@news.povray.org>, "Lance Birch" 
<lan### [at] usanet> wrote:

> But what you've got there isn't spherical in the first place is it?

Not completely spherical, but the line
            #if ( (M*M+N*N+O*O) <= 1 )
makes sure all of the light sources are within the sphere.

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Lance Birch
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 12:55:08
Message: <3876287c@news.povray.org>
I realised that shortly after posting and cancelled the message :)

--
Lance.
The Zone - http://come.to/the.zone
Chris Huff <chr### [at] yahoocom> wrote in message
news:chrishuff_99-2D8216.12533107012000@news.povray.org...
> In article <38762474@news.povray.org>, "Lance Birch"
> <lan### [at] usanet> wrote:
>
> > But what you've got there isn't spherical in the first place is it?
>
> Not completely spherical, but the line
>             #if ( (M*M+N*N+O*O) <= 1 )
> makes sure all of the light sources are within the sphere.
>
> --
> Chris Huff
> e-mail: chr### [at] yahoocom
> Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Chris Huff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 13:22:32
Message: <chrishuff_99-F7EACC.13224207012000@news.povray.org>
I don't know how to solve that problem, other than storing all the 
possible positions in an array and counting the ones inside the sphere. 
So here is an alternate method:

#declare rsA = seed(7892983);
#macro SphereLight(SourceNum, Center, Rad, Color)
   #local J=0;
   #while(J<SourceNum)
      #local Pos = < rand(rsA)*2*Rad - Rad,
               rand(rsA)*2*Rad - Rad,
               rand(rsA)*2*Rad - Rad>;
      #if(vlength(Pos)<=Rad)
         light_source {Pos color Color/SourceNum translate Center}
         #local J=J+1;
      #end
   #end
#end

The light sources are placed randomly inside the sphere, which makes any 
patterns or banding less visible. Be careful, though, large numbers of 
light sources can really slow things. I tested it with this little scene:

#include "colors.inc"
camera {
   location <-3, 5, -8>
   look_at < 0, 0, 0>
   angle 35
}

#declare T_Green = texture {pigment {color Green}}

SphereLight(100, < 0, 5, 0>, 1, White)

sphere {< 0, 1, 0>, 1
   texture {T_Green} 
}
box {<-100, 0,-100>, < 100, 0, 100>
   pigment {color Gray80}
}

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Paul Vanukoff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 13:28:25
Message: <38763049@news.povray.org>
That's pretty cool ... a lot better than my idea ... thanks!

--
Paul Vanukoff
van### [at] primenetcom


Chris Huff wrote in message ...
>I don't know how to solve that problem, other than storing all the
>possible positions in an array and counting the ones inside the sphere.
>So here is an alternate method:

[... snipped ...]


Post a reply to this message

From: mskjmhag
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 16:02:39
Message: <3876546f@news.povray.org>
Another method... if you can deal with a slight increase in parse time.  Take the code
you have and copy it so it appears twice in a
row.  Then take the first occurance and change it like this (I commented the "ADDED"
lines to show which ones they were):

#declare STEP=0.2;

#declare NumLights = 0;  // ADDED

#declare M=-1;
#while (M<=1)
    #declare N=-1;
    #while (N<=1)
        #declare O=-1;
        #while (O<=1)
            #declare NumLights  = NumLights + 1; // ADDED
            #declare O=O+STEP;
        #end
    #declare N=N+STEP;
    #end
#declare M=M+STEP;
#end

Then you can divide by NumLights.  Just make sure STEP is the same in both sets of
loops.

-Slime

Paul Vanukoff <van### [at] primenetcom> wrote in message
news:38761c1c@news.povray.org...
>
> I am working on a spherical light, so far it looks something like this:
>
> #declare STEP=0.2;
>
> #declare M=-1;
> #while (M<=1)
>     #declare N=-1;
>     #while (N<=1)
>         #declare O=-1;
>         #while (O<=1)
>
>             #if ( (M*M+N*N+O*O) <= 1 )
>                 light_source
>                 {
>                     < M, N, O> color White/DIVISOR
>                 }
>             #end
>         #declare O=O+STEP;
>         #end
>     #declare N=N+STEP;
>     #end
> #declare M=M+STEP;
> #end
>
> Only problem is, I don't know what to set DIVISOR to, in order for the
> overall brightness to equal that of a single light_source.  I know it has
> something to do with the volume of a sphere, and the value of STEP. Does
> anyone know what formula to use?
>
> --
> Paul Vanukoff
> van### [at] primenetcom
>
>
>
>


Post a reply to this message

From: Chris Huff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 16:18:01
Message: <chrishuff_99-11B8FA.16181107012000@news.povray.org>
In article <3876546f@news.povray.org>, <msk### [at] msncom> wrote:

> Another method... if you can deal with a slight increase in parse time.  
> Take the code you have and copy it so it appears twice in a
> row.  Then take the first occurance and change it like this (I commented 
> the "ADDED" lines to show which ones they were):
> 
> #declare STEP=0.2;
> 
> #declare NumLights = 0;  // ADDED
> 
> #declare M=-1;
> #while (M<=1)
>     #declare N=-1;
>     #while (N<=1)
>         #declare O=-1;
>         #while (O<=1)
>             #declare NumLights  = NumLights + 1; // ADDED
>             #declare O=O+STEP;
>         #end
>     #declare N=N+STEP;
>     #end
> #declare M=M+STEP;
> #end
> 
> Then you can divide by NumLights.  Just make sure STEP is the same in 
> both sets of loops.

That won't work, you have to increment NumLights only for those 
positions inside the sphere:

#declare M=-1;
#while (M<=1)
    #declare N=-1;
    #while (N<=1)
        #declare O=-1;
        #while (O<=1)
            #if (vlength(<M,N,O>) <= 1 )
                #declare NumLights  = NumLights + 1;
            #end
            #declare O=O+STEP;
        #end
        #declare N=N+STEP;
    #end
    #declare M=M+STEP;
#end

Then you can use NumLights as the divider in the loop that places the 
lights.

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Paul Vanukoff
Subject: Re: spherical light math help ...
Date: 7 Jan 2000 17:57:28
Message: <38766f58@news.povray.org>
Now why didn't I think of that .. it's so simple, it just might work! :)
Thanks!

--
Paul Vanukoff
van### [at] primenetcom


Chris Huff wrote in message ...
>In article <3876546f@news.povray.org>, <msk### [at] msncom> wrote:
>
>> Another method... if you can deal with a slight increase in parse time.
>> Take the code you have and copy it so it appears twice in a
>> row.  Then take the first occurance and change it like this (I commented
>> the "ADDED" lines to show which ones they were):
>>
>> #declare STEP=0.2;
>>
>> #declare NumLights = 0;  // ADDED
>>
>> #declare M=-1;
>> #while (M<=1)
>>     #declare N=-1;
>>     #while (N<=1)
>>         #declare O=-1;
>>         #while (O<=1)
>>             #declare NumLights  = NumLights + 1; // ADDED
>>             #declare O=O+STEP;
>>         #end
>>     #declare N=N+STEP;
>>     #end
>> #declare M=M+STEP;
>> #end
>>
>> Then you can divide by NumLights.  Just make sure STEP is the same in
>> both sets of loops.
>
>That won't work, you have to increment NumLights only for those
>positions inside the sphere:
>
>#declare M=-1;
>#while (M<=1)
>    #declare N=-1;
>    #while (N<=1)
>        #declare O=-1;
>        #while (O<=1)
>            #if (vlength(<M,N,O>) <= 1 )
>                #declare NumLights  = NumLights + 1;
>            #end
>            #declare O=O+STEP;
>        #end
>        #declare N=N+STEP;
>    #end
>    #declare M=M+STEP;
>#end
>
>Then you can use NumLights as the divider in the loop that places the
>lights.
>
>--
>Chris Huff
>e-mail: chr### [at] yahoocom
>Web page: http://chrishuff.dhs.org/


Post a reply to this message

From: Robert Dawson
Subject: Re: spherical light math help ...
Date: 10 Jan 2000 08:55:42
Message: <3879e4de@news.povray.org>
Paul Vanukoff <van### [at] primenetcom> wrote in message
news:38761c1c@news.povray.org...
>
> I am working on a spherical light, so far it looks something like this:
>
> #declare STEP=0.2;
>
> #declare M=-1;
> #while (M<=1)
>     #declare N=-1;
>     #while (N<=1)
>         #declare O=-1;
>         #while (O<=1)
>
>             #if ( (M*M+N*N+O*O) <= 1 )
>                 light_source
>                 {
>                     < M, N, O> color White/DIVISOR
>                 }
>             #end
>         #declare O=O+STEP;
>         #end
>     #declare N=N+STEP;
>     #end
> #declare M=M+STEP;
> #end


    Might I suggest something? Firstly, the existing adaptive area-light
saves greatly on number of sources for a given quality; I believe the
circular area light implements this
too.  Secondly, the eye does not infer details of light shape well from
illumination except in unusual cases such as a pinhole camera (that's why
you cannot look *away* from a partial eclipse of the sun & see what's
happening.) And, thirdly, with this scheme the number of point lights grows
with the cube of the linear density.  Sloooooooow.   Could you use two or
three area lights,one in the xy plane, one in the yz plane, and one in the
xz plane - or a circular light "trained" via a macro to follow the camera -
to get the same effect?

    -Robert Dawson


Post a reply to this message

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