Please find attached a simple blend file (v2.58) and a screen shot that demonstrates occlusion culling in the blender game engine. I often see videos on you tube where FPS is suffering due to what I suspect is overly complex objects and a lack of culling.
It took me a short while to figure out how the scene was to be set up to use the bullet physics based occlusion culling but it appears to do the job when running. Obviously there are no real benefits in this scene but were there several rooms full of complex objects there would be a significant benefit.
Instructions: Open the Blend file, while hovering mouse over the 3D window hit P to start the game engine. Use the mouse and WASD keys to move the camera around the scene.
When moving around the scene you should see that objects that are blocked by the walls of the largest cube are removed from the scene and only reappear when they become visible through the doorway. If you go to the world tab and switch off Occlusion Culling you will see the difference to the scene. If you switch into solid or textured drawing mode you will see that there are no impacts on what you can actually see.
It would be good to present some screenshots showing what you mean.
If you mention the BGE version it would be easier to open the file with the right version ;).
Please add a short manual here or in the file (what keys are used, what the user is supposed to see and why). Otherwise it is hard to guess how to use this file.
Correction: Occulision is used for rendering not for physics (bullet). You can see that by enabling âShow Physics Visualisationâ in the Game menu.
Thanks very much for the above advice, I have made appropriate corrections to the posting to make it more useful.
While occlusion is a function of the rendering pipeline in deciding what to send to the GPU, it is my understanding that blender implements firstly view frustum occlusion and then utilises the Bullet physics engines dynamic bounding volume tree (DBVT) feature to decide which objects are occluded in the scene. While this isnât strictly a physics function it is a physics engine feature.
Now I understand why you are referencing the Bullet Engine. I didnât know that. I thought occlusion is a feature of the 3D engine. But I never looked at the internals.
So I learned something today
So the idea is to enclose any large group of random objects with an âoccludeâ box so as to prevent the rendering of all unseen objects, right? And we add such an âoccludeâ cube inside the walls of every building (for example) just like collision boxes around the players and enemies?
Kind of. If Iâm correct, I believe the idea is to âoccludeâ, or hide high-poly objects with low-poly objects. An example would be a gate occluding the rest of a scene - thereâs no reason to render the rest if the gate is in the way. Once you move the gate aside, the scene will render.
Why does the GE render objects it canât see? Basically, why the need for occluders? Shouldnât this happen anyway? If Iâm standing in a room, why does the GE render a table on the other side of the wall? Or a table behind me for that matter. Shouldnât the ge simply create an on the fly picture of what I can see? Iâve always been confused on this point.
Thanks, thatâs what I had in mind, but in addition my point was that Occlude objects donât only stop other out-of-view objects from being rendered, they also let moving ones (e.g. player) pass through. So we need these two âlayersâ I was talking about in the previous post: one low-poly Occlude object that optimizes rendering and a second Static wall/door object that âcoversâ it, holds textures and stops the player from going ânoclip modeâ.
â8<â
Because all polys/tris are rendered. On the Unity website I read this:
This [i.e. Occlusion Culling] does not happen automatically in 3D computer graphics since most of the time objects farthest away from the camera are drawn first and closer objects are drawn over the top of them (this is called âoverdrawâ).
If the occluders are small and donât hide many objects.
In that case, occlusion culling is just dragging your CPU down.
If the occluders are large but hides simple objects.
In that case youâre better off sending the objects to the GPU.
If the occluders are large and hides many complex objects but in a very predictable way.
Example: a house full of complex objects. Although occlusion culling will perform well in this case, you will get better performance by implementing a specific logic that hides/unhides the objects; for instance making the objects visible only when the camera enters the house.
Thanks. Thatâs a bit odd. Seems like a weird reason to draw objects you canât see, but then again I know nothing of how game engines work. Why would the computer need to render objects behind the player? No overdraw there.
I like to set my camera clipping to a hair further than largest distance I will see in a level - if a 20â hall way is the longest distance I can see in a level, Iâll set my clipping to 20â + a bit. It has a good affect on frame rate - I guess itâs forcing the ge to completely ignore things beyond itâs draw distance. It will still render things through walls, but perhaps a well considered draw distance + occluders is the best solution.
@Man - Ah, yes. My mistake. @3D - Yes, I believe objects that are out of the clipping range of the camera arenât drawn. One could make fairly easy Level of Detail on complex objects by simply sliding them out of the range of the camera, and sliding them back up when itâs time to look at it.
Any reasonable rendering engine would already do occlusion culling⌠i think BGE does it too⌠imâ not sure i understand why we need thisâŚ
Are you basing âreasonableâ on what you think should be the case, or you know is the case - âI wish I had a million dollars vs. my account balance is 1 millionâ. I donât mean this in a sarcastic manner. Do you know for a fact that a specific GE occludes automatically? You were not very precise - I canât imagine why the developers would create something we donât need - âHey, the GE culls automatically, and thatâs great, but you know what, letâs make a manual culler as well, just for fun.â
@gizmo - The BGE most definitely does not already occlusion cull, which is why we have the occluder type. As you might have seen three posts above, the Unity game engine, a powerful, professional, non-free game engine doesnât automatically do occlusion culling either. EDIT: And if you check out Unityâs page in the post above, youâll see itâs a little complex to set up. Bulletâs is most likely slower, but is far easier to set up, as well.
If you designed your occlusion scene in the vein of Unityâs example, using a mixture of occlusion objects and cells to hide nearby objects, it would probably perform wellâŚ
I dont think many game engines have automatic occlusion culling, for the obvious reason occluders arent always optimised. They could instead slow your game down if used improperly. UDK has automatic occlusion culling as far as I can remember but its not for all types of objects I suppose (I am sure it isnt for terrains but dunno how much for static objects.)