Been working on something for the last few weeks and was wondering how I could improve performance (something that sorely needs doing).
So here’s the problem, I’m using transparency, a LOT.
As a result, ambient occlusion (I’m using Unity 5.6 Pro by the way) doesn’t actually work, despite the object not being visible through multiple layers of the transparency.
Despite the fact you, more often than not, can’t see to the end visually, Unity still ignores transparent materials as exempt from occlusion culling, meaning that form of optimisation doesn’t work properly.
Is there anything I can do to get the framerate above 20FPS on the lowest quality settings?
There’s no built in magic bullet here. The solutions are don’t draw so many layers, or potentially draw simplier layers.
Your best option is to create a system with triggers or modify something like SECTR Core that disables glass that’s far away and maybe swaps the material on some glass surfaces to an opaque. You might be able to get away with replacing the glass shader with a simplier shader, like one that just samples the cubemap and doesn’t do specular or diffuse lighting. You might even be able to use mesh LODs in that case.
I had a similar issue in my game. My game features really long corridors with many light rays along the corridor and this was causing a lot of overdraw.
My solution to this problem is to use the CullingGroup API:
… to collect visible/nearby light-rays, which in your case are the glass layers. Light rays that are farther away then X units get their renderer turned off, so there is no overdraw issue anymore.
In order to avoid object popping, I use a custom shader that fades in/out the light rays depending on the distance to the camera. So when the light ray gets enabled, it has alpha=0 and then increases alpha as the object comes closer to the camera. The same applies if the object moves away from the camera, in this case alpha decreases again to hide when I disable the renderer.
This works really well in my game, butter smooth transitions and improved performance. Not sure how well it might work in yours, but perhaps worth a try.
Thanks for the tips, I’m already using extensive LOD to massively lower the tricounts at distances beyond about 5m but this doesn’t seem to help much at all.
I wasn’t aware this API existed, I may be able to build an instantiated shader model that allows for alpha at distance.
–
When I get some free time I’ll try to implement these and see what happens, thanks for the tips