本文介绍了OpenGL混合函数,以消除原始重叠,但保持整体不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些几何,它有一个单一的原始集,是一个三条。基元中的一些三角形重叠,因此当我使用alpha值向几何添加材质时,我看到重叠(如预期的那样)。我想摆脱这种效果,而不改变几何体 - 我试着玩不同的混合模式(glBlendFunc()),但我不能让这个工作。我得到一些有趣的结果,但没有什么会消除不透明效果三原色的原始,并保留整个对象的不透明度。我使用OpenSceneGraph,但它提供了一个方法来调用glBlendFunc()为几何的问题。

I have some geometry which has a single primitive set that's a tri-strip. Some of the triangles in the primitive overlap, so when I add a material to the geometry with an alpha value I see the overlap (as expected). I want to get rid of this effect without changing the geometry though -- I tried playing around with different blending modes (glBlendFunc()) but I couldn't get this to work. I got some interesting results, but nothing that would eliminate opacity effects within the primitives of the tri strip, and preserve opacity for the entire object. I'm using OpenSceneGraph, but it provides a method to call glBlendFunc() for the geometry in question.

从图片中,假设粉红色的道路,紫色的道路和黄色的道路构成三个独立的对象,每个使用单个三条带创建(有多个条带,但是为了争论,假装在这里只有三个不同的彩色三条带)。我基本上不想看到在同一个颜色的自相交

So from the image, assume that pink roads, purple roads and yellow roads constitute three separate objects, each created using a single tri strip (there are multiple strips, but for arguments sake, pretend that there were only three different colored tri strips here). I basically don't want to see the self intersections within the same color

此外,我的问题是几乎一样的这一个:,但我应该注意,当我尝试混合模式

Also, my question is pretty much the same as this one: OpenGL, primitives with opacity without visible overlap, but I should note that when I tried the blending mode in accepted answer for that question, the strips weren't rendered in the scene at all.

推荐答案

我遇到了同样的问题在以前的项目。这是我如何解决它:

I've had the same issue in a previous project. Here's how I solved it :

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA)



资料来源:

这篇关于OpenGL混合函数,以消除原始重叠,但保持整体不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 23:21