POV-Ray : Newsgroups : povray.advanced-users : depth values / hit times : Re: depth values / hit times Server Time
28 Jul 2024 18:12:17 EDT (-0400)
  Re: depth values / hit times  
From: Tim Nikias v2 0
Date: 22 Apr 2004 04:47:25
Message: <4087869d$1@news.povray.org>
> > I was wondering if there is a way to access the hit time (aka depth
value)
> > for the output pixels of a render. The idea is to render a heightfield
with
> > povray, and reading back each pixel ray's hit time.
>
> Employ no light sources and make all your objects
>
>    hollow
>    texture {
>      pigment {rgb 1/eps + transmit 1-eps}
>      finish {ambient 1/255}
>    }
>
> for small values of eps, eg 1/1000000. Now all your surfaces are (almost)
> completely tranparent but add 1/255 to the brightness of the pixel. Hence
> the byte value of the pixel (say its red channel) contains the number of
> surfaces hit.
> Note that I did not test this. To be sure you should set up a scene in
> which every value for hit time occurs and check its output.

This won't work. What you're actually describing is a method to find how
many surfaces in the line through a given pixel are, not the depth value.

To get the depth value, just use the following texture for ALL objects AFTER
they've been positioned and rotated to their place in the scene:

texture{
pigment{spherical color_map{[0 rgb ][1 rgb 1]} scale Max_Distance translate
Camera_Location}
finish{ambient 1 diffuse 0}
}

Now, Max_Distance has to be declared and gives the maximum distance you want
to be able to see, e.g.

#declare Max_Distance = 4;

will result in everything being black after its four units away from the
camera. The spherical-colormap has to be positioned at the camera's location
so that distances are "measured" away from it, not the origin, so declare
Camera_Location as you're current camera's location.

That's about it!

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

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