当前位置: 动力学知识库 > 问答 > 编程问答 >

transparency - Opengl Simple Fragment Shader to overlay semi-transparent Triangle Strip over texture

问题描述:

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.

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);

}

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: