# Separate Physics and Rendering layers

**URL:** <https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444>\
**Category:** Physics\
**Tags:** Physics\
**Created:** [November 21, 2017, 1:08pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444 "2017-11-21T13:08:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [November 21, 2017, 1:08pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/1 "2017-11-21T13:08:45Z")

</div>

[https://feedback.unity3d.com/suggestions/separate-physics-and-render-laye](https://feedback.unity3d.com/suggestions/separate-physics-and-render-laye)

It is a longstanding Unity issue. Layers are used for both Physics and Rendering. This is probably fine for small games but when you start creating custom rendering buffers you can really run into corners. Basically for few games I made in the past (Hard West, Ancient Space) I just couldn’t do certain graphics features due this limitation. I just had to cut them out.

The only solution for separating graphics and physics layers is to duplicate your gameobject and assign different layers to each duplicate. That is not acceptable in a complex game due to performance reasons (you are adding considerably large amount of new gameobjects). Imagine doing that for 20 skinned characters (I am not even mentioning the need of syncing animations for each duplicate). I just don’t see a reason why layers would be shared between physics and rendering. And also, why one object can be only assigned to one layer? That is a mystery to me.

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [November 22, 2017, 9:20pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/2 "2017-11-22T21:20:07Z")

</div>

OK, that’s an actual production example explaining why this is important for me.

> **[Check Out... Hard West (Gameplay)](https://www.youtube.com/watch?v=rgF9GKE1HXc%7Cstart=1712)**
>
> Hard West is a turn based strategy game set in the Wid West. Let's check it out.Hard West Website: http://playway.com/index.php?option=com\_content&view=artic...

That video is time-stamped.

During a production of this game we had two “dimensions”, only one visible at a time. One called Normal and another one called Nightmare. We were switching rendering between dimensions by assigning different objects to either Normal or Nightmare layers. So if Nightmare dimension was being shown, Nightmare layer was rendered and Normal was excluded. This was also used for physics for obvious reasons - we didn’t want to do raycasts or interact with currently invisible layer. That worked well.

What was not actually working well were custom render buffers. I wanted to implement screen-space subsurface scattering for characters and foliage. Normally I would assign all foliage to a custom layer called Foliage, render SSS textures into a buffer and do some light calculations in a shader. Easy. What I couldn’t actually do is exactly that - assign all foliage to a new layer. This is because we already had to assign all gameobjects to either Normal or Nightmare layers.

But I could have used tags, right? Not really as they were already being used for gameplay purposes.These days I think I could achieve similar results with command buffers but they significantly more time to setup due to lack of proper examples and something you just need that simplicity which layers offer.

Another issue we had and I don’t see that being solved with latest Unity is assigning objects to different physics layers. Basically, we wanted to trigger destruction for each object being touched by a weapon’s bullet passing by. I wanted to use physics for ragdolls of debris. Super easy but for various gameplay reasons I could not have any colliders on Normal nor Nightmare layer. This means I needed my own physics layer to which I would assign my colliders to interact with.

So the issue was that we had this Normal and Nightmare dimensions which we were switching between. Let’s just say I have a destroyable crate which is seen only in Normal dimension and is constructed out of 6 individual pieces

- I had to create 6 gameobjects rendering components only, assign them to Normal layer
- To each piece I had to add a child object with colliders only and assign them to Normal\_VFX layer so that I would be interacting with proper physics objects
- That’s a total of 12 gameobjects in best case scenario

Let’s say that now I need to use the same destroyable crate in both Normal and Nightmare dimensions. I would have to:

- Create 6 gameobjects with rendering components only, assign them to Normal Layer
- Create 6 child objects with colliders and assign them to Normal\_VFX layer
- Create 6 child objects with rendering components only, assign them to Nightmare layer
- Create 6 child objects with colliders and assign them to Nightmare\_VFX layer
- That’s a total of 24 gameobjects

All these problems would be solved if we could only assign the same gameobject to few different layers or have separate rendering and physics layers.

---

<div class="post-metadata">

**Author:** ![PhilSA](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/philsa/32/146334_2.png) [@PhilSA](https://discussions.unity.com/u/PhilSA)\
**Post date:** [November 23, 2017, 1:58am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/3 "2017-11-23T01:58:38Z")

</div>

+1 for this

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [November 30, 2017, 1:20pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/4 "2017-11-30T13:20:41Z")

</div>

Can we get an official Unity clarification on on that? Normally I would not push so hard for an official response but Unity staff always suggests putting a feedback ticket. One was created in 2011 and has 278 votes so far so what else there is for me to do?

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [December 4, 2017, 8:39am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/5 "2017-12-04T08:39:37Z")

</div>

Bump.

---

<div class="post-metadata">

**Author:** ![SpAM\_CAN](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/spam_can/32/312610_2.png) [@SpAM\_CAN](https://discussions.unity.com/u/SpAM_CAN)\
**Post date:** [December 5, 2017, 3:19pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/6 "2017-12-05T15:19:48Z")

</div>

This has been a requested feature since 2011, and they’ve ignored it repeatedly. I doubt it’s gonna happen, though I’d certainly love for this to be added. It makes zero sense that physics and rendering are linked like they are.

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 5, 2017, 3:25pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/7 "2017-12-05T15:25:55Z")

</div>

But physics and rendering isn’t coupled - only in your mind. Just abstract it with your own naming scheme.

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [December 6, 2017, 8:45am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/8 "2017-12-06T08:45:40Z")

</div>

> [@hippocoder](#):
>
> But physics and rendering isn’t coupled - only in your mind. Just abstract it with your own naming scheme.

Not sure if this is irony or not so forgive me if it is 😉

Physics and graphics are coupled simply because you use the same layer system for both camera culling and physics channels. If you need a gameobject to be placed in Layer A which would be used for camera culling but you need it to be using Layer B for physics, both at the same time, you need to clone this gameobject, place one copy into Layer A, and another one to Layer B. This way one can be culled by the camera and the other can be used for physics. Like I said - not a problem for a small game but for something larger with complex physics and culling setup aaaand large amount of gameobjects, this spins out of control quite fast. Have I mentioned that maximum amount of layers allowed is 32?

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 6, 2017, 10:39am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/9 "2017-12-06T10:39:20Z")

</div>

Don’t forget light culling. Although you only get (4?) of those to play with.

Not sure why Transparent FX is sitting next to Ignore Raycast. They must really get along like best buds. I’m sure Unity was extremely pro about this part!

Why can’t we even change 8 of them? That alone would help a lot. But it is what I meant by being able to repurpose their meanings. The entire thing is illogical and I think, for Unity’s convenience more than ours.

HAVING SAID THAT… I don’t actually use more than a handful of layers in all the projects I’ve used, big and small. Because I generally design things that don’t rely on Unity systems all that much (it is usually just used for physics only).

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [December 7, 2017, 11:35am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/10 "2017-12-07T11:35:18Z")

</div>

Is there anyone watching physics forums? What’s the purpose of it if noone from Unity staff is watching it? It looks quite dead. Sorry if I am being too rude but it seems that some Unity regions have better community support then others. For example communicating with particle system developers is really easy and straight-forward whilst getting any information on terrain system or physics is basically impossible.  
@Adam-Mechtley@MortenSkaaning@yant

@hippocoder  
Would you mind sharing your secret on how did you abstract from Unity’s layers?

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 7, 2017, 11:51am UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/11 "2017-12-07T11:51:56Z")

</div>

Well I just reuse the blank ones, ‘reserved’ ones and have a class of constants instead so the actual names don’t matter. I admit it’s of limited use to some, and it’s stupid that Unity mixes physics and rendering. Although I’m struggling to find a situation where I can fill it up - even in complex titles over the last 8 years or so I’ve been doing stuff in Unity.

Even if I don’t have a problem with it, I recognise it’s a problem for a lot of people and the design is absolute nonsense. Water layer mandatory? Really, Unity? since when do people even desire Unity’s water? or use it? These layers should never, ever be shared with Unity internals anyway.

I guess it basically is one of those neglected areas of Unity. It works fine, it’s just lower priority I suppose.

---

<div class="post-metadata">

**Author:** ![thibouf](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@thibouf](https://discussions.unity.com/u/thibouf)\
**Post date:** [December 12, 2017, 1:36pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/12 "2017-12-12T13:36:27Z")

</div>

Just found this thread and wanted to add one voice here… What a strange design decision …

---

<div class="post-metadata">

**Author:** ![Peter77](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/peter77/32/561199_2.png) [@Peter77](https://discussions.unity.com/u/Peter77)\
**Post date:** [December 12, 2017, 1:44pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/13 "2017-12-12T13:44:07Z")

</div>

It’s a really good (real-world) example that varfare gave, why separating layers makes sense. Too bad Unity staff isn’t responding or perhaps not even looking at this thread.

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 15, 2017, 12:18pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/14 "2017-12-15T12:18:54Z")

</div>

I’m 100% sure they know but there is not much user pain from this. Just vague examples and plenty of workarounds. You can see why it’s not high priority.

I’ve just had to moderate laurent posting links to this thread in the beta forum for 2017.3 (which I deleted cos there’s a time and a place for nagging and it’s totally unrelated to beta), there needs to be more actual ship stopping issues for it to get bumped up in priority.

---

<div class="post-metadata">

**Author:** ![yant](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/yant/32/44182_2.png) [@yant](https://discussions.unity.com/u/yant)\
**Post date:** [December 18, 2017, 3:19pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/15 "2017-12-18T15:19:19Z")

</div>

Hi,

Yes, we’ve been using this shared layering system for a while now. When introduced, it used to be a natural and a pretty convenient tool in helping developers to learn parts of Unity, where features that looked similar were actually shared so one had to learn the same concept only once and for all. It’s clear though, that the approach is fairly limiting these days. As it was noticed above in the thread, we don’t allow for assigning GOs to multiple layers. We also use bitmasks for filtering, so there is a natural limit to the amount of layers we can afford, being the amount of bits a certain type of a processor word has. It’s 32 at the moment, and could probably be bumped up to 64 should we allow to deprecate a few platforms. I reckon it’s a stretch anyways.

That said, there were a number of options considered. One particular interesting was to make it so that each physics object could belong to multiple layers at the very same time. A simple, mask-based, physics query could then be used to discover all objects visible to camera, but not NPC-produced projectiles for example. At physics team, we were discussing that with the editor folks to align our roadmaps and make sure we don’t do the same work twice but in a slightly different way. As a result, it’s clear we need to start working on that, but the dates are not quite finalised yet. That’s why there might be some perception of the problem being ignored while it’s definitely not the case at all. Going to get that done for sure.

Hope that helps.

Anthony,  
R&D Physics

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 18, 2017, 3:21pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/16 "2017-12-18T15:21:28Z")

</div>

I would just like to set up what is colliding with what layer in code as well, seems a bit painful just using the editor.

---

<div class="post-metadata">

**Author:** ![yant](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/yant/32/44182_2.png) [@yant](https://discussions.unity.com/u/yant)\
**Post date:** [December 18, 2017, 3:25pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/17 "2017-12-18T15:25:28Z")

</div>

Yes, sure. I guess two objects could be passed to the broadphase for the collision computation once their masks being &-ed give a non-zero value (i.e. if they belong to at least one common layer). The old pair-wise collision ignorance should be remained as is I think. That would give the full scripting coverage as well as full editor coverage. Makes sense?

---

<div class="post-metadata">

**Author:** ![hippocoder](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/hippocoder/32/442865_2.png) [@hippocoder](https://discussions.unity.com/u/hippocoder)\
**Post date:** [December 18, 2017, 3:35pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/18 "2017-12-18T15:35:27Z")

</div>

Sure, if the performance is the same, I’m happy.

---

<div class="post-metadata">

**Author:** ![yant](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/yant/32/44182_2.png) [@yant](https://discussions.unity.com/u/yant)\
**Post date:** [December 18, 2017, 3:48pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/19 "2017-12-18T15:48:53Z")

</div>

It’s an indirection right now to do a linear table lookup alongside a few bitwise operations. Should be just a bitwise operation in the future, so I’d expect it to perform even better.

---

<div class="post-metadata">

**Author:** ![varfare](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/varfare/32/177560_2.png) [@varfare](https://discussions.unity.com/u/varfare)\
**Post date:** [December 19, 2017, 1:06pm UTC](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444/20 "2017-12-19T13:06:19Z")

</div>

> [@yant](#):
>
> Hope that helps.

Sure it does! Thank you for the reply.

> [@yant](#):
>
> but the dates are not quite finalised yet

Would it be safe to assume that this might appear sometime next year? Or is it something in the back of the backlog?

[Next page](https://discussions.unity.com/t/separate-physics-and-rendering-layers/683444.md?page=2)
