Wednesday 15 July 2015

glsl - OpenGL Alpha Blending Issue, Blending ignored (maybe)? -


edit + better solution:

If there is a problem running, there are two solutions The solution is accepted, but it only applies when you are doing things that I was tell me what I was doing:

1.) Screen

2.) Assign ships to FOO, then FOO particles

3) Presenting FBO on screen

This problem And to solve this problem, it happened in the first place because I was including the FBO with Star Background.

The real solution, which is believed to be slightly faster, is to provide the star background to the FOO, then the FBO has to present the handicapped with the screen in combination. To use this method, I do not have to mess with glBlendFuncSeparate ...

1.) Assign stars, then ships, then FBO particles

2 .) FBO render on screen with filtration disabled

---------- Basic question: ----------

On the issue of what I think, blending in any way is being ignored Alpha transparency particle textures completely overwrite the pixels .

I'm making a top-down game, the camera is a little bit so that there is some feeling of depth. I am rendering my ships, then presenting the particles on them ...

After starting the OpenGL reference

  GlennBel (GL_BLEND); GlBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GlCullFace (GL_BACK);   

In the render loop, I do this:

  glBindFramebuffer (GL_FRAMEBUFFER, ook-> fbo); GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GlEnable (GL_DEPTH_TEST); GlEnable (GL_CULL_FACE); Entitymgr_render (OOK); // Instructors always handling 1.0 alpha texture glDisable (GL_DEPTH_TEST); GlDisable (GL_CULL_FACE); // glBlendFunc (GL_SRC_ALPHA, GL_ONE); // This will enable the composite blending for the non-prevalent compound_recker (oak); // Render particles are probably always & lt; 1.0 Alpha Texture / glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GlBindFramebuffer (GL_FRAMEBUFFER, 0); I  

Screenshots from OGL Profiler (Mac Device):

screenshot from OGL profiler

Screenshots of FBO provided without any particle:

Screenshot of FBO provided without any particle

FBO S Screenshots with some particles crawling at the top:

with some particles provided at the top Screenshots of FBO

As you can see, particle, despite alpha transparency, does not mix with the ship given below. Instead, it overwrites pixels completely.

Last notes, shader installs pixel transparency correctly - the ship appears below. And here's my shader:

  #version 150 Uniform sample 2D s_tex1; Uniform float v4_color; Vec4 in the top; Vec3 in general; Vec2 in texcoord; Out vec4 frag_color; Zero Main () {frag_color = Texture (s_tex1, texcoord) * v4_color; If (frag_color.a = 0.0) discard; }   

Let me know if anything can make available.

I think this is giving the alpha channel even presentation in frame buffer, so when you have particles , Then alpha channel alpha channel is blended with alpha channel, which you do not want here.

This is the reason that the glblendfuncseparate () function was created. Try it ... glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);

Therefore, the alpha channel of your particles will be used to determine the colors of the last pixel, but alpha channels of the source and destination will be added together.

No comments:

Post a Comment