Jump to content
  • Advertisement
Sign in to follow this  
underthesun

using pixel shader for calculations..

This topic is 3610 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

How does one go about getting the output from a fragment shader back into code (c++)? The method I know of consists of drawing then using glReadPixel or something along that line.. but last time I tried this, the performance wasn't so great.. Are FBOs what I'm looking for? Or is there something else that will let me get the output from the fragment shader? Thanks

Share this post


Link to post
Share on other sites
Advertisement
You could use FBO and attach whatever render target you like for the texture format. e.g. 32bit RGBA or 16 or 8 depending on your needs. Then bind that texture and use glGetTexImage or if you are using PBO you could use them also...

Remember the gl_FragColor will be gl_FragData[0], gl_FragData[1] depending on what attachment you are rendering to.

Share this post


Link to post
Share on other sites
Quote:
The method I know of consists of drawing then using glReadPixel or something along that line.. but last time I tried this, the performance wasn't so great..

There will always be some sort of overhead when you try reading data from the GPU, as they were designed for pumping pixels to the screen, not doing calculations for the CPU.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!