Skip to content

Performance Enhancement: GameObject Culling#2789

Open
Vwing wants to merge 3 commits into
Interkarma:masterfrom
Vwing:culled-gameobjects
Open

Performance Enhancement: GameObject Culling#2789
Vwing wants to merge 3 commits into
Interkarma:masterfrom
Vwing:culled-gameobjects

Conversation

@Vwing

@Vwing Vwing commented May 24, 2026

Copy link
Copy Markdown
Contributor

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

  • added relevant 'Object Culling' setting to Video settings (defaulted to enabled)
  • ActiveGameObjectDatabase now supports inactive object lookups (required for culling disabled objects, otherwise you can have e.g. enemies walking around in disabled dungeon blocks)
  • billboards are now registered with the ActiveGameObjectDatabase (so they may also be culled; we only bother doing so when the player is outside)
  • added CulledGameObjectManager to the game scene

* 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
@KABoissonneault

Copy link
Copy Markdown
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.

@Daneel53

Copy link
Copy Markdown
Collaborator

Will push this one into next Test3 so that we can test it.

Daneel53
Daneel53 previously approved these changes Jun 22, 2026

@Daneel53 Daneel53 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@Vwing

Vwing commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

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.
@Vwing

Vwing commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants