Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to attach one depth buffer to two different render target?

Discussion in 'Graphics Experimental Previews' started by watsonsong, Mar 4, 2018.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    In my render pipeline, after I finish the post process for opaque objects, the depth buffer is missing for render transparent objects. So I have to copy the depth buffer from the opaque to the next render target by using a blit with copy depth shader, just as the LightWeightRenderPipeline did.
    But the depth buffer is the same, why should I copy it? Can I create a depth buffer and attach it to both render target? That may be better for performance?
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    Why the Lightweight copy depth for the scene view camera?

    if (sceneViewCamera)
    CopyTexture(cmd, CameraRenderTargetID.depth, BuiltinRenderTextureType.CameraTarget, m_CopyDepthMaterial, true);


    If the scene view need the correct depth buffer, why not just bind it?
     
  4. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    @Tim-C I met the problem is a write a simple pipeline without the pre-depth pass. And I found the game view is OK, but the gizmos in scene view is render incorrectly for there is no depth information. The gizmos always render on top of everything. And the preview camera is always black.

    Besides, the UI Canvas using Screen Space - Camera and World Space - Camera can not render any thing.
    Is there any logic I am missing?