Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Camera Culling Mask layers only work when default is included

Discussion in 'Editor & General Support' started by TeamDefiant, Nov 19, 2020.

  1. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    Hello, I'm working on a game which has NPCs in it. I have a system to take a mugshot of the NPCs face to be used in UI, but I don't want any of the environment to get in the way. (The creation of the mugshots happens on level load, so the NPCs could be anywhere in the map.)
    I've created a layer specifically for the mugshots and move every gameobject the NPC contains into this layer when taking a picture so that only the NPC and any background image I want is included. (The NPCs layer is then reverted to whatever it was before) This system works fine. I can create a mugshot just fine, and the NPC moves layers as it should.

    What I'm having trouble with is that if I set the cameras culling mask to be the mugshot layer only, I only get the background image and not the character. (The mugshot camera rig consists of the camera, a foreground UI image, and a background UI image. The rig is then positioned at the NPCs location/rotation placing it between the foreground and background UI elements.)
    If I include the default layer, then I get the NPCs image, but also any scenery which might be in the way.

    I know for a fact that the layers are set correctly, I can check during runtime and see that the NPC is entirely on the mugshot layer, as is every part of my mugshot camera rig.

    Why does it only work when I include the default layer? This is not the behaviour i'd expect or want!
     
    maxkcy likes this.
  2. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    Additionally, the main camera (which is on the default layer) can also see the NPCs when the mugstot rig is active, even though the NPCs should not be visible to the main camera. (Specifically removed the mugshots layer from this camera.)
     
  3. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    Anyone? No-one having the same issue or knows of a solution, or can point out what I might be doing wrong?

    [EDIT] I think the GPUInstancing currently in use is the cause of the NPC not moving layers. I think this is the cause of my issue therefore consider this question answered.
     
    Last edited: Nov 20, 2020
  4. timzydee

    timzydee

    Joined:
    Mar 18, 2013
    Posts:
    8
    I am seeing this issue as well.
    My setup was working fine in 2020.3
    But now I am in 2021.2, which uses new cameras, and is no longer working as expected
    I can't just select a custom layer to show in the culling mask, it must include Default. Which is not good as I don't want to see things on the default layer only my custom layer.

    Did you ever find a solution? I don't know what you are referring to with the GPU instancing comment. Does it have to do with shaders? All of my shaders were created in Shader Graph.
     
    maxkcy likes this.
  5. murgntheurgn

    murgntheurgn

    Joined:
    Oct 12, 2019
    Posts:
    8
    Using 2022.3.3f1, Camera culling masks don't work on any layer unless default is selected. Can't find a fix
     
    maxkcy likes this.
  6. LuisFCle

    LuisFCle

    Joined:
    Nov 27, 2022
    Posts:
    1
    I'm experiencing this issue also, I'm guessing there's no fix yet to this?