Sign in to follow this  
akerlund

glReadPixels from multiple color attachments

Recommended Posts

akerlund    122
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.

Share this post


Link to post
Share on other sites
Kalidor    1087
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 bound
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(...);

glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
glReadPixels(...);

//etc... plus error checking

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this