简体   繁体   English

OpenGL渲染到FBO

[英]OpenGL rendering to FBO

Is it possible to render to a FBO with render calls that use fbos themselves? 是否可以使用本身使用fbos的渲染调用来渲染到FBO? for instance here is a bit of pseudo code. 例如,这里有一些伪代码。

Bind (top level FBO) 绑定(顶级FBO)

render water <-- (generate and use own sub fbos) 渲染水<-(生成并使用自己的子fbos)

render shadows <-- (generate and use sub fbos) 渲染阴影<-(生成并使用子fbos)

render regular scene etc.. 渲染常规场景等。

unbind (top level FBO) 解除绑定(顶级FBO)

Blur Top level FBO, bloom, render final scene to a quad using the top level FBO generated texture. 模糊顶层FBO,开花,使用顶层FBO生成的纹理将最终场景渲染为四边形。 I'm interested in doing post processing like bloom to my final game scene. 我有兴趣对最终游戏场景进行后期处理,例如绽放。

If I get your question right you want to compose a final scene from different rendering results,right?So first,this is completely possible.You can reserve an FBO per effect if you want.But your pseudo-code lack efficiency and would impact performance.No need to create sub-FBOs in runtime all the time.It is expensive operation.If you are after a pipeline with post-processing stage you would usually need no more than 2 FBOs (offscreen).Also remember you always have the default FBOs (front,back,left,right) which are created by the context.So you can render your 3D stuff into FBO -1 than use its texture as source for FBO-2 to apply post-processing effects.Then blit the results into the default screen FBO. 如果我的问题正确,那么您想根据不同的渲染结果组成一个最终的场景,对吗?首先,这是完全可能的。您可以根据需要保留每个效果的FBO。但是您的伪代码效率低下,会影响性能不需要一直在运行时创建子FBO,这是昂贵的操作,如果您处于具有后期处理阶段的管线之后,通常将不超过2个FBO(屏幕外),并且请记住您始终使用默认值由上下文创建的FBO(前,后,左,右)。因此,您可以将3D素材渲染到FBO -1中,而不是使用其纹理作为FBO-2的源来应用后处理效果。默认屏幕FBO。

I don't see a reason to create FBO per effect.The execution is still serial.That's, you render effect after effect so you can reuse the same FBO again and again.Also,you may consider,instead of multiple FBOs use multiple render buffers or texture attachments of one FBO and decide into which of those you want to render your stuff. 我看不出要为每个效果创建FBO的理由。执行仍然是串行的。也就是说,您要逐个效果渲染,以便可以一次又一次地重复使用相同的FBO。此外,您可能会考虑,而不是多个FBO使用多个渲染一个FBO的缓冲区或纹理附件,并决定将其渲染到哪个FBO中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM