camera depth does not work in deferred lighting mode

Discussion in 'Unity Support' started by azuretttc, Mar 16, 2011.

  1. azuretttc

    azuretttc

    New Member

    Joined:
    May 8, 2009
    Messages:
    75
    The problem is :

    I have two cameras, A for the main 3d scene, B for renderering guis behind the main 3d scene. The reseon two use two cameras is GUITEXTURE and GUITEXT are always on top of the main scene.
    for A I set Clear flags to depth only, depth to -1, culling mask to the main 3D scene
    for B I set clera flags to solid color, depth to -3, culling mask to the layer I define for the guis,rendering path is forward.

    The problem is that if I set A's rendering path to forward, everything goes fine. If I set it to "deferred lighting", It seems only can see the 3D scene, and everything without any depth values becomes black and can not see the behind guis. Seems "depth only" does not work in defered lighting mode. Is that a bug on something?
  2. azuretttc

    azuretttc

    New Member

    Joined:
    May 8, 2009
    Messages:
    75
    If I turn off camera A, I can see the guis rendered by camera B. So I guess the contents in camrea A just occlude camera B's contents because "depth only"clearing mask does not work in deferred lighting cameras
  3. azuretttc

    azuretttc

    New Member

    Joined:
    May 8, 2009
    Messages:
    75
    has anybody meet similar problems before?
  4. azuretttc

    azuretttc

    New Member

    Joined:
    May 8, 2009
    Messages:
    75
    Is here the right place to ask or I should ask at scripting forum?
  5. Frank Oz

    Frank Oz

    New Member

    Joined:
    Oct 13, 2010
    Messages:
    1,564
    You can try, the reason I haven't responded (dunno about others reasons) is cause I can't really tell what's wrong so have nothing useful to respond with except I've not noticed anything.
  6. azuretttc

    azuretttc

    New Member

    Joined:
    May 8, 2009
    Messages:
    75
    thanks, has anybody met similar problems before? Is this really a bug that unity have problems on depth rendering in deferred lighting mode? I'm using 3.2.0f4 pro
  7. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Messages:
    187
    Hey azuretttc,
    the problem you're describing is a known issue. It is caused by the fact that the final pass of prepass rendering (so the pass that renders the geometry the second time and applies the result of the lighting pass to it) is rendered into a render texture. Then it is just blit-copied into the back buffer, overriding everything that was rendered there before.

    Fixing that problem requires some changes in other subsystems, so won't be a quick one, but it has been placed on our roadmap.

    A workaround is probably possible if the second camera (the deferred one) would render into a render texture and you would handle compositing that with the first camera's output yourself.
  8. mikemalinowski

    mikemalinowski

    Member

    Joined:
    Oct 1, 2013
    Messages:
    3
    I know this thread was started back in 2011, but it appears to still be an issue. I have exactly the same problem in that i have two camera's setup as deferred with the 'top' layered camera set to depth only. In Forward Rendering i get the composited result i'd expect but in Deferred i only see the top layer result.

    As this was raised in 2011, do you have any idea when it will be resolved? Failing that i will look at going down a rendered texture route.

    Thanks.

    Mike.
  9. ShadowK

    ShadowK

    Member

    Joined:
    Sep 5, 2013
    Messages:
    1,681
    Try to layer your camera's, let's say for e.g. you use a UI / GUI for camera to render you need a new layer to add the UI render with the correct depth to overlay. If they are both in default, the new camera will always take poll position.
  10. mikemalinowski

    mikemalinowski

    Member

    Joined:
    Oct 1, 2013
    Messages:
    3
    Hey ShadowK, the issue is not with the ordering of my render 'layers'. With all my cameras set to forward rendering i get exactly the result I expect by layering the depths of the cameras to overlay and 'see through' the top level ones.

    The issue is with the depth ordering not working in deferred rendering mode. Or more specifically the 'transparency/empty pixels' between depths.

    Sadly I am not layering for the GUI, otherwise I could just set the GUI camera to Forward Rendering. Instead my actual 3D view is made up of a couple of cameras layered atop of each other to get a very specific effect. Ideally i'd like to use deferred rendering to achieve the visual id i am after but unless I can solve this i will have to fall back to Forward.

    Is this behaviour expected?
  11. ShadowK

    ShadowK

    Member

    Joined:
    Sep 5, 2013
    Messages:
    1,681
    Not really and could be a bug as Kuba says, as I understand it lower depth camera's will render first. Now there is a specific issue that I've come across (I used deferred) which completely seems to ignore what depth you have. With Daikon forge for UI you have to specifically layer the UI or it renders over the main camera even though the depth is higher?

    Not sure how applicable it is to what your trying to do, but I thought it worth a mention.