Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Depth prepass expensive

Discussion in 'Universal Render Pipeline' started by SXY1997, Jan 25, 2021.

  1. SXY1997

    SXY1997

    Joined:
    Apr 8, 2018
    Posts:
    18
    Hi,
    When I tested the game demo, I found that the depth prepass consumption was very high. I used RenderDoc to debug and found that the depth prepass took up 30% of the consumption, and found that MSAA and SSAO would force the depth prepass on, otherwise Copy Depth would be used, and now I can only give up MSAA and SSAO. Can anyone give some optimization suggestions?
     
  2. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    This is just a fact of the implementation of SSAO. You need to generate a DepthNormals before you render so that you can sample the correct values when drawing opaques.

    If you really cant afford this then you could either try to render with last frames depth values(These are generated for free by drawing opaques, you can blit _CameraDepthAttachment or _CameraDepthTexture to a buffer to use as input for SSAO next frame) though this will mean that the SSAO will ghost by 1 frame. Otherwise you might need to look for some sort of Screenspace post-process rather than AO that is drawn during object rendering
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    % is not what you want to look at on profiler. That 30% will shrink rapidly once other things take a bigger slice. What is the time ms taken for this function? It should be in the range of a couple of millisecs for hardware that can utilise it.
     
    CianNoonan likes this.
  4. SXY1997

    SXY1997

    Joined:
    Apr 8, 2018
    Posts:
    18
    Thank you, I will look for other ways to achieve AO.
    This is the information I got in RenderDoc.After that, I conducted a series of tests and found that DepthNormalPrepass will be turned on after SSAO turns on the normal mode. To my surprise, DepthNormalPrepass consumes less than DepthPrepass, but the frame rate did not change significantly.Does this mean I am getting the wrong information?
     

    Attached Files:

  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What does the unity profiler say? it's often a case where something is profiled but something else pads it out, especially if it's a dependent function. 3ms for it seems like you must be on really weak hardware or doing something huge, could you supply more information?

    At this point my mind is thinking you probably have 2000+ draw calls and a lack of optimisations / vert bound for a depth prepass to actually cost 3ms.
     
  6. SXY1997

    SXY1997

    Joined:
    Apr 8, 2018
    Posts:
    18
    This is the data obtained by the profiler.
    Yes, there are many objects in my demo.
     

    Attached Files:

  7. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    You should look at the GPU profiler, the CPU is spending a lot of time there waiting on the GPU