Search Unity

Render texture optimizing (removing depth prepass ?) HDRP

Discussion in 'High Definition Render Pipeline' started by vjess, Jan 9, 2020.

  1. vjess

    vjess

    Joined:
    Jan 24, 2017
    Posts:
    8
    Hello,

    I'm using 8 cameras going into render textures. Theses render textures are really having a high impact on the game framerate. I'm running at 70fps and fall to 40fps with the cameras activated.

    The cameras are only rendering simple flat 2D objects in orthographic mode. I then use the resulting textures as alpha masks. So I don't need hi quality graphics from theses cameras. I've put the objects being rendered on their own layer used as a culling mask for the cameras. I deactivated every possible rendering option apart from "opaque objects".
    But nothing seems to help. I also changed the resolution of the textures, but that doesn't seem to have any impact.

    I then looked into the output of the profiler and discovered the "mask cameras" as I call them, are using a fair part of the CPU cycle. Under inspection, the "depth prepass" is taking the longest and I don't really know how to remove it.

    I'm running on Unity 2019.2.11 with HDRP 6.9.2

    Any ideas ? It feels near unusable to have render textures at that cost !

     
  2. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Enable Custom Frame settings on those cameras and turn off depth prepass.
     
  3. vjess

    vjess

    Joined:
    Jan 24, 2017
    Posts:
    8
    Unfortunately this option is already ticked off. I really don't understand why this depth prepass is still taking place.

     
  4. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,
    hmm... We have a prepass for any forward object that is rendered. Are your object "unlit" ?
    Disabling the prepass only affect the deferred opaque. Also alpha tested objects have also a depth prepass.
    How many object do you render in the prepass ?
     
  5. vjess

    vjess

    Joined:
    Jan 24, 2017
    Posts:
    8
    Yes, I just have two unlit objects. One is a simple "background image" (unlit opaque) and the second one is a custom shader graph. It's very simple, just a simple unlit and a noise to create a displacement type effect. I use theses to create a texture mask for my character (the cutout for eyes and mouth). The shader graph is used to displace the mouth of the character when he is afraid.



     
  6. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    did you ever find out how to minimise depth prepass?
     
  7. amarcolina

    amarcolina

    Joined:
    Jun 19, 2014
    Posts:
    65
    There is a gotcha where you need to turn of decals in order for the depth pre-pass to be disabled. Supporting decals forces there to be a depth pre-pass regardless of any other settings.
     
    VoidOB and radiantboy like this.
  8. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    thanks! that makes sense, shame though that will be footprints and bullet holes gone I think. Will try it, cheers again.
     
  9. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    183
    From what I tried, even a single extra camera is not even close to acceptable performance wise even with every feature turned off in the custom settings, no matter which resolution, unless you render the camera only X times per second

    The fixed camera costs are just too high

    You could try do a custom render texture which gets its data without any camera. Its not as easy but you skip all camera performance costs.