0使用单个FBO对iPhone进行后处理

0使用单个FBO对iPhone进行后处理

本文介绍了使用Opengl ES 2.0使用单个FBO对iPhone进行后处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OpenGL ES 2.0在iPhone上实现后处理(模糊,模糊等).我遇到了一些问题.在第二个渲染步骤中进行渲染时,最终在屏幕上而不是场景上绘制了一个完整的黑色四边形(似乎缺少纹理数据),因此我想知道原因是否使用了单个FBO.以下列方式使用单个FBO是否不正确?

I am trying to implement post-processing (blur, bloom, etc.) on the iPhone using OpenGL ES 2.0. I am running into some issues. When rendering during my second rendering step, I end up drawing a completely black quad to the screen instead of the scene (it appears that the texture data is missing) so I am wondering if the cause is using a single FBO. Is it incorrect to use a single FBO in the following fashion?

对于第一遍(常规场景渲染),

For the first pass (regular scene rendering),

  • 我将纹理附加为COLOR_ATTACHMENT_0并渲染到纹理. glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,texturebuffer,0)
  • I attach a texture as COLOR_ATTACHMENT_0 and render to a texture.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texturebuffer, 0)

对于第二遍(后处理),

For the second pass (post-processing),

  • 我将颜色渲染缓冲区附加到COLOR_ATTACHMENT_0 glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER,colorRenderbuffer)
  • 然后使用第一遍的纹理将其渲染为屏幕上的四边形.

推荐答案

不,FBO用法很好.原因很可能是您没有设置纹理(纹理缓冲区)的MIN/MAG过滤器,绑定后,使用glTexParameter将GL_MIN_FILTER和GL_MAG_FILTER设置为GL_NEAREST或GL_LINEAR,您的纹理应该可以工作.

No, that FBO usage is fine. The cause is very likely to be that you didn't set the MIN/MAG filters of your texture (texturebuffer), after binding, set the GL_MIN_FILTER and GL_MAG_FILTER to GL_NEAREST or GL_LINEAR using glTexParameter, and your texture should be working.

这篇关于使用Opengl ES 2.0使用单个FBO对iPhone进行后处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:46