Search Unity

why clear z after update depth texture instead of using to ztest

Discussion in 'General Graphics' started by kittycon, Dec 18, 2017.

  1. kittycon

    kittycon

    Joined:
    Jan 12, 2016
    Posts:
    15
    upload_2017-12-18_14-24-25.png

    Reuse the z from depth texture may reduce overdraw, Why clear it?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,338
    Because the depth texture and the main view don't use the same shader passes so the depths may not match exactly, and the main view may be using MSAA where the depth texture is not.
     
  3. kittycon

    kittycon

    Joined:
    Jan 12, 2016
    Posts:
    15
    Thanks for reply. We can make sure the depths is the same, and we use no MSAA, is there any way we can reuse the depth?
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    No. There are other factors too, which would need supporting in the engine (eg dynamic batching decisions would have to be identical between the 2 passes).

    We would need to make changes to allow you to do this.