Occlusion Culling Support for 2D? #2383
-
We have noticed that Axmol makes draw calls for nodes fully occluded by others, impacting performance. For example, when a Layer A(covering full screen) is rendered on top of another Layer B, draw calls are still made for Layer B, even though it's not visible to the user. We specifically need to call setVisible(false) to stop draw calls for those layers. Does the engine support occlusion culling to skip rendering these layers? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
No, it does not. The only culling that occurs is for objects outside the camera viewport. It's the same as it was in Cocos2d-x, and it hasn't changed in Axmol. |
Beta Was this translation helpful? Give feedback.
-
is layer A fully opaque? because some parts require blending from previous layers or for alpha discard or even empty spots in the layer that don't produce fragments, if layer A fully covers the one behind then I think that's a developer choice to not render layer B and shouldn't be in the engine. occlusion culling is mainly beneficial in 3D, I haven't seen any use for it in 2D in other engines as there is rarely any extreme performance hit from overdraw in 2D compared to 3D |
Beta Was this translation helpful? Give feedback.
-
Yes, Layer A is fully opaque. Our use case has multiple stacking of such opaque layers and can add more than 1k draw calls. |
Beta Was this translation helpful? Give feedback.
-
That is not a work-around, but precisely how it should be implemented by the developer. For a 2D game engine to handle it, then I can only imagine that it would be a very expensive process, and I personally don't know of any 2D engines that do implement such a feature. |
Beta Was this translation helpful? Give feedback.
-
lets imagine that yes this feature is gonna be added to the engine, how can you go about detecting if a layer is opaque? do you look at sprite bounding boxes and see if they cover the entire screen? because I'm sure that's very expensive. maybe you want to render the opaque layer and check the final render texture it produced and somehow check for any alpha pixels to see that it's not fully opaque? that's expensive too. I think you're doing a good job handling the culling manually, straight forward idea that doesn't require expensive algorithms. |
Beta Was this translation helpful? Give feedback.
-
This is not a bug or limitation in Axmol, and as @DelinWorks explained, implementing such a feature is not realistic for any 2D game engine. This issue should be closed. |
Beta Was this translation helpful? Give feedback.
-
closed now |
Beta Was this translation helpful? Give feedback.
This is not a bug or limitation in Axmol, and as @DelinWorks explained, implementing such a feature is not realistic for any 2D game engine.
This issue should be closed.