0
\$\begingroup\$

So I've been getting this weird bug in the Android build of this game I'm working on. There are these weird lines that all over the place. As far as I can tell, this is a visual bug. Like something wrong with a shader or the camera settings or something but I can't quite figure it out completely. Please help out if you can.

TIA.

I've attached pictures. The ones with the lines are from my phone and the one without is from the Unity Editor.

From phone #1

From phone #2

From Editor

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Z-fighting is a visual artifact that occurs when two or more objects in a 3D scene occupy the same space and compete to be rendered on the screen. This competition results in flickering, shimmering, or distorted textures, making it difficult to distinguish between the objects.

Z-fighting is primarily caused by limited precision in representing depth values in computer graphics. In a 3D rendering pipeline, each pixel on the screen is associated with a depth value, also known as a Z-value, which represents the distance from the camera. When multiple objects have similar or overlapping Z-values, the renderer struggles to determine which object should be displayed in front, leading to the visual glitch.

To address Z-fighting, there are several solutions you can try. One common approach is to increase the distance between the objects that are experiencing the issue. By doing so, you provide more space for the depth buffer to differentiate between the objects, reducing the likelihood of Z-fighting. However, this solution may not always be feasible or practical.

For a more comprehensive understanding of Z-fighting and its solutions in Unity, you can refer to the following link: Unity Z-Fighting Solutions. This resource provides additional insights and techniques to mitigate Z-fighting issues in your Unity projects.

Remember, it's always recommended to analyze your specific scenario and experiment with different approaches to find the most suitable solution for your particular case.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Thank you Seyed Morteza Kamali. Your answered helped. I changed the camera clipping values and the lines went away. \$\endgroup\$
    – abeer98
    Commented Jun 26, 2023 at 10:09
  • \$\begingroup\$ As for why this happened on Android but not on the Editor: different platforms may use different levels of precision for depth. In this case, you had more precision in the Editor than on Android. \$\endgroup\$
    – Kevin
    Commented Jun 27, 2023 at 1:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .