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

自作多情 提交于 2019-12-08 00:13:39

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4867577/opengl-simple-fragment-shader-to-overlay-semi-transparent-triangle-strip-over-te

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!