Realtime lighting broken by Occlusion

Hi there. I’ve got a scene made up of lots of cubes, essentially. When I walk around in the world the performance is meh but the lighting works well. The lighting is one big sun pointing down at the scene.

However when I turn on occlusion, which is essential for performance, I get really weird behaviour. As the camera turns it seems that cubes that are no longer drawn (as expected) stop blocking out the realtime lighting, which then illuminates areas it shouldn’t be able to get to. Is this expected? It seems insane.

For instance, if you’re inside a building, with a separate roof model. If you look up at the roof, the sunlight can’t hit you. As soon as you look away from the roof, it gets occluded (ie not drawn) and the sun can now stream in through the open hole. WTF? Is this the intended behaviour?

Yep, sound about right, the shadow are real time, so is the occlusion, coming the two mean that object that aren’t there no longer cast shadow … 2+2.

So the questions are:

  • do you need real time shadow
  • do you need it only for the sun
  • is teh sun moving
  • can you use simplified proxy objects that cast shadow (but don’t receive it) that are invisible to scene’s camera but not to light
  • if proxy object, is it a big world or not, then you can use a LOD system to phase out proxy objects base on distance or different occlusion rule.
  • if you can think of anything else.

Hi there Neoshaman.

I should point out that this doesn’t always happen - just at certain rotations. Sometimes the roof is still visible but the sun comes through anyway. I would actually not expect this behaviour - the occlusion should remove objects just before the render pass. It would effectively make real time lighting and occlusion impossible to use at the same time.

I’m using real time lighting because unity’s pre-rendered lighting looks completely different, and isn’t useable for this project. I’ve wasted hours experimenting with lighting settings. (and yup, I’ve tried linear/gamma etc)

I will think about your idea of proxy objects - I might just have to whack loads of invisible cubes around the world. I’ve tried this in a few places, and it does help a little. There’s still something fundamentally wrong with the lighting model if occlusion causes this to happen.

It’s not the lighting model, nor it has to do with gamma linear!
It should be occlusion aliasing (they use a voxel model I think).

I only mentioned gamma/linear to explain what I’d tried when failing to get pre-baked lighting to match realtime.

So to summarise - you can’t use occlusion and lighting at the same time?

You can, but you need to understand both to get them to interact correctly.
Nothing work out of the box without some fiddling

Sure - but this can’t be fixed with some minor fiddling. What sort of hack will fix this issue? If occlusion turns off an object, the realtime light nearby will illuminate the wrong areas that are now ‘exposed’. I don’t buy that this is expected behaviour. Either the underlying model is fundamentally flawed, or there is some other error at play.

I’ve tested the same scene on different hardware. Nvidia cards show exposed lighting in a non-desirable manner. Intel gpu does not.

Well then file a bug to unity

Good idea