glReadPixels from multiple color attachments

Started by
0 comments, last by Kalidor 16 years, 1 month ago
I am using deferred shading where I output values to 6 render targets in the fragment shader. I want to fetch all of this data on the CPU side for some processing (ray tracing). How can this be done? It's all rendered to a FBO with 6 COLOR_ATTACHMENTs.
Advertisement
Quote:Original post by akerlund
I am using deferred shading where I output values to 6 render targets in the fragment shader. I want to fetch all of this data on the CPU side for some processing (ray tracing). How can this be done?

It's all rendered to a FBO with 6 COLOR_ATTACHMENTs.
This is more OpenGL specific, but when you have an FBO bound (i.e. GL_FRAMEBUFFER_BINDING_EXT is non-zero) you can set the current read buffer to one of the FBO's color attachments...
//FBO should be boundglReadBuffer(GL_COLOR_ATTACHMENT0_EXT);glReadPixels(...);glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);glReadPixels(...);//etc... plus error checking

This topic is closed to new replies.

Advertisement