How to use early z in unity

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

Object are sorted in a rough front-to-back order for the opaque queue by default: Unity - Scripting API: OpaqueSortMode

1 Like

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 them5888252--627536--GIF.gif

Yes, rough front-to-back :slight_smile:
This means that objects are not guaranteed to be in a strict front-to-back order, but close to that.

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.

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.

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 picture5888741--627647--QQ截图20200523170439.png

well, there should be a change in this mode, yes :slight_smile:

I have sorted them manually, as shown in the GIF, but the overdraw diagram has not changed:(5891195--628067--2222.png5891195--628076--3333.png 5891195--628082--4444.png 5891195--628061--GIF.gif 5891195--628064--1111.png

:frowning:
Sorry, I thought it’s more useful than it is: SceneView "Overdraw" mode is misleading

Thanks, this link was useful for me and I found places to look at overdraw in renderdoc:)

1 Like