Download

Material/Shader to blend mesh edges together

Hi there,

I’m trying to make a material or shader that will blend the edges of separate meshes together, and reduce or eliminate the shadowing and seam at the intersection point.
The meshes share the same material but are separate meshes.
I don’t yet know that much about materials and shaders, and I’m hoping someone could help me.

Im trying to blend the seams of these meshes.

Thank you

@Zurael Have you seen this?:

https://www.youtube.com/watch?v=PKX_v4RDkPc

Im never work with “metaballs shaders”, but you can read, look some video about them, maybe it can work in you situations.

Check this thread. Terrain Blending Tool (based on Star Wars: Battlefront) - Unreal Engine Forums

[quote=“ClockworkOcean, post:2, topic:135135”]

@Zurael Have you seen this?:
https://youtube.com/watch?v=PKX_v4RDkPc[/QUOTE]

Hi there thank you for the link,

I had recreated his pixel depth input in my mesh’s material, I found that it did make the edges of the mesh near the ground blend, but did not affect the seams between the meshes from what I could see. I’ve tried changing the scalar parameters but I didn’t have any luck.

Hi, that is a cool project, but it seems like it was never released? Thanks

Notice in the vid, he is not doing it with the ground. He’s doing it between two objects…

Maybe it doesn’t work with two meshes of the same material.

Did you check out the ‘other method next week’ he talked about?..

It sounds like you need a depth fade without having to use transparency…
if that’s the case, couldn’t you maybe take from the shader and re-work the same or similar logic into a custom node?

Otherwise, follow this logic bit for a sec.

  1. assume that mesh edges are at edge of UV.
    1.a) possibly create a mesh edge texture channel with the edge in white fading to back where it’s no longer and edge or viceversa.

  2. lerp the UV or the map from assumpion 1 between the color albedo value and a desaturated version of the same.

  3. normals needs to be modified to offset the light too. I would mask them similarly and take the geometry information as the basis to multiply fro the edge. While leaving the material normal in place as is for the non edge area.

While all of that my work, may I remind you that you could better shape the mesh first?

I’ll try making the meshes have a different material to see if I can get them to blend, thanks for the suggestion.

Also I wasn’t able to find another video on his channel about this, maybe it was deleted or he didn’t make the follow up video?

Hi thanks for posting, the meshes that have the seam are all different fbx files, they are different static meshes that are unwrapped and share a single texture/material, and they swap for different ones at runtime. So I think the physical edges of the mesh would be all over the UV, could I still find the intersections with the other meshes somehow? Thanks

Distance to nearest surface comes to mind as a possibile node to use.

But let me understand.

Every separate mesh is an extra draw call. This can either be the desired effect or not… more calls = lower performance.
This was enough of an issue for me to create completely different swappable meshes once over 10 separate parts. (Each material is also a new draw call, so for detailed things it gets to be heavy).

Second, are you dealing with a character or with actually static meshes? The approach would change a little, but it’s mostly important to know in order to approach the issue the best way.

That said,
If you have control over all the meshes, simply create a new UV and unwrap just the edge in it as a flat square.
You can then instruct the material to use UV2 and perform operations on just the edge to mix in with the base color of UV1.
If the meshes share the same texture/material the second UV idea is probably less intensive then instances with different flow maps.

You can similarly use the 2nd UV to force a new normal map. The normals mostly drive the shadowing you see, as I’m sure you know.
So applying a differently extruded custom normal may offset the seam a bit. However a gap in geometry is a gap in geometry. It will keep on causing shadows.

Potentially, you could enlist the help of a stancil and add a custom material to the overall post process in which you - similarly to a toon shader - change the image where it darkens (for the stencil only). Consider it some sort of a LUT table. Replacing all colors that are darker then a certain amount is what you want, and a simple lerp of the desaturated scene texture could help isolate the dark spot no matter where it is.

If the shape is a character and moves around the post process becomes an even better idea then the second UV…

@Zurael Yep, it only works when one object is opaque and the other is transparent. Not sure how to get a material to fade against itself…