Occlusion Culling bake settings

Hey guys,

So I have complex levels. My first level is about 40 rooms plus adjoining corridors. I wanted to get an OC bake done on it. Really, just to see what it does for my frame rates. [My frame rates are mostly pretty good due to heavy use of LOD and some scripts I have on the dynamic lights that adjust their ranges as you get further away from them, but in a few places there are frame rate drops that I’d like to take care of].

Using Automatic Portal Generation, I got a bake fairly quickly (less than an hour), but the results were disappointing (my frame rates actually went down). So I decided to try PVS and Dynamic Objects setting (which seems like the one I want to use anyway since I have a lot of static geometry).

The settings I used were a cell size of 1, a near clip plane of 0.1, and a far clip plane of 150,000. I started it at 10 AM, and at around 10 PM (12 hours later) it was still chugging away. But some time during the night it failed with a “Run out of memory in PVS sampler - Try increasing cell size” error.

Okay, that’s fine, I could do that, but I’m wondering about that far clip plane value. Of course, 150,000 is a totally ridiculous number, the player does not see anywhere near that far. I actually had the camera set to 1,500 originally, which is still further than the player can actually see before the fog takes over. But the problem with that is if I set it that low, it does bad things to the shadows (deferred rendering), causing them to flicker badly. So I had to bounce it way up to 150,000 to fix that.

But for the purposes of the OC bake settings, could I set that value back down to 1,500? The popup tool tip says that setting ought to match the largest far clip plane of any camera in the scene. What happens if it doesn’t? Will I get usable results? And will that reduce the memory usage and bake times (I would think so?).

Before I start up another 12 hour bake that may or may not give me good results (or even successfully run), it would be nice if I knew what reasonable values I could put in for the parameters of the bake. Does anyone have any experience with this sort of thing?

The OC bake far plane value does not need to have any actual relationship to the camera’s far plane value - it’ll just cause the OC system to cull out objects that are that far away.

I don’t think it’ll have any substantial effect on your bake times or memory usage unless you actually have objects that are more than 1500m apart though.

Cool, thanks Superpig. I sort of figured that was the case, but I was thrown off by that tooltip that said it ought to match my camera.

Point taken about the distances. I’m actually not quite sure how big the level is (I could figure it out easily enough), but your right, it’s probably not more than 1,500m per side. Maybe I ought to do some observations on just how far the player really can see, and set the far plane setting to a bit over that value. I bet I could reduce it pretty far (couple hundred meters maybe?). That ought to help out the PVS system :slight_smile:

Thanks for the advice, that was a help.

[EDIT: Yeah, I measured how far the player can see down a long corridor before the fog obscures everything, and it’s about 150m. So I set the far clip plane on the occlusion to 200 and started it up. We’ll see what results I get :slight_smile: ]

The idea behind the tooltip is just that if it doesn’t match the camera, then you’ll get objects that aren’t being culled when they could be (if the OC far plane is too high) or you’ll get objects that are being culled when they’re still visible (if the OC far plane is too low). But if you’re doing unusual things with the camera far-plane then you can reason around this.

The stuff you’ve run into with your shadow flickering sounds very odd though. Usually, decreasing the distance between camera near and far planes is the solution to flickering problems, not increasing; ideally you’d have your far plane just long enough to see down the longest corridor, and then push your near plane out as far as you can go before stuff starts clipping out close to the camera.

Hmm, well I can try messing with it again, but I did have it set pretty low (maybe even at 150) for a while and I got horrendous flickering with shadows on the walls (this is in deferred rendering mode), especially as I got further from the origin. And I found the further I pushed the far plane back the better it got. That’s how I ended up with a far plane of 150,000, at which point the flickering is gone (but of course I’m drawing far too much, hence my playing around with the OC system).

But I will definitely try out pulling it back down and pushing out the near plane as much as I can and see what happens. That would be better, since I wouldn’t have so much overdraw.

[EDIT: You are right SP. The reason I couldn’t fix it before is that one of the scripts I use (which came with an asset off the asset store) was setting the near clip plane of the camera to 0.01. So no matter what I set it to, it was being overwritten. I commented out that line, set the near to 0.3, the far to 200, and no flicker! And much less overdraw. Why did that script write the camera’s near clip plane to a magic number? I have no idea. As far as I can tell, it’s useless. That will teach me to go over scripts that I don’t write myself a little more carefully.]

Cool :slight_smile: