Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

PROBLEM: Unity Layers for culling raycast is corrupts render order

Discussion in 'General Graphics' started by kjhuebner, Dec 8, 2021.

  1. kjhuebner

    kjhuebner

    Joined:
    Oct 2, 2018
    Posts:
    16
    PROBLEM - I'm developing a multi player Unity 3D game. But the player characters are always drawn ON TOP of all background scenery, such as a tree -- even when a player character (with a greater z-depth) is "hiding" behind scenery objects in the foreground.

    Whereby the Z-depth rendering process is corrupted since the character should be occluded by foreground scenery like a tree or rock.

    Currently all the characters are on the same layer
    index= 10, CHARACTER_LAYER

    All scenery objects (trees,rocks,etc) are on the default layer:
    index= 0, DEFAULT_LAYER

    So might the solution be to NOT use "Unity Layers" whatsoever in my case?

    Then what is the point of Unity Layers if this is the result?

    My hope was to use "Unity Layers" to improve performance for...
    ray casting from character cameras by culling or ignoring the CHARACTER_LAYER,
    and ray casting from enemy characters to detect player characters on the CHARACTER_LAYER,
    and light culling by doing real-time lighting on only CHARACTER_LAYER objects, while DEFAULT layer objects use baked lighting.

    But there does not seem to be a means to do this.

    Creating another layer like "CHARACTER_LAYER" is corrupting Unity's Z-Depth rendering process.

    I hope someone has a solution!

    My Setup: Unity 2019.2.17, PC and Android target platforms.
     
    Last edited: Dec 8, 2021