Jump to content
  • Advertisement
Sign in to follow this  
akerlund

glReadPixels from multiple color attachments

This topic is 3793 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
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 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!