Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

"Too many layers" in Unity 3

Discussion in 'Editor & General Support' started by John-B, Sep 30, 2010.

  1. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,259
    I just updated a project to Unity 3, and now I get this message:

    I only have 2 layers that I created (GUI and Data), the rest were already there and can't be deleted. I have three lights set to the default + GUI layers, and one light set to the Data layer only. I get the same message if I set the lights to Everything then exclude the other layers. Never saw this before updating, and I didn't change the lights.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Edit: are you setting the culling masks from a script? I've just discovered from another post that the operator precedence of + relative to << and >> is now different in JS, so code like:-
    Code (csharp):
    1. 1 << 1 + 1 << 3
    ...will behave differently under Unity 3.0.
     
  3. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,259
    Nope. Setting in the inspector. This message pops up periodically. Sometimes immediately when I change a light setting, sometimes apparently at random when I've done nothing with light settings. I've tried pretty much all possible combinations of including and excluding layers, and still get the message.
     
  4. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,259
    Now I'm getting this message in another project I'm working on:

    Again, I started seeing it after updating to Unity 3. In this case, I have 3 lights that all include/exclude the same layers. Should I just not worry about it?
     
  5. GennadiyKorol

    GennadiyKorol

    Joined:
    Jul 10, 2010
    Posts:
    107
    Noticed the same issues here.

    Wouldn't mind understanding why it happens either :)
     
  6. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    Yup. Happening here too....and object that have "Receive Shadows" unchecked continue to receive shadows.
     
  7. NTDC-DEV

    NTDC-DEV

    Joined:
    Jul 22, 2010
    Posts:
    593
    I had the same problem until I realized I was understanding the error backward.

    Ex. If layer 9 was "Lights" and layer 10 was "Render" (not affected by light). Doing 1 >> 9 excluded 1 to 8. Which is over 4...

    What I had to do is ~ ( 1 >> 10). So all except "Render" is going to be affected by lights. It did the trick.
     
  8. tomvds

    tomvds

    Joined:
    Oct 10, 2008
    Posts:
    1,028
    If you use deferred shading, you cannot use lights that exclude more than four layers. This is one of the limitations of that rendering mode. Either switch to forward rendering (if you don't need deferred rendering anyway) or for all of your lights, reduce the number of layers it ignores to a maximum of 4 (which means all but (up to) 4 layers in the culling mask must be ticked).
     
    Last edited: Oct 15, 2010
  9. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I have many layers to organize rendering, one UI, one for second camera, one for tranparent FX etc, so I definitely have more than 4 layers.

    Isn't this a real serious limitation of deferred shading?
     
    DragonCoder likes this.
  10. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The more I look into this ,this is becoming a real limitation. For organizing physics layers, we have to use GameObject Layer as well (IMO, physics should use a separate layer).

    So it's unavoidable now to have many layers to optimize the collision masks. In a basic game scene, there will already be these layers

    Default
    UI (no light)
    TransparentFX (no light)
    Projectile (no light)

    Which leaves only 1 layer left to ignore light. How is it possible to make a more complex game with deferred shading then? And point light now don't cast shadow in deferred, we are pretty screwed.
     
  11. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    The only layer I as an artist ever created was for excluding several lights in ONE scene. All the other layers came from standard Unity setup or from our programmers (one to be precise).

    To sum it all up: creating two layers in Unity Pro borks the whole light exclusion in deferred rendering?!?!?!?!???????
    I cannot express how much of a facepalm moment it was when I got that warning message and found this thread.

    Cannot stop laughing hard. Seriously. Why isn't there a separate layer management for lights? Why on earth ...ah forget about it... back to laughing hard.

    More on this topic: http://forum.unity3d.com/threads/74...exclude-objects-from-lighting.-Up-to-4-layers....

    Sorry, didn't mean to be rude, just needed to vent a bit.
     
    ModLunar and RyanFavale like this.
  12. RGravity

    RGravity

    Joined:
    Jul 4, 2012
    Posts:
    30
    Yes this does seem ridiculous - I mean why 4 anyway?
    Surely this is just masking out results from the b-tree search that all the other culling processes use.
    To me it makes deferred rendering completely useless in all but the most trivial scenes - if it's not going to be fixed then at least can we have an explanation as to why it is setup this way?
     
  13. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Points lights do cast shadows in deferred - I have lots, hard and soft shadows, no problems. (Unity 4 Pro).

    Indeed.
     
  14. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Physics and Graphics should be in separate layers. |n non trivial games, I use Physic layer a lot to optimize collision detection.
     
  15. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    No; under the deferred renderer (which is actually deferred lighting, not deferred rendering), lights are applied in screenspace, which means there's no object information anymore. The decision about whether or not to light an object gets made on a per-pixel basis, which means it can only use information available at a per-pixel level. I don't know exactly how they pack it but I think the 4-layer limitation is down to this.
     
  16. PlutoniumStudios

    PlutoniumStudios

    Joined:
    Apr 25, 2014
    Posts:
    1
    I've found a way...

    Just create three additional dummy layers and set the Culling on those extra three.

    So together with your primary, you have 4 layers. It works for me.
     
  17. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    168
    The layer limitation for light cullingmask is due to the additional light value that each light add over a rendered pixel. Adding an exception value (culling mask) is requiring the system to subtract the additionnal light value so that it ends with 0.
    (So the culling mask of the light actually add more calculation because the shadow process is an additive process similar to projectors)

    It would be great if it was possible to inverse the lights setting of a scene between additive or subtractive.

    Right now, with the additive light system, the culling mask of lights is limited to 4 layers ignored. The light auto-produce effect on all assets and the culling mask act as an exception applicator. This is quite bad for complex indoor (with windows showing lighted outsides or room) and heavily windowed areas. (Since you need to make sure that windows are ignored through the culling mask for the non-cutout transparency can be simulated)

    It is also really problematic whenever the scenes lights and shadows are downgraded in quality for performances. For example, if you do a bit of an interior that is linked to the exterior, downgrading the shadows precision actually allow light to pass through the walls.

    Having the capacity of reversing it to subtractive would makes thing a lot easier for indoor or heavily dark area. Unlike the (current) additive system, the subtractive system would not projecte any lights nor shadows except for up to 4 layers.
     
  18. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    I remember seeing someone doing this in Maya to overlay realtime shadows on top of baked skylight scene (the video's probably up on the AD Area blog still). Basically the subtractive light cancels out it's own light contribution, and you're left with a simple shadow-caster. Not exactly efficient, but an interesting workaround, and definitely preferable to light bleeding which is constantly evident in U5's lighting too. I was hoping mixed mode lights might fix this (when they're fixed), but apparently Mixed mode is only going to work on the primary (sun) direction light.
     
  19. Danny-vda

    Danny-vda

    Joined:
    Aug 7, 2013
    Posts:
    5
    yup. confirmed. Not the 4-layer limitation story, but getting this crazy error as mentioned in the first post...
     
  20. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    I got this warning too. It happpened after I added a new screenshot camera and copied the properties from the main camera, which only has the PlayerAvatar layer (that I created) excluded.

    The warning was naming a whole bunch of layers that I've never seen before nor knew they even existed. I got the warning to go away by setting the culling mask to everything, then excluded the PlayerAvatar layer again. That seemed to refresh the mask, so who knows if I had a bunch of unseen bits being set when I copied from the main camera.
     
    RyanFavale likes this.
  21. RyanFavale

    RyanFavale

    Joined:
    May 30, 2014
    Posts:
    28
    OMG, there with you bud. Lots of things to laugh about over the years. Hahaha.
     
    ModLunar likes this.
  22. RyanFavale

    RyanFavale

    Joined:
    May 30, 2014
    Posts:
    28
    I'm getting this report, I believe, from updating from Unity 5.3 to Unity 2017. Still trying to find where the error is coming from. Would be nice if Unity specified "where" their errors were being reported from. Our project is quite massive, so finding the needle in the haystack is quite time consuming in a lot of Unity warnings and error reports in the console.
     
    ModLunar and glitchers like this.
  23. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    Continues error in Unity 2020.3. Very big project. There is also no way to find it.