Z fighting, what options do I have?

Hey!
I’m working on a project for a customer, where I’m having problems with z-fighting

Here is a stage build: campus Albano

As you can see when you move the camera around the ground and buildings fighting.

What steps I’ve already tried:

render groups
I tried setting the buildings in it’s own render group, but that introduced another problem where because of the building being below the ground in some places, it would not render correctly.

material.useLogarithmicDepth
I though this might help. tried setting it on both the buildings and the ground, but it also rendered strange
And I could not see any improvements

material.zOffset = -2
Tried setting zOffset on the loaded building materials, but without any change.

It seems that the z fighting is

Any suggestions on how I can improve the Z-handling?

1 Like

What are your camera minZ & maxZ ? (And first, is your scene - which looks nice by the way - using real scale?)

I love the scene!! really cool…You should add it to our homepage!

1 Like

Hi guys. Nice scene. Mostly problems where terrain meets building… but some problems on roofs, too.

Over in another thread, I used some “rays” to get measurements from one mesh… to the surface of another. The ray’s pickingInfo object, besides knowing distance to “hit”, also reports the hit mesh (pickedMesh).

SOOooo… imagine this: Move a box (iterate/step) along every vertex-point of the ground, but 5 units below it. Shoot a ray upward into the ground. IF the pickedMesh !== ground, then a building/model is lower than the terrain AT THAT POINT. (a z-fighting causer).

IF a bad point is found… create a red sphere and place it at that terrain position/vert. (a marker, for where terrainpoint.y work… needs to be done)

IF you use multi-pick… maybe you can get a “pick hit” from BOTH the building AND the terrain, and you can determine how much difference between their Y-positions… and lower the terrainPoint.y THAT amount. It’s sort of a like… “Auto-Contour-Terrain-To-Building-Foundations”… the legend begins. :slight_smile:

Ok, it’s probably a bad idea… but it sounds easier than hauling it all back into the modeler and tweaking stuff in there. :open_mouth:

I bet it’s a min or max z issue. Like @Vinc3r is hinting at. I can’t get it to work on my iPhone though, but in the past I’ve had that issue.

really nice scene !

Yes the scene is real scale.
The whole ground plane is about 1200 meters
and the skybox is 3000 meters

zMin was the problem for the z-fighting once I changed that to 3 meters most of the artifacts went away :slight_smile:

@Deltakosh once I’m finished with the project, I’d be glad to showcase it on the homepage :slight_smile:

@Pryme8 I’ve added pepjs, so now the interactions work. But something else is really wrong, because on my ipad the scene looks like crap. Will have to investigate further there.

Can’t wait!