문제

I'm trying to render a set of textured geometry to a single FBO, and then render that FBO to the scene. The problem is that overlapping semi-transparent areas of that geometry are not rendered correctly. They end up too opaque and dark. If I render the geometry directly to the scene it renders correctly, but I need to render it first to the FBO.

By the way, I'm using the following for blending (according to opengl - blending with previous contents of framebuffer):

  • rendering geometry to the FBO: glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE)
  • rendering the FBO to the scene: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

I'm doing this for OpenGL ES 2.0.

도움이 되었습니까?

해결책

Actually, I found that the problem was the blending function used to render the geometry to the FBO.

Instead of:

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE)

I have to use:

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

And now it works as good as if I was rendering the geometry directly to the scene.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top