Scissor vs Canvas for offscreen optimization?
Posted: Tue Aug 13, 2019 5:42 pm
Hi!
I have a tile map which can be moved about by the user, thereby parts of it coming and going off the screen. I'm currently using a spritebatch to draw the tiles, and am looking for the best way to prevent off-screen drawing.
My first thought was a canvas. As far as I understand, the two (relevant) benefical properties of canvases are:
1. Reduce draw calls by pre-rendering canvas.
2. Prevent wasteful offscreen drawing.
However- as the map will be moved around a lot, I'll need to frequently re-render the canvas contents. Even when re-rendering every frame, will using a canvas improve performance (like the case of clearing/readding to spritebatches)? Given these frequent re-renderings, will whacking in a love.graphics.setScissor instead provide similar performance enhancements?
Furthermore, is using spritebatches to draw to a canvas unecessary by virtue of the negligible performance difference? Is it a spritebatch OR canvas kinda deal?
So I guess my final question is: will a spritebatch+canvas be any more effecient than a spritebatch+setScissor in the situation above?
Thanks for any help! (I'm finding this equally interesting and confusing lol)
I have a tile map which can be moved about by the user, thereby parts of it coming and going off the screen. I'm currently using a spritebatch to draw the tiles, and am looking for the best way to prevent off-screen drawing.
My first thought was a canvas. As far as I understand, the two (relevant) benefical properties of canvases are:
1. Reduce draw calls by pre-rendering canvas.
2. Prevent wasteful offscreen drawing.
However- as the map will be moved around a lot, I'll need to frequently re-render the canvas contents. Even when re-rendering every frame, will using a canvas improve performance (like the case of clearing/readding to spritebatches)? Given these frequent re-renderings, will whacking in a love.graphics.setScissor instead provide similar performance enhancements?
Furthermore, is using spritebatches to draw to a canvas unecessary by virtue of the negligible performance difference? Is it a spritebatch OR canvas kinda deal?
So I guess my final question is: will a spritebatch+canvas be any more effecient than a spritebatch+setScissor in the situation above?
Thanks for any help! (I'm finding this equally interesting and confusing lol)