Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tudoraster · Aug 31, 2021 at 06:02 AM · renderingoptimizationproceduralprocedural generationocclusion culling

Unity Procedural Game Optimization

I am currently developing a 3d dungeon crawler which implements a procedural dungeon generation system which works perfectly fine. However the game is not very performant. I have tried a few optimization tricks I heard like:


  • Adding LOD Groups to each room prefab (this works perfectly fine), has impact on fps and batches

  • Tried addig static batching, I made every room prefab static and enabled dynamic and static batching in the player settings, however there is no change in the batches count or the saved batches count.

  • Tried addind occlusion culling but i cannot bake it before the game, as it's a procedural generated world.

  • The room prefabs are low poly rooms and are not even decorated yet, just the floor and walls and torches.


I should mention that i am using deffered lightning and I am activating the torch point lights as the players walks in the room. There aren't any baked lights everything is realtime. Every room prefab uses the same metrial and is not copied when the room is instantiated.


Some screenshots to help you understand better: [1]: https://i.stack.imgur.com/msoBy.png [2]: https://i.stack.imgur.com/vpuTT.png [3]: https://i.stack.imgur.com/WF6Y6.jpg [4]: https://i.stack.imgur.com/S7hQz.jpg

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Riiich · Aug 31, 2021 at 08:10 AM

According to https://docs.unity3d.com/Manual/occlusion-culling-dynamic-gameobjects.html you can add occlusion culling to static objects during runtime (static means it's not moving, even if they're "dynamically generated")

"A dynamic GameObject can be an occludee at runtime, but it cannot be an occluder."

Have you tried setting the prefab to static and seeing if the occulsion system is working at runtime?

Otherwise I'd have a look at Occlusion Areas: https://docs.unity3d.com/Manual/class-OcclusionArea.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tudoraster · Aug 31, 2021 at 08:17 AM 0
Share

That's what i came across in the first place. I have set all my room prefabs as static but i still need to go to the occlusion inspector tab and bake it. But i haven't got any meshes in the scene to bake. I will take a look at the occlusion area and come back with a response. Thanks

avatar image Riiich · Aug 31, 2021 at 08:21 AM 0
Share

@Tudoraster what about making your own system? I found this Reddit post that might be useful: https://www.reddit.com/r/Unity3D/comments/2g3nw5/occlusion_culling_at_runtimerealtime_tips/

avatar image
1

Answer by Llama_w_2Ls · Aug 31, 2021 at 02:19 PM

however there is no change in the batches count or the saved batches count.


If you set a game object to static at runtime, static batching only takes place if you call StaticBatchingUtility.Combine() on your root object. See here. For example, if all your rooms are under a game object called 'dungeon', call StaticBatchingUtility.Combine on the 'dungeon' game object after all rooms are generated. This will enable static batching and you should see your saved batches count increase, and your performance drastically improve.


Another thing to mention, occlusion culling isn't really possible at runtime. My guess would be it would be slow and costly to calculate in the first place. However, since your dungeons are small interior rooms with small hallways, you could set up a simple occlusion culling system manually, to turn off all rooms if the door is closed, for example. So any rooms with closed doors are deactivated, and if you are inside a room with a closed door, all rooms are deactivated. This might be a lot harder to implement, since you'll have to set things up at runtime, but it seems like the best solution to increase your performance.


Hope that helps

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tudoraster · Aug 31, 2021 at 03:52 PM 0
Share

@Llama_w_2Ls I implemented StaticBatchingUtility.Combine() right after the dungeon generation has finished but there is no change in the batches count or the saved by batching count. Maybe it has something to do with the fact that under my dungeon generation gameobject there are empty gameobjects which just hold the room gameobjects?

My hierarchy is structured like this: - Dungeon Generator (Where the generation script is and StaticBatchingUtility.Combine() is called) - MainBranch (just an empty gameobject which hold all the rooms prefabs that take part in the main branch from the spawn room to the exit room) - Room 1 - Room 2 - ....

avatar image Tudoraster · Aug 31, 2021 at 04:07 PM 0
Share

Ok I found out that I needed to tick write/read on the mesh properties. The batches lowered to around 150 and the saved batches jumped to 44. And when i click on the generated room prefab and look at the mesh filter it says: Combined Mesh (root: Dungeon Generator) 88. Thanks @Llama_w_2Ls. If you have any other suggestions I would really appreciate it.

avatar image
0

Answer by Tudoraster · Aug 31, 2021 at 10:21 AM

Ok i found out that the occlusion culling works at runtime if the room prefabs are set to static and it only shows how it work when you click visualize on the occlusion culling window my guess is that this is what is happening when the game is running under the hood. Thanks @Riiich, if you have any other optimization adivce, I would really appreciate it.

alt text


save.png (492.8 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Riiich · Aug 31, 2021 at 11:25 AM 0
Share

@Tudoraster No problem! Let me know if my answer was correct by marking it as the best answer :D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

155 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Optimization of Procedurally Generated Game 0 Answers

Problem with Occulusion Culling (Game hide gameobjects when the camera is inside a wall even if gameobjects are still visible) 0 Answers

Why is the CPU usage so high? 1 Answer

Optimize Occlusion Culling and Particle Systems in a House sized scene 0 Answers

Procedural Audio in 3D 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges