Download

Moire / Z Fighting Splines on Landscape

Hi Guys

Looking for some suggestions to combat Moire and Z fighting when I Place this spline in a scene.

It is much worse than the image shows, constant flicker and black shadows jumping around.

The spline has mesh 3d components for the sleepers (ties), these are not individual but are as a block 2048 cms long.

It seems the spline will not LOD any particular section out it takes the entire spline to move X distance for the LOD to work.

I have played around with the z fighting settings in the landscape material to no effect.

Any suggestions as to overcome this would be most appreciated

I do need a 3D spline as this is physics based track

Thanks

Paul G

Two options come to mind.

  1. Use the vertex shader to pull the spline mesh towards the camera a bit. You could use camera depth fade (make sure to set “used with vertex shader” = true) to multiply it by cameravector and clamp it to some amount. I can’t recall if the spline meshes still let you use the vertex shader so maybe option 2 will work in case it doesn’t.

  2. Try using pixel depth offset on the terrain itself using the train rock mask and camera depth fade. Then you can push back the pixels under the train tracks specifically.

Hi Ryan

Thanks for taking the time,

Although there is some Z fighting which I will try to solve using the second method, it seems the main problem is actually the shaded vertical face of the sleeper (ties).

I placed 3d track well above terrain and am still seeing the horredous moire, The only thing I have found that makes any effect at all is to turn off tangent space normal.

Here is a shot looking into the light source

And with light at our back, there is still moire but much less pronounced

fb279fa5b120198c7f3c6509e0c3d41bfb16cf0a.jpeg

The sleepers are well clear of the terrain and rail elements removed for clarity, the vertical faces of the sleepers are lodded out after the moire

Thanks again

Paul G

For an asset this specific you need a view directional LOD setup. For bullet train I had to solve this for VR so I make the LOD rendered from an angled orthographic camera. I did not have to worry about view from the sides since the level was basically a tunnel so I am not sure right off the bat how you also make it work from the sides but maybe you can try also baking one from the side and using the dot product of the local X vector to blend between.

The normal for the LOD looked like this:

If you have really long view distances I would probably even bake some gravel/dirt/whatever into the space between the rails and gradually fade out the opacity mask to be full white and reduce the contrast in the material and possibly even the normals to make the surface smoother from a distance.

In order to support viewing from the opposite direction, I flipped the UV.Y coordinate if viewed from the other side. That is just using the sign of the dot product of the camera vector and the rail forward vector. Since this only happens in LODs you don’t see the spit but if you force LOD and go right above, you can tell it just flips the UVs (and the normal map G channel) on a hard line:

e4cfa82c182008a38b5e15ccf59fd857102690e9.jpeg

Hi Ryan

Wow great specific reply… gld its not me just me,

Interesting approach, that is a world normal ? any details on how you hooked it up ? I have have not been getting expected results in my tests

Cheers

Paul G

I rendered the world normal of the mesh from a top down view which makes it in tangent space in the captured perspective. Its definitely something pretty specific that needs to be tweaked on a case by case basis. if you post some image of where you are at I will be able to suggest improvements and if you post the normals I can help debug them.

Hi Ryan

I am guessing from your screens that in your project you laid out individual track sections ?

I am attempting to use a spline with the sleepers added as a spline mesh component, each inheriting the rotation of its spline point.
If I group the sleepers into say a bank of 8 or 16, similar to your mesh… individually they would not have the correct rotation.

When I tried adding sleepers as spline mesh so they would distort with the spline, I could not get them to LOD down per section, the entire spline length stayed stayed at whatever LOD the viewing distance dictated.
Is this as spline mesh is designed ? or did I miss a trick ?

Chairs can be a seperate spline mesh component LODed out as required
Rails are spline mesh

So as regard the sleepers, I am thinking that I use Individual 3D sleepers reduced and LODed out at say 20m ( which so far seems to be well clear of the moire at expected viewing angles)
Over 20m a spline mesh is revealed using the directional normal method above ?

If you think this is workable, I will reconfigure

Sleeper with Chairs
8d10c10c354647e5caf6f3f2e862dcd32232b81f.jpeg

Extreme Curvature showing rotation (individual)
70e39c00092cf5e71f1233ad3458ca7519b462b2.jpeg

Directional Normal Bake
91365af8e1322dff3b0383ecaa60ff475c449afd.jpeg

Many thanks

Paul G

Hi Ryan

I have managed to get an acceptable result by using a world normal bake on an individual sleeper ( non directional ).
From a purist view the shadowing is not strictly correct but as a ground level feature it seems reasonable to me.

Many thanks for your help.

ec64772e3f44ff2548581a1a01f686ff30eb73e5.jpeg

Paul G