Strange seams visible in Instanced Static Meshes

I’m having a strange problem with instanced static meshes. I’ve also posted on AnswerHub, but this is a critical thing for me, and is a bit strange as well, hence the double post here on the forums.

I am making a procedural building system, and I’m using modular static meshes to form the buildings.

When I use instanced meshes, I can see visible seams where the meshes line up. These seams don’t appear when I use plain, non-instanced static meshes, keeping everything else exactly the same.

This is not a micro-placement issue because I’m generating and placing everything in C++. The material is very simple, with just a blue color assigned to the base color. Any ideas on why this could be happening?

This smacks of UV lighting issues. Have you checked all your UV settings?

The fact that it doesn’t appear with normal meshes … leads me to believe otherwise.

Sorry man … I have no idea.

All the lighting is dynamic. Nothing is baked.

From other observations, I have a strong suspicion that there is a discrepancy between how vertex normals are calculated on non-uniformly scaled instanced meshes, and non-uniformly scaled regular meshes.

I think you may have found a bug … don’t quote me on that. Lets see what answers you get on AnswerHub.

Update:

Suspicions confirmed. I created a basic shader to check the vertex normals.

Instanced mesh normals vs.

non-instanced mesh normals

Some weirdness is happening, and I’m not sure why.

Just update your AnswerHub post so that the Epic team can check this for you and log a bug if necessary.

Thanks

Already done. :slight_smile:

The official response on AnswerHubis that it is not a bug. I’m not so sure yet. Either way, hiding the seams is not an option for me because I’m writing a procedural building generation tool that heavily relies on instanced meshes.

I’ve spent almost three full days trying to come up with a solution, but while I’ve made some progress, I haven’t been able to fully understand or solve the problem.

The problem will affect almost everyone who’s using scaled instanced meshes, and I’d really be grateful for any help I can get.

Here’s an in-depth look at my findings:

The Problem

Non-uniformly scaled instanced meshes are lit incorrectly, even in fully dynamic lighting. I’ve established that this is a result of incorrect normal data. This problem occurs only on instanced meshes, and not on static meshes. Check out the first post in this thread for a screenshot of the incorrect lighting artifacts.

My Observations

I made a simple blueprint script to equally scale instanced meshes and static meshes. Using a simple material, I visualize normals in local space. (Instanced mesh on top, static mesh on bottom, both scaled on the local X axis.

M1.PNG
Result: Click to see GIF

Here’s the same operation, but now the material displays normals in tangent space.

M2.PNG
Result: Click to see GIF

I had a hunch that I could solve this issue by dynamically generating a normal map to correct the normals. However, this is more tricky than just supplying (0,0,1) (the color blue) into the normal. Observe what happens when I input (1, 0, 0) (red) into the normals.

M3.PNG
Result: Click to see GIF

Note that as the instanced mesh stretches, the normals no longer “obey” the normal map. This leads me to believe that the tangent space itself is being distorted. This is the part of the problem I don’t fully understand.

My Attempts

I tried a lot of things to make this work, but none of them worked completely. Here are two attempts that worked to some extent:

Attempt 1

Here’s a material that successfully corrects the “green faces” (with normals along the Y axis) when the mesh is stretched on X upto a certain point, but fails when stretched along the Z axis.

Attempt 2

Here’s a material that works in tangent space, and works for the X stretch, but again, fails for the Z stretch.

Important Considerations

The dimensions of this mesh are 200x20x250. The mesh was created in blender, all of the edges were split, and the mesh was exported with smoothing groups set to ‘Off’.

The same issue occurs even on a four vertex plane (a quad), and is not a problem with this specific mesh.

This is not a problem with the UV mapping, because (1) the problem doesn’t occur on static meshes which use the same mesh asset, (2) the lighting is fully dynamic, and (3) I’ve shown clearly that this is a result of normals distortion.

Hiding the seams is not a solution. Instanced meshes are critical to rendering large amounts of geometry, and I think this is a rather large functional hole.

Reproducing the Issue

I’ve provided the blueprint and the mesh for download at the AnswerHub link.

Closing Notes

This is a rather large roadblock to progress in my current project, and it’d be a huge help if you guys could help. :slight_smile:

If you want to get in touch, you can post here, or contact me at apoorva.ramesh.joshi@gmail.com.