Hi guys, I'm a student Video Game Design at Digital Arts and Entertainment (in Kortrijk, Belgium). For my graduation project, I'm developing a tool to blend static meshes with the environment. I basically want to remove the harsh seam that you see when a static mesh intersects with a landscape actor. Some examples of landscape-seams in AAA games:
I was inspired to make this becasue of the 2016 GDC talk by Dice about Star Wars Battlefront. In this presentation they showcased some in-engine tools to blend together natural meshes and the environment.
http://www.youtube.com/watch?v=3-y6lq3z95wI was also inspired by a terrain-blending plugin in Unity3D (which is currently outdated).
http://www.youtube.com/watch?v=pv8wjMGGGDM&t=2sSo the solution I currently have is based on the Distance Fields functionality in Unreal 4. I didn't come up with this idea, I saw a forum-post about someone fusing meshes together by using Distance Fields. However, I cant seem to find this link anymore so if anyone knows which post I'm talking about, feel free to let me know
. I use the DistanceToNearestSurface node to automatically detect the intersection between the terrain and a mesh. I combine this with a noise mask to get a nice procedural material transition.
What really sells the effect is the adjustment of the vertex normals of the mesh. This removes the ugly lighting seam caused by intersecting geometry. To adjust the normals of the mesh to the normals of the surrounding area, I use the DistanceFieldGradient node. This system can be a bit finnicky and took a lot of tweaking to get right, but I'm pretty happy with the result.
I currently have created three variants of this material. One automatically detects the landscape intersection, the second one uses a vertex-paint mask and the third one is a combination of the two.
It would be nice if the final result of this Graduation Project was a free tool on the Unreal Asset Store. However, I have little experience with tool development (certainly not in UE4) so I'm looking for all the advice I can on that front.
So please let me know what you think
. Would you be interested in something like this? Do you have ideas for other potential use-cases of this tool? Do you have some insight in making something for the Unreal Marketplace? All information is welcome!
*Disclaimer: I also made a post about this on the Unreal Engine Forums and I copied the text because I'm lazy
*
Replies
May I ask you, what did you do with the normals? And what are the final instruction counts?
Anyways, as I understand, this won't make the terrain texture "appear" on your rock. Rather, both the terrain and the rock has the snow textures and it appears when you move the rock close to the terrain right? So if you would put the rock across an area that has multiple textures painted on the landscape, you would only see one of them appearing on the rock.
About the normals:
Do you just mask some of the normals with the distance field gradient, and you make them pointing up?
About the normals, I actually mask of the "terrain blendin area" with the DistanceToNearestSurface node. I get the normals that are adjusted to the terrain by using the Absolute world position and the PixelNormalWS in combination with the DistanceFieldGradient node.
Funny you should mention the normals pointing up . That's what I did in my early prototypes, however this effect falls appart as soon as you have some relief in your landscape. This system still works in a bumpy environment .
This would be a great tool for artists working in UE4, and for those who like to push their scenes with more realism and shader trickery.
I don't think the shader itself is too expensive, imo, and I believe there have been previous discussions on achieving this effect in regards to games like DICE's Battlefront and BF1 where it seems to be present. So already we're seeing this being done in games, or what appears to be.
It's still some effort by you, though. If you can't get it on the UE4 Market then perhaps sell it for free/donation on Gumroad.
The way they said it's done in star wars is that it samples the landscape layer underneath the mesh and blends it to the mesh, and I've seen it being true in places where a rock is placed on different material layers. However, I don't think that's really necessary. You could just make material instances and swap the snow textures in the material instance with grass and then apply it to a placed rock, then you can move the rock on a grass material layer and have grass blending into it instead of snow. So no big deal at all.
As for the performance, in general things really run much better in Frostbite and this doesn't really have to do with the artist. However something cool you can do is to make two material instances, one with the blending feature enabled and the other disabled. Apply the one with blending feature enabled to the LOD0, and have rest of the LODs using the instance with blending feature disabled. This way not all rocks will always have high instruction count/red shader complexity on screen. Since the LODs will be far from player, not having the blending feature present on them in not really an issue either.
With that said, I don't see a reason for you to go through more headache since it's already working and there won't be performance problems if using the material instances. I am really interesting in getting my hands on this, please do the clean up and release it ASAP. :*
Yeah I definitely want to go the Material Instance route, I have one issue though. The landscape materials are currently Material Functions, but you can't use a MF as an input for a Material instance . I could just use textures as inputs but if someone wants to change the scale of the landscape material, they would have to do that in two different places (in the regular landscape material as well as in the mesh material). So a convenient way to swap the materials is one of the last biggest hurdles to overcome .
Thank you so much for all!
Will this work with any mesh intersection of just with terrain?
Also you should apply for a UE4 Dev grant I'm sure you'd get it with such great tool, especially if they can add it to the engine for free
For changing the scale of landscape material and such things, I think you can use a parameter collection in both landscape and mesh materials, that way you just change the value in the parameter collection and it affects both of them at once without needing you to go inside both materials and change the values there.
You can combine your mesh Height map with Dither temporal AA to get quite similar to what you have, but without having distance field activated. You can use it with shadows, but it works better with shadows casting disabled. For reference you can look Titan pass level in UT. There lots of different assets on walls and ground using this tech.
Clever to blend the vertex normals aswell! This makes me very happy, very good application aswell!
Looking forward to the release!
Found it: https://youtu.be/ixkP5WTr4DY?t=215
Anyway, great job, your solution looks awesome! Thanks for sharing.
Seams make me sad Amazing work, keep it up!
Could you tell me if you're still able to have 'Generate Distance Fields' checked for the rock mesh?
Your tools looks great btw, now if UE4 only had proper virtualized texturing you could just take the texture result outputs and bake to have something with no runtime cost. Ah well, maybe you could optimize in some way, nice job anyway.