How do I avoid z fighting on my meshes when viewed from a distance?

My walls on my modular pieces are supposed to be made of plywood so I have to keep them relatively thin. The walls are 10cm thick with 2x4’s butted up against the inside rear face of the wall. Up close, everything renders fine but when I look at it through the scope a few hundred meters away, I see z fighting. Making the walls thicker solves the problem but that doesn’t fit with the design. Any Ideas?



Thanks

1 Like

Z-fighting happens when there is too little depth data available, you can adjust this better for your game by changing the near and far clipping plane of the camera. The current version of Unreal Engine (4.4) doesn’t have a way to set it from within the editor. You can adjust an overal value for your game in Engine.ini:
[Engine.Engine]
NearClipPlane=20.0

I would assume there is also a FarClipPlane variable, however, I did not try it out. If you need to change it dynamically, you got to dive into c++.

If you don’t want to change your camera, or can’t, you need to adapt your art to make sure it supports the distance. So thicker walls, or make sure the wooden beams are separated so they can be culled away properly.

I changed the NearClipPlane from 10 to 30 and it looks great!
Thank you.

Cool, but make sure the wall does not disappear when you stand close to it. Because now it is basically not rendering anything within 30 centimeters from the camera. Which might be okay, but it might break the game.

Personally I’d vote for just not rendering the inner beams when you get that far away. Have another LOD of the mesh without the inner beams and set the lod distance to about 50m or so.

RE: Far Plane.

AFAIK, UE4 uses an infinite projection matrix as described in http://www.terathon.com/gdc07_lengyel.pdf

1 Like

Hi, I have the same problem in my project and I tried opening the Engine.ini file on TextEdit, I changed the NearClipPlane to 50, then saved the file and opened the project, nothing changed, then I checked the file and it had been automatically reverted to 10.

Am I doing it wrong? what is the correct way to edit the Engine.ini?