Need help getting occlusion culling working

I’ve read the unity iphone manual for “Using Occlusion Culling” But after following the steps… nothing seems to be happening in my game.

Unlike the example in the manual (which has it’s view areas setup by rooms) my game is an open environment with buildings and streets.

I would like to hide buildings that aren’t in view or ones that are behind other buildings.

So what I’ve done is setup a huge view area and scaled it so all the buildings fit inside of it… then I set the cell size to 40 so just about each building has it’s own cell. After previewing or building my occlusion data… nothing happens… there is no change in the rendering.

Does anyone know exactly how to work occlusion culling?

Thanks.

I’m pooling my ignorance here since I haven’t used occlusion culling at all yet, but I did find in the docs where it says something about a property of GameObject called “isStatic” that may have something to do with it.

Yes, I have all the meshes set as static.

Can you post a screenshot of how you have the view areas actually set up? Placing a single, enormous view area over your entire scene might not be the best way to go about this. It’s best to set up multiple areas to encompass all the places the camera can get to.

Ethan

The red box around the buildings is the view area… basically what I need is for the game to not render the buildings that are not in the camera’s view.

Also I should note that I’m using the CombineChildren script… will this cause a problem? or can certain buildings still be occluded.

Thanks

No, you can’t combine all the buildings into one mesh and expect them to then separately disappear when they’re occluded from view. For a scene like that it would be best to keep each building its own mesh. Also it would be better to make several viewing areas going along the streets (even if they overlap) instead of one big viewing area.

Thanks for the tip!!

So the height of the viewing area isn’t important? And the viewing areas don’t have to actually touch the buildings?

I think once I figure out what the viewing area is actually doing… I’ll have a better understanding of how to lay them out.

But thanks so much for your advice thus far.

The buildings are all separate meshes now … Still no luck. The editor isn’t even displaying changes. Here’s how I changed the view areas. (I just don’t know what I’m doing wrong) :cry:

The viewing areas have to encapsulate all the areas where the camera can move to… as soon as the camera moves out of these viewing areas everything will be visible regardless of culling data.

There is a new viewing option in the Scene View for seeing how well your occlusion data is working. It can be found under the “Textured, Wireframe, Tex/Wire” drop down menu. If you don’t see any occlusion happening in the Scene View with this viewing option selected then the occlusion data isn’t working properly.

This is a new feature/concept for Unity users so it’s going to take some time for people to get their head around how to use it properly. If you’d like I can take a look at your project and set the occlusion up for you once so you can see how it’s done properly… just email me your project to ethan [at] unity3d [dot] com. Hopefully by the end of the week we should have an example up on the resources section of unity3d.com of a scene that is set up to use occlusion culling properly.

Ethan

Thanks so much for all your help Ethan. I’ll send what I have so far.

Just letting everyone know Ethan solved the problem!! In the current version of Unity the occlusion culling will only take place if the camera is tagged as MainCamera.

Ethan thanks! and you rock! You just made me feel 10x better about my Unity purchase… very helpful support team you all have.

I had a similarly awesome support experience not long ago. Let’s hear it for the Unity team!!!

Oh, and would you be willing to share an example by uploading a package to this thread so we could all learn from it?

We’ll hopefully have one up by the end of the week on the Unity Resources page. We showed it at Unite and now just need to clean up the project folder a little bit.

Ethan

Awesome, I can’t wait to see it! Does it demonstrate an outdoor scenario? That seems to be the most challenging. Indoor seems like it would be pretty straightforward.

Actually occlusion culling itself will take place for all cameras. Regardless of them being tagged main camera or not.

It is only the previewing mode in the scene view which basically just uses the position of the game view camera to see the occlusion culling results from the perspective of another camera. In the scene veiw previewing mode only a camera tagged as main camera will use the occlusion preview.

I just laid over 200 buildings in my scene which would have easily added up to over 9,000!!! tris … but after adding occlusion culling… my tris were at about 800-900!!!

I feel like I should do a commercial for Unity now…

You could do something like those infomercials where you have a ‘before’ and ‘after’ shot … how you lost x no. of polys on the occlusion diet or something :wink:

I could really use a tutorial on how the occlusion stuff works … I know my game would benefit from it, but I have no idea how it is supposed to work!

Jeff.

Well I know it was mentioned that Unity is putting out a tutorial… but in the mean time if anyone wants to look at the file Ethan edited for me… I’ve attached it.

I’m sure it’ll be no where as professional as Unity’s demo. But here goes…

99958–3866–$iphonetest_948.zip (3.02 MB)

Hi Jeff, did you read this page:
file:///Applications/Unity%20iPhone/Documentation/Manual/Using%20Occlusion%20Culling.html

TouchSoft, I’m eager to see your example, but it looks like the attachment didn’t come through. :frowning: