Unwanted seams visible in Instanced Static Meshes

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.

The material is just a blue color assigned to the base color. Is this an issue with the normals? This looks like a bug to me. Any help would be appreciated.

UPDATE 1:

Turns out that there is a discrepancy between how vertex normals are calculated on non-uniformly scaled instanced meshes, and non-uniformly scaled regular meshes.

I wrote a simple shader to visualize the vertex normals.

Instanced meshes:

Non-instanced meshes:

UPDATE 2:

I’ve written a simple blueprint to recreate the issue. You can download the “Block1” mesh [here][6] and the blueprint [here][7].

I don’t know if Blueprints can be shared this way. If it doesn’t work, refer the following screenshots to recreate it: [Overview][8], [Screen1][9], [Screen2][10], [Screen3][11]

Note: Assign a dark-colored material to the Block1 mesh to easily view the seams.

Hey ApoorvaJ,

What version of the engine are you running?

There was a bug reported for this exact issue associated with version 4.6 that was labeled as fixed in 4.7 versions.

Regards,

Just checked. I’m using 4.7.0.

Hey ApoorvaJ,

If it is not too much trouble, would you mind updating to 4.7.3 and checking to see if the issue is still apparent there as well. We have rolled out a lot of fixes for the engine within these three hotfixes, and one of them could very well resolve your issue.

If for some reason you cannot update, or do not wish to update your version please let me know.

Thank you,

I will update to 4.7.3. The download is rather large (4.9GB) for my net speed, but I’ll do it within a couple of days and get back to you.

Sounds good. Appreciate the co-operation!

I updated to 4.7.3. The problem still persists. :frowning:

Hello ApoorvaJ,

Go into your ‘World Settings’ and try changing the values under ‘Lightmass’ to help hide the seams. One setting in particular to pay attention to for your issue is the ‘Indirect Lighting Smoothness’. Set this value to something around 0.6 and see if that helps improve your issue.

Let me know if you are able to get your mesh to look correctly, or if you need further assistance.

Cheers,

I changed Indirect Lighting Smoothness, which did absolutely nothing. Note that all of the lighting in my scene is dynamic.

More importantly, I think that the difference with the normal data is the key to the solution. For some reason, normals are handled differently for instanced static meshes vs static meshes, when the objects are scaled.

Whether this is intentional or a bug in the engine, I don’t know.

I think the issue would be resolved if we focus on the normals. If you are having trouble reproducing the issue, I could send you a simple blueprint and mesh.

Hey again ApoorvaJ,

Thank you for the clarification, I did overlook the fact your scene was fully dynamic. It does seem like you have found an important bug here.

I am going to enter a bug report for this issue, and if you have the simple blueprint and mesh that I could attach for testing of the bug report, that would help get a fix implemented.

You can try attaching the Blueprint and Mesh here on the AnswerHub, but if the file size is too large you can provide me with an external link to where you uploaded the file, and provide me with the link via Private Message on the Forums.

Thank you for taking the time to report this issue and let us know if you have any other questions or comments.

Cheers,

I have edited the original post (Update 2) and I’ve added the mesh and blueprint downloads and detailed blueprint screenshots.

Hope this helps.

Even big game companies try to hide seams behind a tree, or a pipe…Try in your modeling software to delete all smoothing groups. Is very hard to put together two walls to act like one. Also your uv must be perfectly snapped

Any updates on this? Were you able to reproduce the issue?

Well, I’d be thinking that it’s not the only or most prior bug that they have on their list… so… patience is a virtue, I guess. No offense, friend!

Hey ApoorvaJ,

After running some more tests with your asset I can confirm what you are seeing. The issue here is that lighting is not calculated the same when using instanced meshes versus individual meshes. Since instanced static meshes are referencing a single object, the way the engine calculates lighting information is different, in order to improve performance when using a lot of heavy static meshes within your scene/level.

With that in mind, instanced meshes also do not light well when scaled non-uniformly. I set up a very simple dynamic scene (movable directional and skylight actor) with the mesh you provided. I created two sets of walls using the original mesh and then using instances. As mentioned by other users on this post, your never going to fully get rid of seams, but with dynamic lighting you can really reduce the visibility. It is all about balancing your indirect lighting quality in conjunction with your bounces and intensity. There are also tons of small ways to hide the seams by using materials that tile smoothly with macro variations to break up the repetition.

Here are the results of the tests I ran and hopefully give you some idea of how to reduce the visibility of your seams.

Instanced Meshes vs. Static Meshes

The wall on the top-left of the screen is the Instanced version of the static mesh you provided.

Instanced Mesh Wall

Here, although barely visible, I have circled where the seams begin on the meshes.

Non-Instanced Mesh Wall

Here the seams are completely invisible.

Although this might seem like a bug, it really just comes down to optimizing your lighting when using the Instanced Mesh approach.

Cheers,

Thanks for taking the time to recreate the issue. Now that you’ve confirmed that this is not a bug, I have a feeling that I might be able to negate the effect in the material. If not, clever lighting it is. :slight_smile:

You are welcome.

Never forget, some of the best games are the ones who can achieve the desired effect by optimizing their approach. Even if it means covering up dirtied areas or sacrificing realism for the faked effect.

Sorry for necroing this thread, but I’ve spent a lot of effort trying to solve the issue in-material, to limited success. I’ve posted my analysis on this forum thread.

Moreover, Adam Davis seems to have acknowledged the same problem as an issue in this AnswerHub thread.

Could you clarify this further? If this is not a bug, I think there’s a lack of functionality here. There should either be an option to recompute normals properly, or a way to avoid any normal distortion at all.

Hey ApoorvaJ,

There is actually an option within the Static Mesh editor ‘Recompute Normals’ just in case you might have overlooked that. On another note, I have been attempting to reproduce your blueprint and have double-checked, but the ‘ForEachLoop’ node is not compiling correctly so I am unable to test your exact approach.

That being said, I have tested this with three different approaches and all return the same results. I am not seeing the same seams you are seeing so I am guessing you might not be setting your scene up correctly for the fully dynamic lighting. Be sure you have a ‘Skylight’ as well as your ‘Directional Light’ sources set to ‘Movable’. You can also go into your project settings within the rendering section and uncheck the box that says ‘Allow Static Lighting.’ Another safeguard to make sure you are not using lightmaps, is to open your ‘World Settings’ and under the ‘Lightmass’ section, check ‘Force No Precomputed Lighting.’

After you have done this, rebuild to see if your results change. I will show you how I set up my scene up and my results with instanced static meshes.

Construction Script Approach

Since your mesh is 200 units wide, I set the positions of the next mesh relative to that value to make sure they were touching, but not overlapping.

Blueprint Viewport Approach

Here I hard added the extra meshes and used the same relative locations to place the instanced meshes.

Original Static Meshes

Here I took three of the static meshes and simply connected them at the ends.

Final Results

The section on the left are the original static meshes grouped together. The other two are the instanced static mesh versions using the approaches mentioned. As you can see I am not getting the same results as you, so maybe this could be something to do with how you are spawning/creating your instanced meshes.

Let me know after you have tried some of the suggestions mentioned and still think this is a bug. Another quick note taken directly from the documentation. In case you were using the ‘Generate Mesh Distance Fields’ approach, Non-uniformly scaled instanced static meshes cannot be handled correctly.

Regards,

I tried all the lighting settings you mentioned, and turned off the Mesh Distance Fields. Nothing worked.

The reason you weren’t able to reproduce the issue is because you didn’t scale the instanced mesh. The problem only occurs when you (1) have an instanced mesh component and (2) you scale an instance non-uniformly.

Look at my [forum thread][1] in which I prove that this is a normals issue. In the thread, if you look at the GIFs, I compare the normals on an instanced mesh (top) against the normals of a plain static mesh (bottom). Just two meshes.

What’s happening is that instanced meshes do not compute their tangent basis vectors correctly if the instance is non-uniformly scaled. As you pointed out before, this might not be a bug, but rather a performance optimization.

My point is that this leaves a rather large functional hole in the engine. Maybe we could have a bool on the instanced mesh component that, if set, would ignore the scale while transforming the per-instance normals. That way, we would get both, the performance and the correct normals.

Finally, to illustrate the problem, you can even see the normal difference between a instanced mesh (top) and a static mesh (bottom) in the Blueprint Viewport Approach: