1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Reddit AMA with Adam Myhill on Cinemachine, Thurs July 27 - 10AM PT. More info.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  7. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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:
    951
    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:
    951
    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:
    951
    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:
    98
    Noticed the same issues here.

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

    nm8shun

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

    PolishRenegade

    Joined:
    Jul 22, 2010
    Posts:
    586
    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,532
    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?
     
  10. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,532
    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:
    519
    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.
     
  12. RGravity

    RGravity

    Joined:
    Jul 4, 2012
    Posts:
    29
    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:
    836
    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,532
    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

    Insert bacon, receive bugfix Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    3,772
    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. myasinay

    myasinay

    Joined:
    Oct 16, 2012
    Posts:
    6
    Hi guys.
    Now I'm trying to tell why you get this error.
    You have to mesh renderer for seeing shadow on it.
    I can see you with images.
    [​IMG]


    [​IMG]


    [​IMG]


    [​IMG]


    [​IMG]




    I hope this will help you.
     
  18. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    65
    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.
     
  19. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    836
    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.
     
  20. 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...
     
  21. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    357
    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.