linzhang.robot
linzhang.robot

Reputation: 379

VTK and Paraview volume rendering

Paraview is a visualisation application based on VTK library. I have a volume (vti format) that I can visualise it in Paraview and set the color and opacity transfer function. I can also load it into VTK as vtkImageData and render it using the same color and transfer function settings as Paraview, however, I cannot get the same result. Paraview rendering of the volume: Paraview visualisation

VTK rendering of the volume using same settings: VTK visualisation

The setting in Paraview: enter image description here

The snippet in VTK for setting:

vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity =
vtkSmartPointer<vtkPiecewiseFunction>::New();
compositeOpacity->AddPoint(0.0,0.0);
compositeOpacity->AddPoint(255,1.0);

vtkSmartPointer<vtkColorTransferFunction> color =
        vtkSmartPointer<vtkColorTransferFunction>::New();
color->AddRGBPoint(0.0  , 0.231373, 0.298039, 0.752941);
color->AddRGBPoint(18.62, 0.865, 0.865, 0.865);
color->AddRGBPoint(61.52, 0.9647, 0.639, 0.518);
color->AddRGBPoint(249, 0.705882, 0.01568, 0.14902);

vtkSmartPointer<vtkVolumeProperty> volumeProperty =
        vtkSmartPointer<vtkVolumeProperty>::New();
volumeProperty->SetScalarOpacity(compositeOpacity); // composite first.
volumeProperty->SetColor(color);

// Visualize
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
        vtkSmartPointer<vtkSmartVolumeMapper>::New();
mapper->SetInputData(imageData);
mapper->SetRequestedRenderModeToDefault();

What can I do in order to have the same rendering in VTK?

Upvotes: 1

Views: 2026

Answers (2)

L.C.
L.C.

Reputation: 1145

Try setting the blend mode explicitely, for example: mapper->SetBlendModeToComposite();

vtkSmartVolumeMapper uses a different mapper depending on the mode you select. See the documentation here: https://www.vtk.org/doc/nightly/html/classvtkSmartVolumeMapper.html

I'm using vtkOpenGLGPUVolumeRayCastMapper rather than vtkSmartVolumeMapper and in my apps volume transparencies are displayed correctly.

Upvotes: 0

Leo Pessanha
Leo Pessanha

Reputation: 139

I believe you have to disable opacity mapping in Paraview.

Hope it helped!

Upvotes: 0

Related Questions