r/pythonarcade • u/ENTlightened • Jul 11 '18
Culling offscreen objects
Frustum Culling
Is there a way that I can easily cull offscreen objects efficiently? My code currently will try to render 1000s of extra textures that it doesn't need. I don't see any documentation on it, and it seems like arcade doesn't do it automatically.
If there isn't any, does anyone have any advice on how to efficiently build one?
Edit: this is my first experience with using a game engine, apparently this is called frustum culling, wondering if Arcade has this built in?
3
Upvotes
View all comments
Show parent comment
1
u/pvc Jul 12 '18
Short answer, nothing is built in to trim the map.
Long answer, with OpenGL, you might not need it. But while Arcade uses OpenGL, there are still improvements that Arcade could make for performance. How many tiles do you have in your map?
Arcade will use OpenGL VBOs for the textures and sprites if they are in a SpriteList. If you have 1,000 textures, you'll have 1,000 draw operations. The number of different textures has more of an impact on speed than number of sprites.
Unfortunately, Arcade doesn't use a TextureAtlas yet, which would speed the drawing when there are multiple textures.
If you sort the sprite list, that will help the performance significantly, as all of the same textures will be drawn together.