具有不透明度的基元

具有不透明度的基元

本文介绍了OpenGL,具有不透明度的基元,没有可见的重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Cocos2d在OpenGL ES中绘制半透​​明基元(线,圆),但不能避免可见的重叠区域。有谁知道如何解决这个问题?

I'm trying to draw semi-transparent primitives (lines, circles) in OpenGL ES using Cocos2d but can't avoid the visible overlap regions. Does anyone know how to solve this?

推荐答案

这是一个通常经常出现,即使是3D的问题。

This is a problem you usually come across pretty often, even in 3D.

我不太熟悉Cocos2D,但在一般的OpenGL中解决这个问题的一种方法是用你想要的alpha通道填充framebuffer,将混合模式切换到 glBlendFunc GL_ONE_MINUS_DST_ALPHA,GL_DST_ALPHA)并绘制矩形。这背后的想法是,你从framebuffer绘制一个所需的透明度的矩形,但在进度掩码你绘制的区域,以便你的后续矩形将被掩盖。

I'm not too familiar with Cocos2D, but one way to solve this in generic OpenGL is to fill the framebuffer with your desired alpha channel, switch the blending mode to glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA) and draw the rectangles. The idea behind this is that you draw a rectangle with the desired transparency which is taken from the framebuffer, but in the progress mask the area you've drawn to so that your subsequent rectangles will be masked there.

另一种方法是使用不重叠的多边形来渲染整个纹理或组合形状。

Another approach is to render the whole thing to a texture or assemble the shape using polygons that don't overlap.

我不是确定Cocos2D是否支持这些...

I'm not sure whether Cocos2D supports any of these…

这篇关于OpenGL,具有不透明度的基元,没有可见的重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 15:56