Search Unity

Unity considers single mesh as 3 or 4 shadow casters?

Discussion in 'General Graphics' started by Perfecto, Oct 18, 2017.

  1. Perfecto

    Perfecto

    Joined:
    Oct 13, 2012
    Posts:
    11
    I'm trying to understand why a single mesh increases shadow casters statistics by 3 or 4.

    1. Create empty scene. Create a ground using unity 3d cube (cast shadows off). Run game and stats show that shadow casters = 0.
    2. Add a cube on top of the ground (cast shadows on). Run game and stats show that shadow casters = 3.
    3. Add another cube. Run game and stats show that shadow casters = 6.
    4. Add another cube. Run game and stats show that shadow casters = 9.
    5. Select ground, turn on cast shadows. Run game and stats show that shadow casters = 13.

    I don't know exactly what unity considers a shadow caster and I can't seem to figure it out from the docs. I assumed a shadow caster was an object that casts shadows. But according to the rendering statistics, that can't be correct since there are 13 shadow casters in the scene but only 4 objects that cast shadows.

    The docs also don't mention shadow casters in the rendering statistics so it doesn't say either.
    https://docs.unity3d.com/2017.3/Documentation/Manual/RenderingStatistics.html

    Is something not working right or am I just not correctly understanding what a shadow caster is?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    The main directional light uses cascaded shadow maps. That means it renders the shadow map for the directional light multiple times at different ranges. By default Unity uses 4 cascades, so a single shadow casting object may be rendered between 1 and 4 times depending on how the cascades overlap.

    Check out the frame debugger window.
     
    homemacai, HaruLee932001 and Perfecto like this.
  3. Perfecto

    Perfecto

    Joined:
    Oct 13, 2012
    Posts:
    11
    Thank you so much for the very quick and very helpful reply! After reading your post, I looked in the docs to learn all about shadow cascades which was exactly what I needed. You're AWESOME! Thanks