Skip to content

Tips

General tips for when working with ZFighter

Reducing Processing Time

For most scenes, Process Scene should take a few seconds. But because ZFighter works best when it performs a Process Scene often, take some steps early on to speed things up.

  • Adjust the Sensitivity settings. Angle settings have the largest impact, so try narrowing the angle first. Find a balance where the amount of Issues found is accurate--too broad and you'll get false positives, and too narrow may miss some z-fighting issues.
  • Use Volumes. This is the best way to focus on smaller areas at a time. See Working with Volumes Guide for more details.
  • Only Process what you need. Setting exclusions up one time will reduce processing overhead for your entire workflow, as well as eliminate clutter from your Issues List.
    • Exclude objects: anything that you know for sure isn't relevant, such as background scenery objects
    • Look at what types of objects are most often causing issues and see if there is a way to group them by material, mesh, or any other method to exclude or isolate in specific processing operations.
  • Divide and conquer with temporary exclusions
    • If you have meshes that have known problems, Exclude those by mesh temporarily until you have fixed them in an external program
    • For repeated objects with similar problems, you can use tags and layers to mark them and temporarily exclude, so you can work on specific sets of Issues at a time.
  • Work on repeated Issues first. If an Issue exists inside a prefab, fix that in the prefab so you can Dismiss the whole batch. It's helpful to sort by Size as Issues with identical sizes are usually related.
  • Use Auto-Dismiss This is a one-click easy solution to ignore large number of tiny issues.

Reducing z-fighting artifacts in your project

Z-fighting visual artifacts depend heavily on depth precision. This is limited somewhat by the platforms you will publish on. For example, desktop projects typically have higher precision than Android and mobile platforms. Adjust Unity Project Settings to match the intended platform.

In general, to have the best results:

  • Keep your camera depth range as small as possible. Set the near plane to a reasonable value, as large as is tolerable. Set the far plane to as small a value as you can (you can use fog to prevent clipping artifacts in the distance.)
  • Avoid far-from-zero issues. Keep all visible geometry as close as possible to 0,0,0 in the Scene. Unity uses floating point precision, meaning if a GameObject is at 1000m from origin, it has less precision than one at 1m. Large values will even result in flickering and jittering, as well as increased amounts of z-fighting.
  • Keep the hierarchy shallow and with parents with nice round numbers and uniform scales. Precision is lost to rounding errors when there are parents with different transform values, causing gaps and overlaps especially with modular pieces.

Optimize your visualizations

Adjust your Scene view to more easily visualize Issues. Here are some recommendations:

  • Make sure the Overlap colors contrast well with the scene. These can be adjusted in the View Options section of the Issues Tab. Make sure to also adjust the alpha.
  • When you Focus on the Issue, it centers the overlap in view. If the focus view is large but the overlap area is small, it is likely a very thin triangle that might be smaller than a visible pixel
  • Change your Scene view options as needed–we recommend the following:
    • Shaded Wireframe view This helps visualize mesh triangles, which is useful to see exactly where problems are.
    • Always Refresh toggled on (to see the Overlap blink).
    • Lighting toggled frequently on or off, whichever gives the clearest view.
    • Hide Gizmos as these often clutter the Scene view.

Master Issues List navigation

  • Click column headers to quickly sort the Issues List by Name, Type, Size, Status, etc. Click again to reverse the sort order.
  • Use the Show/Hide Properties Section in View Options to show and hide Issues in the list by various properties, to make scrolling and sorting the list more relevant to the current workflow.
  • Mutli-select to quickly annotate or Dismiss. Often Issues are repeated throughout the scene, so this can clear many of them quickly.

Fixing tips

Once an Issue has been created and understood, what is to be done to fix it? This might require some creativity! Here are some strategies for fixes and ways to prevent issues in the first place.

  • Use Unity's snapping features and tools for placement.
    • Press v to snap vertices You can snap an individual vertex of a mesh by pressing "v" while moving the object to snap to other geometry by vertex.
    • Grid snap or Increment snap tools are great for rapid layout of walls, floors, etc.
    • Third party tools Check the Unity Asset store for layout tools. There are entire systems out there that make this easy, and you'll spend less time in ZFighter!
  • Organize your hierarchy with clean Transform values. Precision issues tend to compound, especially with deep hierarchies. For objects that are intended to snap together perfectly, make sure those objects do not have parents with non-uniform scales, or long decimal places in the Transform. For best results, when objects need to align perfectly, give them the same parent and keep their transforms to as few decimal places as possible. 4.25 is preferable to 4.246849607.
  • Don't cause more issues with fixes. Tiled or repeated objects such as floor tiles, walls, or stacked objects can be tricky, as solving one Issue just causes more problems if you don't address all at once. Make sure you fix the entire area before dismissing the Issue.
  • Cover it! Sometimes the overlap can't be resolved by moving an object. Put in a pillar, plant, detail object, or even just a textured cube to hide the z-fighting. Floors that don’t line up perfectly can have a transition strip that's a little bit higher than the floor, and removing the collider on this will prevent possible player controller movement hitches.
  • Cheat the Transform. Sometimes scaling an object slightly in one dimension will help everything fit without too much visual stretching. Or just a little scootch over in a way that isn't noticeable.
  • Use wonky meshes with bevels, rough edges, or other forgiving geometry. These can intersect slightly and are less likely to be a problem than perfectly straight and flat planes.
  • Avoid large scale low-poly objects. The larger a polygon, the more likely it will z-fight. A polygon that is 100m will cause more issues than one that is 1m, due to Unity precision. Break up large polygons into smaller ones either by tiling objects, or by using a 3D modelling program to subdivide large planes.
  • Use design to your advantage. If it is too difficult to lay out your assets, design in steps, ramps, architecture details, or other ways objects can intersect at angles to prevent z-fighting.
  • Angle horizontal faces that make corners, such as wall molding. Two faces that are perfectly horizontal will always have a problem inside a corner. But if those two faces are angled down slightly, corners are no problem.
  • Try rotating objects slightly. 2 to 5 degrees might not be visually noticeable but may fix a z-fighting issue.
  • Un-flatten planes and quads. For thin flat objects that need to lay on top of other flat objects, such as pieces of paper, make them slightly crinkled or raise one center vertex slightly.
  • Use shaders to force one object to render in front of another.