POV-Ray : Newsgroups : povray.general : Rays path Length Server Time
29 Mar 2024 08:35:09 EDT (-0400)
  Rays path Length (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
From: Motive17
Subject: Re: Rays path Length
Date: 10 Jan 2018 08:50:01
Message: <web.5a561958f3020183e278d3b70@news.povray.org>
"Kontemplator" <haf### [at] yahoocom> wrote:
> "Motive17" <nomail@nomail> wrote:
> > Simple question:
> >
> > do you know if there is a way for extracting the length of the rays path from
> > the light source until the camera?
> >
> > Thank you in advance
> >
> > Best regards
>
> try:
>
> vlength(V)
> Length of V. Returns a float value that is the length of vector V. Formula is
> vlength=sqrt(vdot(A,A)). Can be used to compute the distance between two points.
> Dist=vlength(V2-V1).

Yes, you are right, I know this tool but I'd want the length of the entire ray
path hitting an object of the scene.


Post a reply to this message

From: clipka
Subject: Re: Rays path Length
Date: 10 Jan 2018 10:48:51
Message: <5a5635e3$1@news.povray.org>
Am 10.01.2018 um 12:18 schrieb Motive17:
> Simple question:
> 
> do you know if there is a way for extracting the length of the rays path from
> the light source until the camera?

If there is only one light source involved, you /could/ use a special
pigment for the objects in your scene that sums up the distance between
the surface and the camera plus the distance between the surface and the
light source.

Use a function-based pigment, with a function constructed like this:

    #declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
    #declare Fn = function(x,y,z) {
        FnDist(x-xC,y-yC,z-zC) +
        FnDist(x-xL,y-yL,z-zL)
    }
    #declare P = pigment {
        function { Fn(x,y,z)/MaxDistance }
    }

where <xC,yC,zC> is the location of the camera, <xL,yL,zL> is the
location of the light source, and MaxDistance is the maximum total
distance you want to be able to handle properly.

Then choose a finish that gives full brightness whenever the surface is
illuminated (regardless of incident light angle):

    finish { ambient 0 diffuse 1 brilliance 0 }

Finally, set up the light source to have no distance-based attenuation
(i.e. use `fade_power 0`).


This should give you an output image where the brightness of each pixel
corresponds to the distance the light ray has travelled.


Make sure to use a high bit depth for the output image, and either use
linear encoding (`File_Gamma=1`) or be aware that your pixel values will
not correspond linearly to distance travelled.


Post a reply to this message

From: Motive17
Subject: Re: Rays path Length
Date: 12 Jan 2018 08:55:01
Message: <web.5a58bdc7f3020183e278d3b70@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 10.01.2018 um 12:18 schrieb Motive17:
> > Simple question:
> >
> > do you know if there is a way for extracting the length of the rays path from
> > the light source until the camera?
>
> If there is only one light source involved, you /could/ use a special
> pigment for the objects in your scene that sums up the distance between
> the surface and the camera plus the distance between the surface and the
> light source.
>
> Use a function-based pigment, with a function constructed like this:
>
>     #declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
>     #declare Fn = function(x,y,z) {
>         FnDist(x-xC,y-yC,z-zC) +
>         FnDist(x-xL,y-yL,z-zL)
>     }
>     #declare P = pigment {
>         function { Fn(x,y,z)/MaxDistance }
>     }
>
> where <xC,yC,zC> is the location of the camera, <xL,yL,zL> is the
> location of the light source, and MaxDistance is the maximum total
> distance you want to be able to handle properly.
>
> Then choose a finish that gives full brightness whenever the surface is
> illuminated (regardless of incident light angle):
>
>     finish { ambient 0 diffuse 1 brilliance 0 }
>
> Finally, set up the light source to have no distance-based attenuation
> (i.e. use `fade_power 0`).
>
>
> This should give you an output image where the brightness of each pixel
> corresponds to the distance the light ray has travelled.
>
>
> Make sure to use a high bit depth for the output image, and either use
> linear encoding (`File_Gamma=1`) or be aware that your pixel values will
> not correspond linearly to distance travelled.


Thank you for the reply. This could be a very interesting approach.

