So, I’m on a quest to make my system nice and efficient. I’ve hit an annoying issue with trying to clear the buffers of a small chunk of the screen rather than the full screen.
I’ve tried setting viewport and scissor and then clearing, which is working nice for making a little grid of views. However, if I leave some chunks static and redraw the others, only the redrawn views stay on the screen.
I found a stackoverflow that explained that I have two options:
- preserveDrawingBuffer: true
- Render using an FBO
For #1, I have set it to true, and the context still clears out anything that did not re-render for the frame. So rats. Also, it turns out, this is a poor choice as it comes with some major possible performance hits for different environments.
I have also ensured I set all autoClear options for the renderer to false.
So #2, it seems I have to work with an FBO.
I couldn’t find anything in ThreeJS that lets you fiddle with FBO’s directly. They’re all wrapped in abstracted concepts.
What would be the best abstracted concept for this use case? RenderTargets don’t seem to work well for me because they do not honor scissor and viewports that I explicitly set. Not sure if that’s a bug or not.
Can I just grab the context, create my own FBO and set it as the current FBO in use when I call three’s render as an alternative? Then I’d just set the fbo target back to null and draw the FBO’s attached texture as a Full Screen Quad.
I dunno, I’m not sure what approach I should take here or if I’m encountering odd things or not.
Thanks for any input on the matter.
[EDIT] I incorrectly said stencil above when I meant scissor