简体   繁体   English

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

[英]VTK (Activiz 5.8.0) texture influencing opacity

When I try to render a scene that contains a transparent object (50% transparency) and a textured opaque object, the transparent object becomes more faded. 当我尝试渲染包含透明对象(50%透明度)和纹理不透明对象的场景时,透明对象变得更加褪色。 If the textured object is hidden, the transparent object gets its expected transparency again. 如果隐藏了纹理对象,则透明对象将再次获得其预期的透明度。

I map the texture to the object using a vtkTextureMapToSphere . 我使用vtkTextureMapToSphere将纹理映射到对象。 Note that bounds in the code below represents the bounding box of the _polydata object to which I apply the texture. 需要注意的是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);

透明对象和纹理的对象。 隐藏纹理对象的透明对象

EDIT 编辑

After turning the PreventSeam option of vtkTextureMapToSphere off, the difference in color has disappeared. 车削PreventSeam选项后vtkTextureMapToSphere关闭,颜色的差异已经消失了。 However, there still is a noticeable difference in shading wherever you view through more than two surfaces of the mesh (eg where there are cavities in the mesh). 但是,无论您通过网格的两个以上表面查看(例如,网格中存在空洞的位置),在着色中仍然存在明显的差异。

关闭PreventSeam后透明网格的细节,显示纹理对象。请注意,纹理对象不在屏幕截图中 关闭PreventSeam后透明网格的细节,隐藏纹理对象。

Well if I understand the current state of the question You are asking how to remove the darker colors caused by pockets in your mesh. 好吧,如果我理解问题的当前状态你问的是如何去除网格中的口袋造成的深色。 If that's correct you simply need to figure out how to activate occlusion culling for your partly transparent mesh. 如果这是正确的,您只需要弄清楚如何激活部分透明网格的遮挡剔除。 Unfortunately I'm not familiar with Activiz so i can't help with the details but in XNA (DirectX) you would either need to change the GraphicsDevice.BlendState or create a custom shader depending on what your end goals were. 不幸的是我不熟悉Activiz,所以我无法提供详细信息,但在XNA(DirectX)中,您需要更改GraphicsDevice.BlendState或根据您的最终目标创建自定义着色器。

I realize it's not much but i hope it helps. 我意识到它并不多,但我希望它有所帮助。

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

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