Sign in to follow this  

glReadPixels from multiple color attachments

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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