Terrain Blending Tool (based on Star Wars: Battlefront)


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. Here are 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.

I was also inspired by a terrain-blending plugin in Unity3D (which is currently outdated).

So 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.


I also played around with some different materials and animated noise masks.


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. :slight_smile:
So please let me know what you think :D. 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! :slight_smile:

Cheers!

Wow, that one is really nice! I’d certainly buy it, especially if the material is suitable for mobile platforms too.

I’m planning to put it up for free :). My material uses Distance Field functionality, so I don’t know how optimized it is for mobile :).

Nice to see that this problem in games is gettin’ attention! I would love to have a tool for this altough I don’t have any experience in tool development either. I hope others (mods and unreal dev’s) notice this thread and help you out with it to make it a build in feature!
Good luck with it!

Glorious!

This artifact you’re solving has been one of my biggest pet-pevs in videogame landscapes, I didn’t really think it was solvable.

This is very good. Does it work with static meshes that have multiple materials?

Yeah, all the logic is all done in the material itself, so only one material can use this system or all of them can :).

Excellent work! Can’t wait to try it out myself!

If you want to make it a polished resource like what would be released (for $) on the Marketplce, I suggest doing this:

  • Encapsulate the material related stuff into its own Material Function.
  • Create a master material and some instances that use your MF.
  • Create a showcase level with some examples placed down ala your gifs.
  • Write a small guide to using the material function and to your examples.
  • Package it up into a project with your guide, showcase map and material function.

Awesome work btw, I love this effect.

Thank you so much for the advice! This is really helpful :). If I put this up on the marketplace, it’s definitely going to be free, I rather have the exposure than the money :D.

I have a question in regard to Material Functions though. The material for the landscape is a MF that outputs a world-space material, I use this Material Function in the regular landscape material and in my special terrain-blending material for the rock. In this way, if I update the landscape MF, it’s automatically updated in two places. I would love to add functionality to my material that allows for easy swapping of landscape materials. However, using Material functions as inputs for Material Instances seems to be impossible :(.

I could use the textures of the landscape-material as inputs, but if I want to change the scale of this material, I would have to update it in two places, which is inconvenient :). Any ideas for a solution to this problem?

Yeah, this looks great! What kind of changes did you make to make this happen? (As in: how hard would this be to put in self-contained plug-in, which in turn is maybe needed to put it on the marketplace?)

I don’t think there is need for the use of plug-ins. The only prerequisite is that Distance Fields are enabled in Unreal. Everything is done in the standard material editor :).
However, I don’t know a lot about plug-ins in Unreal, so I might be totally wrong :D.

Looking Good!

I think they are implying that you could make a plug-in which unreal has made a lot easier to do recently then sell the plug-in or for free. (I like Free!)
And you could always ask for someone in the community to help you or just get help as you go along on the forums.

you can always just put the add-on (plugin) up on google or someplace for download & link it to your forum post here or in the Content - Tools section:
https://forums.unrealengine.com/forumdisplay.php?12-Community-Content-Tools-and-Tutorials

Great job! Does it work when placed on a static mesh, or Landscape only? I suspect that it works, since you use the DistanceToNearestSurface, am I right?
Also, do you assign a material/texture to use for blending for every mesh, so e.g. if you place a rock on a sand, you assign sand texture for blending, and so on…? Or does it detect ground texture automagically? :smiley: Sorry, my knowledge is limited here, I’ve never played a lot with Distance Fields…

BTW. I’ve tried to make something similar for my game, but in my case it needs to be dynamic since my world generates procedurally - and I’ve stuck here, because I can’t figure out how to e.g. detect ground texture below procedurally spawned rock + what if it spawns on top of two different textures (for example over some grass texture <-> mud texture intersection), etc.

About Marketplace: I would buy it definitely, hereyou can read about submission guidelines. Just prepare the required folder structure, add some documentation/level with examples + demo video and you’re good to go :slight_smile: To submit your pack, you can start here: https://publish.unrealengine.com/

Awesome WIP, keep it up!

Thanks for the reply :slight_smile: ! I glanced over the Unreal plugin documantation and it seems pretty daunting (I’m an artist to the core :D). Is there a way to create plug-ins without writing code? Or will I definitely need someone with more knowledge to help me out?

Thanks a lot for the Marketplace guidelines! I was starting to fear that I had to start writing c code :p.

To answer your first question, all the terrain-blending magic happens in the material of the static mesh :). The landscape material is just a standard world-space material. I use a material function for the landscape material. This makes swapping the materials currently a bit of an issue, since Material Instances can’t use Material Functions as inputs. If you have some insight into this feel free to let me know :). Automatic landscape material detection is a far-away dream at this point :D.

This is fantastic work!

Very well done! Did you have to disable tangent space normals for this to work? I did something similar with world-aligned textures to blend meshes with landscapes:

Adding the mesh-distance field blend is a very smart addition, great work!

Thanks a lot! The thread where you originally posted that pebble-material was one of the things that inspired me to make this this tool :D. And you’re absolutely right, for this material to work, tangent space normals need to be disabled. You can still use tangent-space normal maps in my material though, it just gets converted to world-space in the shader. :slight_smile:

deep breath

hnnnnng.