Frustum Culling

Hi, I just read about frustum culling and I'm making my first 3D engine.



Does frustum culling have to be implemented manually or will OpenGL "take care" of determining what needs to be drawn if I make the perspective with



gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);



or with



GLU.gluPerspective(gl, 52.0f, (float)width / (float)height, 0.1f, MAX_VIEW_DISTANCE);

OpenGL just "clips" triangles that are outside the frustum, which means the shader and depth/stencil/alpha tests are not executed. But the vertex transform and triangle assembly still happen (and incurs a slowdown) so you gotta frustum cull on the object level.

Alright, thanx :slight_smile:

Is frustum culling built into JME and does it work "automatically" for players camera perspective or do I have to initialize some classes to enable it? And I was also wondering if there are enemies that need to see player then can I use same classes?

Henri said:

Is frustum culling built into JME and does it work "automatically" for players camera perspective or do I have to initialize some classes to enable it? And I was also wondering if there are enemies that need to see player then can I use same classes?

Yeah its built in and used automatically. Really frustum culling is one of the primary features of a 3D engine.
You can use it for vision but if there's a wall in front of the enemy he will still see the player. Frustum culling just checks if an object is inside the frustum, it doesn't check if it is occluded by other objects.

I just stumbled across this post and I actually have a follow-up question about frustum culling. Is there a function within jME that returns a list of objects that are within the frustum? I wasn’t sure whether this process is handled within jME or within OpenGL or lower. The reason I ask is that we are considering using this for a research-based project that deals with interaction and we only need to consider objects that are within the camera’s view. Any suggestions on how to go about doing this or whether it exists or not would be great.

You can use Camera.contains() … Although you should probably do a search on it because there are a few nuances to using that method correctly