Search Unity

How to use early z in unity

Discussion in 'General Graphics' started by hellengoodd, May 22, 2020.

  1. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    I know that early z can be implemented in two ways.

    the first by using two passes, and the second by sorting objects and rendering them from near to far.

    But what I want to ask is:

    1 Which way is unity used?

    2 or is it unity that didn't help us implement it, we need to implement it ourselves?

    3 If we need to do it ourselves, who has an example
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,026
    hellengoodd likes this.
  3. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    But I did an experiment, as shown in the GIF, where the green one was the first, the red one was the second, the yellow one was the third, and the blue one was the fourth, and unity didn't sort them GIF.gif
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,026
    Yes, rough front-to-back :)
    This means that objects are not guaranteed to be in a strict front-to-back order, but close to that.
     
  5. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    I see. Thank you. I think it would be better for me to make a pre pass, so as to maximize the performance of early z.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,026
    I don't think it's possible in the built-in pipeline, but afaik Universal RP used to have it for shadows.
    If you really really need it for built-in and you don't have too many objects, you can sort them manually.
     
  7. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    If I had the prepass or sort them manually, how can I see the effect, or the impact of these changes, for example, I switch to overdraw mode in the scene, then will there be a change in the picture QQ截图20200523170439.png
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,026
    well, there should be a change in this mode, yes :)
     
  9. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    I have sorted them manually, as shown in the GIF, but the overdraw diagram has not changed:( 2222.png 3333.png 4444.png GIF.gif 1111.png
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,026
  11. hellengoodd

    hellengoodd

    Joined:
    May 31, 2017
    Posts:
    51
    aleksandrk likes this.