Back to the Shapespark home page

Z-fighting, but only in large scene

We’ve been working with Revit and Shapespark for a while, and are struggling with blinking or Z-fighting as I understand it’s called going from other forum posts. It seems like a known problem that two walls for instance with different surface materials placed next to eachother, can produce this blinking effect when looking at the model from a distance. Even though the walls are not overlapping. For a Revit standpoint it’s perfectly normal to model roofs and walls with multiple elements, to get a better detailing.

We found a fix for this which was to make sure that both elements have the same surface texture. Then the blinking between the two materials doesn’t seem to occur. We did this for the roofs and some walls. In our case the model is quite large, and consists of multiple separate Revit models. Here’s the issue:

When exporting the individual buildings to Shapespark, the z-fighting issues are resolved. But in the larger Shapespark file, containing all of the buildings, the issue is back. See pictures. This is the same building behaving differently in the two Shapespark scenes.

Let me know if I should make the files available.

image (1)

z-fighting is caused by insufficient precision of arithmetic calculations performed by the graphics card. The precision can be improved by increasing the camera near distance, that is the distance from the camera in which triangles are not rendered (the improvement happens at the cost of making triangles very near to the camera not visible).

To increase the camera near distance create a body-end.html file in the scene directory Documents\Shapespark\<SCENE-NAME> with the following content:

  WALK.CAMERA_WALK_NEAR = 0.01;  // applies to walk views
  WALK.CAMERA_ORBIT_NEAR_FROM_1M = 0.01;  // applies to orbit/top views

and play with increasing the values a bit. The snippet in the body-end.html file is applied only when the scene is opened in the view mode (by clicking the scene thumbnail), so you won’t see the changes in the editor.


@wojtek This works perfectly! But am I correct in assuming that this also affects collision detection? I.e. increasing WALK.CAMERA_WALK_NEAR to much will make it more likely that you can walk through objects (like walls)?

Yes, in the walk mode increasing the near distance too much can affect the collision detection.

In the orbit mode collisions are not recognized, so the issue is not present.

1 Like