VTK(Activiz 5.8.0)纹理影响不透明度

时间:2017-04-28 02:37:31

标签: c# vtk

当我尝试渲染包含透明对象(50%透明度)和纹理不透明对象的场景时,透明对象变得更加褪色。如果隐藏了纹理对象,则透明对象将再次获得其预期的透明度。

我使用vtkTextureMapToSphere将纹理映射到对象。请注意,下面代码中的bounds表示我应用纹理的_polydata对象的边界框。

vtkTextureMapToSphere textureMapper = vtkTextureMapToSphere.New();
textureMapper.SetInput(_polydata);
textureMapper.SetCenter(bounds.center[0], bounds.center[1], bounds.center[2]);
textureMapper.PreventSeamOn();

vtkTransformTextureCoords transformMap = vtkTransformTextureCoords.New();
double factorEnlarge = 4;
double scale = bounds.dimensions.Sum() / bounds.dimensions.Length / factorEnlarge;
transformMap.SetInputConnection(textureMapper.GetOutputPort());
transformMap.SetScale(scale, scale, scale);

vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection(transformMap.GetOutputPort());

vtkActor actor = vtkActor.New();
actor.SetTexture(texture);
actor.GetProperty().SetColor((double)color.R / 255, (double)color.G / 255, (double)color.B / 255);
actor.GetProperty().SetOpacity(alpha);
actor.SetMapper(mapper);
actor.GetProperty().SetInterpolationToPhong();

renderer.AddActor(actor);

Transparent object and textured object. Transparent object with textured object hidden

修改

关闭vtkTextureMapToSphere的PreventSeam选项后,颜色的差异消失了。但是,无论您通过网格的两个以上表面查看(例如网格中有空洞的位置),阴影中仍然存在明显的差异。

Detail of the transparent mesh after turning PreventSeam off, with the textured object shown. Note that the textured object is not in the screenshot Detail of the transparent mesh after turning PreventSeam off, with the textured object hidden.

1 个答案:

答案 0 :(得分:0)

好吧,如果我理解问题的当前状态你问的是如何去除网格中口袋造成的深色。如果这是正确的,您只需要弄清楚如何激活部分透明网格的遮挡剔除。不幸的是,我不熟悉Activiz所以我无法帮助解决细节,但在XNA(DirectX)中,您需要更改GraphicsDevice.BlendState或根据您的最终目标创建自定义着色器。

我意识到它并不多,但我希望它有所帮助。

相关问题