POV-Ray : Newsgroups : povray.advanced-users : depth map? : Re: depth map? Server Time
20 Apr 2024 06:56:03 EDT (-0400)
  Re: depth map?  
From: clipka
Date: 23 Mar 2009 16:45:00
Message: <web.49c7f4973a6933706e4227230@news.povray.org>
"Sidney Cadot" <sid### [at] jigsawnl> wrote:
> For a technical project I am doing concerning stereo reconstruction, it would be
> helpful to be able to have access to the depth (z) coordinate of the directly
> visible object at each pixel in the rendered image.
....
> Has something like this perhaps been done before? If not, how difficult would it
> be to add this myself (I am proficient in C, but I have never looked at the
> source code of POV-Ray) ?


To do this in POV-Ray, you might assign to all objects a texture with a
greyscale gradient pigment, and an ambient-only finish, so you get a render
with pixel brightness indicating depth.

You can also use a multi-layered texture using differently scaled gradient
pigments with red, green and blue color respectively to increase the
resolution.

If you use a custom-tailored function pattern instead of the gradient, you can
get e.g. a logarithmic relationship between depth and brightness.


If you don't have to use official POV, you may also try out MegaPOV's
post_process feature, which allows you to mess around quite a lot with the
rendered image before writing it to file, including manipulations based on the
depth of the pixel (although this is not strictly z, but distance between
observer and scene geometry).


Or you can mess around with the source code, of course. In that case,
Trace::TraceRay() (in trace.cpp) is probably the place to start (assuming
you're going for the 3.7 code; I'm not so much into 3.6's bowels), as it is the
"topmost" code that has access to the "hit point" co-ordinates. Make sure you
test for ray.IsPrimaryRay() (to check whether it is not an auxiliary ray for
radiosity, shadow testing or what-have-you) and check ticket.traceLevel (which
gives you information about how often the ray was reflected/refracted already).


Post a reply to this message

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