简体   繁体   English

产生完全不透明体渲染的 VTK 问题

[英]VTK Problem at producing a complete opaque volume rendering

Hello, I am currently playing around with VTK and its volume rendering algorithms .您好,我目前正在玩VTK及其体积渲染算法

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:-这里是问题的截图: -

在此处输入图像描述

As you can see that the opacity of area 1 is higher than of area 2 since there is more material to penetrate.如您所见,区域 1 的不透明度高于区域 2,因为要穿透的材料更多。 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.此外,您可以在区域 1 的 label 旁边看到线条,这些线条位于体积后面,根本不应该看到。

I would be glad if you can help me, thanks!如果你能帮助我,我会很高兴,谢谢!

The opacityTransferFunction decides the part of image you want to render. opacityTransferFunction 决定要渲染的图像部分。 As the code you write, you rendered the threshold between 0 and 255 and the opacity is 1, thus the rendered result is all opaque.在您编写的代码中,您渲染了 0 到 255 之间的阈值,并且不透明度为 1,因此渲染结果都是不透明的。 The following code may works以下代码可能有效

vtkNew<vtkPiecewiseFunction> opacityTransferFunction;  
opacityTransferFunction->AddPoint(0, 0.0);
opacityTransferFunction->AddPoint(50, 0.2);
opacityTransferFunction->AddPoint(150, 0.5);
opacityTransferFunction->AddPoint(255, 1.0);

vtkNew<vtkColorTransferFunction> colorTransferFunction;
colorTransferFunction->AddRGBPoint(0, 0.0, 0.0, 0.0);
colorTransferFunction->AddRGBPoint(50, 0.0, 0.2, 0.3);
colorTransferFunction->AddRGBPoint(150, 0.0, 0.4, 0.6);
colorTransferFunction->AddRGBPoint(255, 1.0, 1.0, 1.0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM