加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 21:06:03 所属栏目:百科 来源:网络整理
导读:当我尝试渲染包含透明对象(50%透明度)和纹理不透明对象的场景时,透明对象变得更加褪色.如果隐藏了纹理对象,则透明对象将再次获得其预期的透明度. 我使用vtkTextureMapToSphere将纹理映射到对象.请注意,下面代码中的边界表示我应用纹理的_polydata对象的边界
当我尝试渲染包含透明对象(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或根据您的最终目标创建自定义着色器.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读