POV-Ray : Newsgroups : povray.advanced-users : depth map? : Re: depth map? Server Time
25 Apr 2024 22:58:55 EDT (-0400)
  Re: depth map?  
From: Chris B
Date: 23 Mar 2009 11:06:55
Message: <49c7a58f$1@news.povray.org>
"Sidney Cadot" <sid### [at] jigsawnl> wrote in message 
news:web.49c79d64a563150ecb94416e0@news.povray.org...
> Dear all,
>
> 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.
>
> Ideally, I would have a file that gives (IMAGEHEIGHT x IMAGEWIDTH) 
> floating
> point numbers (IEEE-754 format), each giving the projected "z" value for 
> the
> corresponding pixel (or "infinity" if there is no object in the eye->pixel 
> ray
> path).
>
> 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) ?
>
> Best regards, Sidney
>

I don't think you'd need to necessarily get into the source code to do this.

If you can build the contents of the scene into a single CSG union assigned 
to an identifier in POV-Ray SDL, then you should be able to get this data 
using a bit of maths and the POV-Ray 'trace' function. You can loop through 
the pixel positions on the image plane tracing rays out from the camera 
position to retrieve the position at which the traced rays hit the union 
object. You can write the floats out using the #fopen, #write and #fclose 
directives.

Regards,
Chris B.


Post a reply to this message

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