Cull only spatials/faces not viewable by Camera

Example, I have 10,000 randomly generated polygonal models in a area. I don’t want the game to render objects that are not viewable by the camera.

1.) Is the only way to do this is using a Controller on each spatial that makes that spatial send a ray to the camera to check for collision?



Spatial → Ray → Camera = Spatial removes itself if Spatial cannot see camera.



2.) Does jMonkeyEngine automatically cull non visible faces? If you had a box and could only see the front face does jMonkeyEngine cull the back face.

if i good know JME have automaticly culling. You can set manual culling if needed(but you dont need :))

Spatials not in the view frustum are culled automatically. Take a look at Spatial.java for more details.

Back facing polygons are also culled.

And if you are using a large number of objects, use GeometryBatching to optimize them.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:optimization

Not talking about the view frustum. I’m talking about a spatial that is behind another spatial should not be rendered.



I’m wondering if jMonkeyEngine renders a spatial that is behind another spatial.

Only if that spatial’s bounding volume is not visible by the camera because its blocked by another spatial’s bounding volume.



Fig1:


[Spatial A] - [Spatial -B] - [Camera A]


Spatial A in Fig1 should not be visible because it is behind Spatial B and Spatial B is blocking the Camera A from viewing Spatial A.

No, JME doesn’t do this. It’s an O(n^2) problem in the general case and way slower than everything else going on.



The only way it works even reasonably well is when many objects are very large and make good occluders or there is some other way that the game/level/scene has a way of determining potentially visible sets.

Check for occlusion query on google, there are nice articles about it in GPU gems