POV-Ray : Newsgroups : povray.general : Rays path Length : Re: Rays path Length Server Time
24 Apr 2024 20:27:35 EDT (-0400)
  Re: Rays path Length  
From: clipka
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

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