Maybe a trivial question but...about the values x,y,z in the definition of the
function Fn:

 Fn = function(x,y,z) {
         FnDist(x-xC,y-yC,z-zC) +
         FnDist(x-xL,y-yL,z-zL)

what do they represent for POV-ray?

I was thinking I could introduce a such function directly as a light attenuation
function in the definition of light source.

What do you think about?


Post a reply to this message

From: Bald Eagle
Subject: Re: Rays path Length
Date: 12 Jan 2018 10:05:01
Message: <web.5a58ce75f3020183c437ac910@news.povray.org>
"Motive17" <nomail@nomail> wrote:
> clipka <ano### [at] anonymousorg> wrote:

> Thank you for the reply. This could be a very interesting approach.
>
> Maybe a trivial question but...about the values x,y,z in the definition of the
> function Fn:
>
>  Fn = function(x,y,z) {
>          FnDist(x-xC,y-yC,z-zC) +
>          FnDist(x-xL,y-yL,z-zL)
>
> what do they represent for POV-ray?

They are the x,y, and z values of the point in space that POV-Ray is evaluating
the function for.

"By default a function takes three parameters and you do not have to explicitly
specify the parameter names. The default three parameters are x, y and z. For
example:

 #declare foo = function { x + y * z }

If you need fewer or more parameters you have to explicitly specify the
parameter list."


Post a reply to this message

From: clipka
Subject: Re: Rays path Length
Date: 12 Jan 2018 12:41:29
Message: <5a58f349@news.povray.org>
Am 12.01.2018 um 14:53 schrieb Motive17:

> Maybe a trivial question but...about the values x,y,z in the definition of the
> function Fn:
> 
>  Fn = function(x,y,z) {
>          FnDist(x-xC,y-yC,z-zC) +
>          FnDist(x-xL,y-yL,z-zL)
> 
> what do they represent for POV-ray?

They represent the x, y and z coordinates for whatever point the pigment
based on the funciton is evaluated for.


> I was thinking I could introduce a such function directly as a light attenuation
> function in the definition of light source.
> 
> What do you think about?

That wouldn't fly: The distance-based attenuation of light sources only
affects the brightness based on the distance between the light source
and the surface. The distance between the surface and the camera isn't
affecting the brightness at all.


Post a reply to this message

From: Alain
Subject: Re: Rays path Length
Date: 12 Jan 2018 16:20:11
Message: <5a59268b@news.povray.org>
Le 18-01-12 à 08:53, Motive17 a écrit :
> clipka <ano### [at] anonymousorg> wrote:
>> Am 10.01.2018 um 12:18 schrieb Motive17:
>>> Simple question:
>>>
>>> do you know if there is a way for extracting the length of the rays path from
>>> the light source until the camera?
>>
>> If there is only one light source involved, you /could/ use a special
>> pigment for the objects in your scene that sums up the distance between
>> the surface and the camera plus the distance between the surface and the
>> light source.
>>
>> Use a function-based pigment, with a function constructed like this:
>>
>>      #declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
>>      #declare Fn = function(x,y,z) {
>>          FnDist(x-xC,y-yC,z-zC) +
>>          FnDist(x-xL,y-yL,z-zL)
>>      }
>>      #declare P = pigment {
>>          function { Fn(x,y,z)/MaxDistance }
>>      }
>>
>> where <xC,yC,zC> is the location of the camera, <xL,yL,zL> is the
>> location of the light source, and MaxDistance is the maximum total
>> distance you want to be able to handle properly.
>>
>> Then choose a finish that gives full brightness whenever the surface is
>> illuminated (regardless of incident light angle):
>>
>>      finish { ambient 0 diffuse 1 brilliance 0 }
>>
>> Finally, set up the light source to have no distance-based attenuation
>> (i.e. use `fade_power 0`).
>>
>>
>> This should give you an output image where the brightness of each pixel
>> corresponds to the distance the light ray has travelled.
>>
>>
>> Make sure to use a high bit depth for the output image, and either use
>> linear encoding (`File_Gamma=1`) or be aware that your pixel values will
>> not correspond linearly to distance travelled.
> 
> 
> Thank you for the reply. This could be a very interesting approach.
> 
> Maybe a trivial question but...about the values x,y,z in the definition of the
> function Fn:
> 
>   Fn = function(x,y,z) {
>           FnDist(x-xC,y-yC,z-zC) +
>           FnDist(x-xL,y-yL,z-zL)
> 
> what do they represent for POV-ray?
> 
> I was thinking I could introduce a such function directly as a light attenuation
> function in the definition of light source.
> 
> What do you think about?
> 
> 

The x, y, z are world centric, with the point <0,0,0> as the origin.
When evaluating a function, for say, an isosurface or a pigment, it's 
the current point been tested.


Post a reply to this message

From: Motive17
Subject: Re: Rays path Length
Date: 15 Jan 2018 06:30:00
Message: <web.5a5c9064f3020183e278d3b70@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 12.01.2018 um 14:53 schrieb Motive17:
>
> > Maybe a trivial question but...about the values x,y,z in the definition of the
> > function Fn:
> >
> >  Fn = function(x,y,z) {
> >          FnDist(x-xC,y-yC,z-zC) +
> >          FnDist(x-xL,y-yL,z-zL)
> >
> > what do they represent for POV-ray?
>
> They represent the x, y and z coordinates for whatever point the pigment
> based on the funciton is evaluated for.
>
>
> > I was thinking I could introduce a such function directly as a light attenuation
> > function in the definition of light source.
> >
> > What do you think about?
>
> That wouldn't fly: The distance-based attenuation of light sources only
> affects the brightness based on the distance between the light source
> and the surface. The distance between the surface and the camera isn't
> affecting the brightness at all.

In order to be more clear I'll write down some details...

I was thinking to define this function, based on your advices :

#declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
#declare  Fn = function(x,y,z) {
          FnDist(x-xC,y-yC,z-zC) +
          FnDist(x-xL,y-yL,z-zL)
                               }
l
ight_source {
                 <0,0,0>
                 color rgb <255,255,255>*1/Fn
                 fade_distance 1
                 fade_power 0
                 media_interaction off
                 media_attenuation off
                }

Unlickely, It doesn't fly.
I did not understand which is the reason in this case.
I cannot define a function in the definition of light source?


Post a reply to this message

From: Motive17
Subject: Re: Rays path Length
Date: 15 Jan 2018 08:20:01
Message: <web.5a5ca96cf3020183e278d3b70@news.povray.org>
Alain <kua### [at] videotronca> wrote:
> Le 18-01-12 à 08:53, Motive17 a écrit :
> > clipka <ano### [at] anonymousorg> wrote:
> >> Am 10.01.2018 um 12:18 schrieb Motive17:
> >>> Simple question:
> >>>
> >>> do you know if there is a way for extracting the length of the rays path from
> >>> the light source until the camera?
> >>
> >> If there is only one light source involved, you /could/ use a special
> >> pigment for the objects in your scene that sums up the distance between
> >> the surface and the camera plus the distance between the surface and the
> >> light source.
> >>
> >> Use a function-based pigment, with a function constructed like this:
> >>
> >>      #declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
> >>      #declare Fn = function(x,y,z) {
> >>          FnDist(x-xC,y-yC,z-zC) +
> >>          FnDist(x-xL,y-yL,z-zL)
> >>      }
> >>      #declare P = pigment {
> >>          function { Fn(x,y,z)/MaxDistance }
> >>      }
> >>
> >> where <xC,yC,zC> is the location of the camera, <xL,yL,zL> is the
> >> location of the light source, and MaxDistance is the maximum total
> >> distance you want to be able to handle properly.
> >>
> >> Then choose a finish that gives full brightness whenever the surface is
> >> illuminated (regardless of incident light angle):
> >>
> >>      finish { ambient 0 diffuse 1 brilliance 0 }
> >>
> >> Finally, set up the light source to have no distance-based attenuation
> >> (i.e. use `fade_power 0`).
> >>
> >>
> >> This should give you an output image where the brightness of each pixel
> >> corresponds to the distance the light ray has travelled.
> >>
> >>
> >> Make sure to use a high bit depth for the output image, and either use
> >> linear encoding (`File_Gamma=1`) or be aware that your pixel values will
> >> not correspond linearly to distance travelled.
> >
> >
> > Thank you for the reply. This could be a very interesting approach.
> >
> > Maybe a trivial question but...about the values x,y,z in the definition of the
> > function Fn:
> >
> >   Fn = function(x,y,z) {
> >           FnDist(x-xC,y-yC,z-zC) +
> >           FnDist(x-xL,y-yL,z-zL)
> >
> > what do they represent for POV-ray?
> >
> > I was thinking I could introduce a such function directly as a light attenuation
> > function in the definition of light source.
> >
> > What do you think about?
> >
> >
>
> The x, y, z are world centric, with the point <0,0,0> as the origin.
> When evaluating a function, for say, an isosurface or a pigment, it's
> the current point been tested.

Thanks!


Post a reply to this message

From: Bald Eagle
Subject: Re: Rays path Length
Date: 15 Jan 2018 10:15:00
Message: <web.5a5cc49bf30201835cafe28e0@news.povray.org>
Nope:
You don't put the function in the light_source definition, you define a pigment
pattern based on the function, and apply that to your shape.


http://wiki.povray.org/content/Reference:Function_Pattern


==============================================================

#version 3.71;

global_settings {
 assumed_gamma 1
}

#include "colors.inc"
#include "textures.inc"

#declare xC = 50;
#declare yC = 0;
#declare zC = -50;

#declare xL = -50;
#declare yL = 0;
#declare zL = -50;

camera {
        perspective
        up <0,1,0>
        right x*image_width/image_height
        location <xC, yC, zC>
        look_at <0, 0, 0>
        }

light_source {
                 <xL, yL, zL>
                  fade_distance 1
                  fade_power 0
                  media_interaction off
                  media_attenuation off
                 }

//plane {y, -20 texture {pigment {White}} }

#declare Scale = 0.02;
#declare FnDist = function (x,y,z) {sqrt(x*x + y*y + z*z)*Scale}
#declare  Fn =
function (x,y,z) {
 FnDist (x-xC, y-yC, z-zC) +
 FnDist (x-xL, y-yL, z-zL)
}

cone {<0, 0, 0>, 10, <0, 0, -30>, 0
 texture {
  pigment {function {Fn (x, y, z)}}
 }
}


Post a reply to this message

From: Alain
Subject: Re: Rays path Length
Date: 15 Jan 2018 11:08:38
Message: <5a5cd206$1@news.povray.org>
Le 18-01-15 à 06:28, Motive17 a écrit :
> clipka <ano### [at] anonymousorg> wrote:
>> Am 12.01.2018 um 14:53 schrieb Motive17:
>>
>>> Maybe a trivial question but...about the values x,y,z in the definition of the
>>> function Fn:
>>>
>>>   Fn = function(x,y,z) {
>>>           FnDist(x-xC,y-yC,z-zC) +
>>>           FnDist(x-xL,y-yL,z-zL)
>>>
>>> what do they represent for POV-ray?
>>
>> They represent the x, y and z coordinates for whatever point the pigment
>> based on the funciton is evaluated for.
>>
>>
>>> I was thinking I could introduce a such function directly as a light attenuation
>>> function in the definition of light source.
>>>
>>> What do you think about?
>>
>> That wouldn't fly: The distance-based attenuation of light sources only
>> affects the brightness based on the distance between the light source
>> and the surface. The distance between the surface and the camera isn't
>> affecting the brightness at all.
> 
> In order to be more clear I'll write down some details...
> 
> I was thinking to define this function, based on your advices :
> 
> #declare FnDist = function(x,y,z) { sqrt(x*x + y*y + z*z) }
> #declare  Fn = function(x,y,z) {
>            FnDist(x-xC,y-yC,z-zC) +
>            FnDist(x-xL,y-yL,z-zL)
>                                 }
> light_source {
>                   <0,0,0>
>                   color rgb <255,255,255>*1/Fn
>                   fade_distance 1
>                   fade_power 0
>                   media_interaction off
>                   media_attenuation off
>                  }
> 
> Unlickely, It doesn't fly.
That just can't work.
> I did not understand which is the reason in this case.
> I cannot define a function in the definition of light source?
Yes, but not to control how it behave.
You can use a function to place it or set it's base colour.
> 
> 
> 

That function, ANY function, need the (x,y,z) when invoked. You just 
don't need to explicitly set those when creating the function. You can 
plug in some constants instead of x, y or z.
Also, you'll get an undefined variable error if any of xC, yC, zC, xL, 
yL or zL is not previously defined.

Next, it can only set the colour of the light, not how it behave as it 
travel. It's the job of fade_power and fade_distance.

You need to set fade_power 2 to have realistic fading. Using fade_power 
0 effectively turn light fading OFF.


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

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