mercredi 10 mars 2021

VTK Problem at producing a complete opaque volume rendering

Hello, I am currently playing around with VTK and its volume rendering algorithms. I want to create a volume where parts are transparent, translucent and some are opaque/solid. I tested all unstructured grid volume renderer, but for each of them, I can't get to work a complete opaque result.

My Code:

vtkNew<vtkPiecewiseFunction> opacityTransferFunction;  
opacityTransferFunction->AddPoint(0, 1.0);
opacityTransferFunction->AddPoint(255, 1.0);

vtkNew<vtkColorTransferFunction> colorTransferFunction;
colorTransferFunction->AddRGBPoint(0, 0.0, 0.0, 1.0);
colorTransferFunction->AddRGBPoint(255, 1.0, 0.0, 0.0);

vtkNew<vtkVolumeProperty> volumeProperty;
volumeProperty->ShadeOff();
volumeProperty->SetInterpolationType(0);
volumeProperty->SetColor(colorTransferFunction);
volumeProperty->SetScalarOpacity(opacityTransferFunction);

vtkNew<vtkOpenGLProjectedTetrahedraMapper> volumeMapper;
/// Adding a dataset with pointwise scalar array all set to 255
volumeMapper->SetInputData(dataset);

vtkNew<vtkVolume> volume;
volume->SetProperty(volumeProperty);
volume->SetMapper(volumeMapper);

renderer->AddVolume(volume);

And here a screenshot of the problem where you can see that the opacity of area 1 is higher than of area 2 since there is more material to penetrate. Also, you can see lines up and right next to the label of area 1 which are behind the volume and should not be visible at all.

I would be glad if you can help me, thanks!

Aucun commentaire:

Enregistrer un commentaire