微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

我使用vtkTextureMapToSphere将纹理映射到对象.请注意,下面代码中的边界表示我应用纹理的_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.

解决方法

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