[vtkusers] vtkImageActor, transparency, and depth peeling

Francois Bertel francois.bertel at kitware.com
Thu Mar 22 12:06:21 EDT 2007


I think the logic in VTK is already the right one.

David Feng reports the line is
if (!(this->Opacity >= 1.0) && input->GetNumberOfScalarComponents() % 2))

but it is actually:
if (!(this->Opacity >= 1.0 && input->GetNumberOfScalarComponents() % 2))

The "not" operator applies to the whole expression.

Basically, the image is rendered in the opaque stage if the Opacity ivar is set to 1.0 and the image does not have an alpha component.

If you want your image actor to render in the opaque stage make sure you use a grayscale image or RGB image with no alpha component and that the ivar Opacity is set to 1.0.

Regards.


David C Thompson wrote:
>> I had some transparency issues when using a vtkImageActor (generated by 
>> vtkImageViewer2) and depth peeling at the same time.  Some digging 
>> revealed that my vtkImageActor was not getting rendered into the initial 
>> opaque layer, but rather somewhere in the transparent layers.  The 
>> offending line of code is tagged below:
>>
>> int vtkImageActor::RenderTranslucentPolygonalGeometry(vtkViewport* 
>> viewport)
>> {
>> ...
>>    if (!(this->Opacity >= 1.0) && input->GetNumberOfScalarComponents() % 
>> 2)) ********
>>      {
>>      this->Render(vtkRenderer::SafeDownCast(viewport));
>>      return 1;
>>      }
>> ...  return 0;
>> }
>>
>>
>> The tagged line appears multiple times throughout the file.  When I 
>> comment out all portions related to scalar components and rely strictly 
>> on opacity values, depth peeling works wonderfully. What does the number 
>> of scalar components of the input vtkImageData have to do with 
>> transparency?
> 
> I believe 4 components is assumed to be RGBA data (A=alpha transparency)
> and 2 components would be greyscale data plus transparency. But if so,
> the number of components mod 2 should be 0 for the test to be correct.
> 
> 	David



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list