decentraland / unity-explorer

Apache License 2.0
8 stars 11 forks source link

[QA] Clipping Issue on Roads and Scenes from a Distance #1790

Open Ludmilafantaniella opened 4 weeks ago

Ludmilafantaniella commented 4 weeks ago

Explorer Alpha build versions:

Issue Description:

There is a clipping issue affecting roads and certain scenes when viewed from a distance. This issue causes visual artifacts where parts of the scene or roads do not render correctly.

STR:

  1. Navigate to the top of the AirDrop tower at coordinates -6, -18
  2. Observe the roads and surrounding scenes from a distance.
  3. Note the clipping artifacts and inconsistencies.

Current behaviour:

https://drive.google.com/file/d/1GFwakV7U5-NuwTumJ3bYZIZ1w7Q8rGT0/view

olavra commented 3 weeks ago

Can we render the floor of the satellite map in a different layer so it does not ever collide with the LODs or scene geometry?

QThund commented 3 weeks ago

This z-fighting issue occurs due to a lack of precision in the values stored in the Depth buffer (which are used to determine whether pixels should be occluded or not). Values are not stored linearly so those produced by geometry that are closer to the near plane of the frustum are more precise. When the engine renders the geometry of objects that are too far from the camera and too close to each other (like the road and the satellite view plane, in this case), the depth values of both geometries are almost equal so comparison among them to know which should appear in front of the other fail. The solution @olavra proposes may be the cheapest and most appropiate.

QThund commented 3 weeks ago

Another option could be rendering the satellite view plane the first without writing to the Depth buffer (or writing the max value), which has the same effect (everything drawn later will appear above the plane without conflicts).

QThund commented 3 weeks ago

In both situations we will be using more GPU of course (not a big deal), as pixels rendered by the satellite view plane will not be discarded when other triangles occlude them, they are written always. If we are using early depth testing (I don't know) then that means that the fragment shader of the so far occluded pixels will execute now.

QThund commented 3 weeks ago

Here is a video that helps to understand the issue (it shows the depth buffer in a place where the z-fighting is happening due to both planes are too close and produce the same depth value): https://drive.google.com/file/d/1fpy-G74yAt-an8NIEa1ffJy1o-S-WLYm/view?usp=drive_link

QThund commented 3 weeks ago

In the end, after exploring the mentioned proposals and studying how the rendering systems work, we came to the decision of just offsetting the satellite view planes.