[vtkusers] How to get silhouette/mask of rendered polydata?
Obada Mahdi
omahdi at gmx.de
Tue May 9 15:31:03 EDT 2006
Hi Michael and others!
On May 9, 2006, at 2:44 PM, Kevin H. Hobbs wrote:
> On Mon, 2006-05-08 at 23:12 -0500, Michael Rice wrote:
>> In the end, I need to be able to render the silhouette of the
>> polydata in realtime as the user manipulates the camera location. For
>> example, the web page below shows two camera shots of a polydata. As
>> the user rotates the polydata in one window, I need to render the
>> stencil image in another window. Optimally, I'll be able to associate
>> each pixel in the rendered stencil image back to a cell in the
>> polydata.
>>
>> http://www.knology.net/~mars/stencil.html
>
> How about you capture the rendered image, with vtkWindowToImageFilter,
> contour it, and then re-render, or something like that.
Speed being a concern, you might be able to emulate Kevin's idea by
using the Z-buffer from the rendering process for creating a stencil
mask. The Z-buffer effectively gives you some kind of "height map"
of the scenery, as seen from the camera's point of view, which could
be converted to an outline mask by thresholding. Admittedly, this is
far from being an exact science, and it comes with some weak spots:
- for being efficient, it requires one to have (fast) access to the
hardware Z-buffer; for example, the "GetZbufferData" method of
vtkOpenGLRenderWindow does use GL calls to obtain the data, but this
does not necessarily guarantee great performance (btw, that method is
already declared in the vtkRenderWindow interface)
- the Z-buffer precision (depth) is hardware/implementation-dependent
- if there are more objects in the scene affecting the Z-buffer
(opaque objects), simple thresholding likely will not be enough
If you are keen enough, it might still be worth a try :-)
Regards
Obada
More information about the vtkusers
mailing list