Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Feb 21, 2018 at 11:26 AM by meat5000 for the following reason:

Discussions go to the forums.

avatar image
3
Question by Pangamini · Apr 08, 2015 at 08:32 AM · renderingscene-switchingparallel

The best way how to render parallel scenes?

Let's say that i want to emulate multiple parallel scenes in Unity. Everything about the game logic is solved, and my only problem is rendering now. What i need is to have many worlds simultaneously running in the unity scene, with each camera only rendering its world. What would be the most efficient way to achieve this? Some options i gave a thought:

  1. Place each subscene's origin far enough from each other

  2. Use filtering by layers

  3. Disable the subscene's root gameObject and only enable it durign the subscene camera rendering

  4. Same as above, but change layer to some invisible instead of disabling

Now none of these options is ideal, and all of them, some more obvious and clear to me than the others, have performance penalties.


Solution 1:

Pros:

  • No extra work, easy to implement

Cons:

  • Not guaranteed to stay separate

  • Floating point precision (If unity could first subtract the common root / transform of the camera and renderers, this would do fine. But it can't.

  • Probably inner engine penalties, such as octree size/depth


Solution 2:

Pros:

  • Probably optimized in the engine

Cons:

  • Limited number of layers, each scene would probably require more of them for special effects (ignoring any game logic requirement, such as collision filtering, i don't need these here)

  • For procedurally created scenes, this would require some dynamic allocation of layers and their translation, this would require either special workaround for every class that uses layers, or automatic reflection based corrections, making it slow and impractical. Also, layers are needed for so many things in the unity engine, and they are shared per purpose...


Solution 3:

Pros:

  • Technically this would work the best, no real limit for the number of subscenes, BUT

Cons:

  • Each component would receive OnEnable and OnDisable every frame. They'd need to anticipate this and handle this correctly. Still, it would make this approach very slow (i think). Even if i am disabling a single GameObject, the state is inherited by chlidren that need to be actively disabled too. Unless i am wrong, this solution is unusable.

+Alternative: Only search for and disable Renderers? Is there a big penalty for updating some trees in the engine here, or are they recreated before each camera rendering anyway?


Solution 4:

This is for now the most acceptable for me, but i don't know if there's penalty for changing object layers, if unity does some precaching or preserves some filtered lists or trees based on object layers. This would basically mean that every camera, before it renders, would change layer of all objects depenging if it wants or does not want to render it, restoring layers afterwards... By far most acceptable i don't mean ideal, I am pretty sure something would go wrong here, or it would be very slow (I'd still need to maintain some dictionary or other way of keeping the original layer of the object to be restored, I don't want to allocate memory for this every frame).


None of these seem fit for the project, mostly for performance reasons. Maybe there's some simple solution i am missing, or there are some people who have solved this by themselves. Any help will be appreciated.

Comment
Add comment · Show 13
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 Pangamini · Apr 08, 2015 at 08:54 AM 0
Share

It would be the absolute best if unity allowed overriding culling methods (for camera culling, lights, together with many other similar methods), just like, for example, OGRE engine does

avatar image Pangamini · Apr 09, 2015 at 08:21 AM 0
Share

One last bump

avatar image rich2020 · Nov 07, 2016 at 11:24 AM 0
Share

Did you ever get anywhere with this?

avatar image Pangamini rich2020 · Nov 07, 2016 at 11:34 AM 0
Share

No, not that much... The best option for my case is the layer filtering, at least for the physics (I do some layer allocation for each parallel world, replacing the 'pseudo layer' with the real one in a Rigidbody wrapper), but it's a lot of extra setup I$$anonymous$$O

avatar image rich2020 Pangamini · Nov 07, 2016 at 11:39 AM 0
Share

Ah well... $$anonymous$$y. It would be nice to have some feedback from Unity on this. Are you doing research, or is this for a game/product?

Show more comments
avatar image aphenine · Nov 07, 2016 at 01:48 PM 0
Share

I'm also interested in this.

I have a game that is so far using Option 1. This works as most of the subscenes are separated physically and will never interact with each other. I need rendering to be switched off, but I need the physics to keep going, which is important for me. So far I'm at the implementing but not optimising stage.

I've been looking into trying to generalise some of what I've written so it can be reused in different ways in my scene (and maybe with a view to releasing what I have as an Asset so people don't have to start from scratch, but I'm not remotely sold on that).

I'm still too early to offer real help, but just thought it worth saying you're not alone in doing this and I'll be watching this interestedly.

avatar image rich2020 aphenine · Nov 07, 2016 at 02:10 PM 0
Share

If you need the rendering to be switched off, can you just disable the $$anonymous$$ainCamera?

avatar image DerDicke · Dec 17, 2020 at 04:04 PM 0
Share

Have a similar problem and tried rendering with one Layer per Camera to achieve some parallel rendering. Performance wise there was zero difference... So it seems there is no parallel rendering at all.

avatar image Pangamini DerDicke · Dec 17, 2020 at 04:30 PM 0
Share

Perhaps this can be solved now by SRP? I haven't explored that yet, so It's a wild guess, but I think problems like this are the reason SPR even exists and tries to solve

avatar image DerDicke Pangamini · Dec 17, 2020 at 05:48 PM 0
Share

Back in the days switching render targets were a big thing. I noticed an hour ago the possibility to let several cameras render into the same RT (in Unity 2019.4), so I used one big texture and rendered into it. Too bad no change in performance. So rendering all cameras into one big texture is the same as rendering each in their own RT.

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Applying Theme to game ? 0 Answers

Can I render two cameras simultaneously? 1 Answer

Why does Unity render everything twice ? 0 Answers

A lot of static objects affects the performance 0 Answers

Merge what 2 cameras render 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