Performance Enhancement: GameObject Culling#2789
Conversation
* added relevant 'Object Culling' setting to Video settings (defaulted to enabled) * ActiveGameObjectDatabase now supports inactive object lookups (required for non-buggy culling) * billboards are now registered with the ActiveGameObjectDatabase (so they may also be culled) * added CulledGameObjectManager to the DaggerfallUnityGame.unity scene
|
Thank you for sharing your improvements back to the main repo. I admit at this stage, I'm a bit hesitant to add a new bunch of unknowns into the build, but this is also more in Daneel's hands, so that's his call whether he wants to add a new round of testing with your latest PRs. I'm aware these have been played on Android for a long time, but it was also on another Unity version, and I'm not sure I can trust Unity to not have weird inconsistencies in runtime behavior between even minor versions. Again, leaving this to Daneel. |
|
Will push this one into next Test3 so that we can test it. |
Daneel53
left a comment
There was a problem hiding this comment.
Pushed into Test3, no remark.
…e queries This fixes already-built mod compatibility, so mods that use these methods don't need to do a rebuild.
|
I changed the public method definitions for ActiveGameObjectDatabase.cs in the original implementation of this, which ended up breaking already-built mod compatibility, requiring a rebuild for affected mods. Now I have changed them back to how they were, but with an overloaded method containing the 'includeInactive' bool this feature required. This should restore mod compatibility. |
* calculate block proximity using horizontal X/Z distance only * prevent tall or deep dungeon geometry from being culled when nearby horizontally * This is a fix for areas in the game with deep geo like the Mantellan Crux; users were reporting culled platforms that remained invisible even when they stood on them.
|
Squeezed in another fix. Users on the Android version of DFU were reporting that platforms were invisible in the Mantellan Crux. Looking at the game data, it seems that those platforms extended below the assumed bounds of RDBs, which meant that they were culled even when you were standing on them. So the fix, here, is to ignore vertical distance when culling dungeon blocks. The platforms should now be visible. |
Performance Enhancement: GameObject Culling
This feature has been part of the Android fork for the past couple years. It greatly improves performance on mobile, and the performance gains are pretty great on desktop as well.
On my machine in the Wayrest dungeon with culling disabled, Profiler shows constant stuttering to 30fps and an occasional 15fps lag spike. With culling enabled, it stays closer to 60fps, occasionally spiking to 30fps. The remaining lag is due to AutoMapper, which is optimized in Android and I'd like to open a separate PR for that.
How it works
The CulledGameObjectManager disables Billboards, Foe Spawners, Enemies, Action Doors, Static NPCs, Loot, and Dungeon Blocks that are further than 2060 unscaled units away from the player. It does so by moving them under a disabled game object parent, so that their local enabled/disabled state is unchanged.
It culls these object types on separate frames, which helps smooth out any lag from enabling and disabling a ton of GameObjects all at once.
Implementation Notes