Search Issue Tracker

By Design

Fixed in 2019.1.X, 2019.2.X

Votes

0

Found in

2018.3.0b1

2018.3.5f1

2019.1.0a1

2019.2.0a1

Issue ID

1143508

Regression

No

Flickering caused by Z-Fighting With Depth Prepass With SV_Depth in Custom SRP

Graphics - General

-

To reproduce:
1) Open project attached by Julian (DepthPrepassFlickerBug.zip)
2) Play it / move mouse in and out of game view / click on empty space of game view

Expected: The scene is played without any interference
Actual: There is flickering all across the scene

Reproducible in: 2019.3.0a5, 2019.3.0a2, 2019.2.0a13, 2019.2.0a12

Reproduced with Nvidia Geforce GTX 750 Ti, GTX 980m, GTX1080
Partially reproduced with Nvidia Geforce GTX 1060 (3GB) - there is a single flicker on play, but then it no longer happens
Not reproduced with Radeon (TM) Pro WX 9100

  1. Resolution Note:

    Hi, this bug is being resolved as by design. Looking into it this is what we are seeing:

    The shader consists of two passes, a depth pass and an opaque pass. The compiled shader code that gets uploaded to the GPU can be seed in the file shaderdiff.png (fragment only as vertex pass is the same). The only change between the two passes is that we move a color value to the output register.

    The other point to not is that the scene uses a relatively extreme near -> far plane (10cm -> 20km). Looking at how depth gets encoded when the plane is this far out leads to utilizing parts of the depth buffer that have low precision (see extremedepth.png). When there is low precision there is a greater chance of z-fighting.

    Now this is where things get interesting. If you make the depth pass use the 'frag' shader instead of 'frag_depth' it works as expected (it will use the same program on the GPU, instead of the other program). From looking at it from this angle it seems as if the two programs are optimized slightly differently by the GPU driver which likely leads to a difference in depth calculation and a different result. Modifying the far or near plan also results in this not being an issue (it is likely only a small difference in the optimization path). This is not something Unity has control over and is why different results can be encountered on different hardware and driver combinations.

    Our recommendation to work around this issue is to modify the near / far planes to not be so aggressive or to force both paths to use the same shader.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.