PDA

View Full Version : Is it possible to clear specific textures attached to FBO's outputs.



CaptainSnugglebottom
06-14-2017, 11:01 PM
I'm thinking about reducing number of FBOs, and for that I have to use first 5 texture (texture A) outputs for first 3 draw passes that happen for several objects, and then using another texture (texture B) to save the results.


I would like to know whether it would be possible to clear the texture A, without clearing texture B. I know that the glClear function clears all (active?) textures attached to the FBO. However, if all the textures I use are already attached to the FBO, I would need to make sure that texture B is not touched when I need to clear texture A.


Is there a way to diactivate a texture output so that it's not affected by glClear when needed?


I guess, one way to solve this problem would be to detach/attach texture B, so that it's not affected by glClear. But I believe that would defeat the purpose, since the FBO would have to be re-verified after I do that, which is time consuming. (I've read that somewhere). Is this correct?


PS.

Would calling glDrawBuffers to activate specific attachments before calling glClear do the trick?

So something like:


glDrawBuffers(texture A attachment number)
glClear(----)
.
.
.
.
glDrawBuffers(texture B attachment number)
glClear(----)

Silence
06-14-2017, 11:27 PM
Try the approaches given in this thread (https://www.opengl.org/discussion_boards/showthread.php/177296-Fast-Way-to-Clear-a-Texture).

mhagain
06-14-2017, 11:58 PM
If you have ARB_clear_texture you could use that: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_clear_texture.txt