I've played with SceneKit on iOS 8 for quite a while, and recently, I run into a situation in which I need to detect if a node does not appear on the viewport. Occlusion culling might be a possible solution. Therefore, is there any occlusion culling option available from SceneKit, and if not, what are other suggestions that I might wanna try? Thanks!
SceneKit - Occlusion culling
1.8k views Asked by Van Nguyen At
2
The
isNodeInsideFrustum:withPointOfView:
method tells you if a node is inside the camera's field of view, but it won't tell you whether it's occluded by other scene geometry.If you need occlusion testing, a frustum test is a good place to start. Once you know a node is in the view frustum, you can do hit tests to see if there are any nodes in between. If the results of a hit test include nodes other than your target, it may be at least partially obscured.
Hit testing won't get you extreme detail (like whether any rendered pixels of one node would be visible behind those of other nodes), but it might be enough for what you need. You can refine the sensitivity of hit testing a bit with the
options
parameter and by choosing which points to test — e.g. just the center of a target node or the corners of its bounding box. Hit testing has a CPU performance cost, too, so you'll have to find the right tradeoff between the functionality you want and your target frame rate.