[vtkusers] vtkImageSlice and depth peeling
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Wed Jan 9 11:20:31 EST 2013
Hello,
as reported here http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes ,
it seems that depth peeling can't be used when using vtkImageSlice.
This matches the code in vtkImageSlice.cxx:
> // Does this prop have some translucent polygonal geometry?
> int vtkImageSlice::HasTranslucentPolygonalGeometry()
> {
> // Always render during opaque pass, to keep the behavior
> // predictable and because depth-peeling kills alpha-blending.
> // In the future, the Renderer should render images in layers,
> // i.e. where each image will have a layer number assigned to it,
> // and the Renderer will do the images in their own pass.
> return 0;
> }
However very little explanation is provided about why this is impossible
(or undesirable) to do. In other words, why doesn't that method do
something like:
return GetProperty()->GetOpacity() != 1.0;
?
HasTranslucentPolygonalGeometry is also used in the
RenderTranslucentPolygonalGeometry method, which has a reasonable
implementation:
> int vtkImageSlice::RenderTranslucentPolygonalGeometry(vtkViewport* viewport)
> {
> vtkDebugMacro(<< "vtkImageSlice::RenderTranslucentPolygonalGeometry");
>
> if (this->HasTranslucentPolygonalGeometry())
> {
> this->Render(vtkRenderer::SafeDownCast(viewport));
> return 1;
> }
>
> return 0;
> }
This makes me think that I can safely override
HasTranslucentPolygonalGeometry and perform the aforementioned check.
Indeed, by doing so and enabling depth peeling, the results seem to be
correct.
Is there anything I should be aware of? :)
Cheers,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
More information about the vtkusers
mailing list