本文介绍了Opengl简单片段着色器在纹理上覆盖半透明的三角形条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形成三角形的带纹理的三角带.当您单击它时,我希望周围区域被标记为半透明的四边形,以便您仍然可以看到下面的纹理.我的四边形得到正确显示,但它们根本不透明,并且完全覆盖了下面的任何东西.

I have a textured triangle strip that forms a quad. when you click on it i want the surrounding areas to get marked with semi-transparent quads so you can still see the textures underneath. i have the quads getting displayed correctly, but they are not transparent at all and completely cover whatever is underneath.

我有一个非常简单的片段着色器,我认为它可以与glEnable(GL_BLEND)glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)一起使用:

i have a very simple fragment shader that i thought would work with glEnable(GL_BLEND) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA):

#version 130

out vec4 flatColor;

void main(void)
{
    flatColor = vec4(0.0,1.0,0.0,0.5);
}

如果我使用简单的图像对四边形进行纹理处理,则可以很好地处理RGBA(0,255,0,128),但是我不想为要使用的每种颜色都创建一个纹理,并且希望通过着色器进行处理. /p>

If i texture the quads with a simple image it works fine RGBA(0,255,0,128), but i do not want to have to create a texture for every color I want to use and would like todo it through a shader.

推荐答案

我是个白痴,没有意识到我没有退缩,所以混合变得混乱了.一旦我确定了排序顺序,透明效果就会像我想要的那样发挥作用.

i am an idiot and did not realize i was not drawing back to front so the blending was messed up. once i fixed the sort order the transparency effect worked liked i wanted.

这篇关于Opengl简单片段着色器在纹理上覆盖半透明的三角形条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:59