Performance Enhancement: GameObject Culling#2789
Open
Vwing wants to merge 1 commit into
Open
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
Collaborator
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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