[ame]
https://www.youtube.com/watch?v=pv8wjMGGGDM[/ame]
I just watched a video about a Unity3D feature that allows Level Designers to seamlessly blend staticmeshes into the terrain. It seems to be doing two separate things:
[1] painting the terrain texture onto the mesh without a UV seam, and
[2] blending the normals of the mesh with that of the terrain, creating a smooth lighting transition.
Any ideas on how they are accomplishing this?
Is it something Unreal users can recreate with the material editor? I can see how
[1] might be recreated in UE4 (I'd just use worldspace-projection mapping on both the terrain and staticmesh), but I am much more interested in how
[2] is accomplished.
[2] would solve a lot of problems I am having right now with my staticmeshes.
I've never used Unity3D before and don't know very much about it, but this strikes me as an absolutely fantastic feature for LDs.
Replies
It's not pretty, but here's a pic of the problem I'm trying to solve:
As you can see, I need only the "skirt" of my mesh to blend with the terrain, but not the inner portions. And not only that, but I want to be able to blend on slopes and different heights.
As WPO can't work here, the only way I can think of doing this at the moment is to use translucency to soften the transition from mesh to terrain, but it's a really inelegant and expensive solution and I think a better solution should be possible somehow (eg. the Unity3D one I linked).
Maybe I'll have to learn coding and make some kind of custom actor like StaticMesh_Blendable that allows the user to bend the vertex normals so they match the terrain, or something. Just throwing ideas around.
@Nightingale
Have you asked about this over at the unreal forums?
going to look into it myself as it would be a massive "hassle" saver.
This is not the same as the Unity solution as you can see when the rock is moved into the terrain surface, you still get a material difference which causes a seam. The unity solution is just like vertex painting only your painting on both the terrain layer and the mesh at the same time so you don't get seams or a difference in material.
As far as I can see this is not currently possible in UE4 because you can't use vertex painting on the terrain and a mesh at the same time. I would welcome it as it would be very useful.
You can see it here: https://www.youtube.com/watch?v=rxM6QVwrzBg&feature=player_detailpage#t=1196
but once you start adding drastic meshs the technique goes out the window. It's an age old problem and that Unity script solves it but I wonder were the con is, if it is indeed a type of decal then the draw calls would increase tenfold.
Near the bottom you can see a viable solution as long as your static meshs are curved. This is for UDK but the principal is the same in UE4.
Worth looking into :poly121:
I just wish Mr. Lazarski would have included a screenshot of the entire master material, to make it more clear exactly what each part is doing. I don't really understand how the material works, and it's not obvious to me how the different parts fit together.
If I understand this correctly, then:
1.) WorldAlignedTexture accomplishes triplanar projection mapping without using a vector transform node.
2.) The material uses the emissive channel to "cancel out" any shadows that might be casted by the staticmesh. Vertex painting determines which parts of the mesh will have the shading cancelled out.
3.) But then what is the purpose of the flat shading? How does it work together with emissive?
Without using hacky emissive materials I think the biggest hurdle is the lighting seam caused by the difference in normals. I suppose you could export your landscape and any meshes you want to blend, match the meshes' normals to the landscape and reimport as unique meshes. That's ridiculous though.
There's always the option to not try to blend things seamlessly and just throw a rock onto the ground, a non seamless, say, moss border where it meets the ground will probably end up looking better than an obvious seam where there isn't supposed to be one.
I just wish I was a programmer.
In the case of my trench meshes, I think I will have to resort to a translucent skirt to get the job done.
https://www.youtube.com/watch?v=rxM6QVwrzBg#t=1099
It is certainly possible, and I've been trying to figure it out for the past month. Unfortunately neither video shows a breakdown of the process.
The technique shown in the vid is just a UV trick, essentially tri-planar projection of UV's based on world space. What it doesn't do is blend geometry or normals when meshes intersect, so you still get lighting seams.
I think there's a material function already built in to UE4 to do projected textures like this, but essentially it's:
For each axis: Use world position, component mask out the two corresponding coordinates, divide by a 2 vector constant for scale, plug into your texture UV's. Then use world normal, dotted against an axis, fed into an abs, and use that to lerp between your different projections.
Damn, I completely forgot that thing is still out there. It's something I had to do as a part of my university dissertation, so it was always more of an experiment than a complete, game ready solution. Looking back, my materials probably make little sense and having looked at the images now I'm not entirely sure what's going on either. That emissive thing is pretty dumb and if I recall correctly it was a hack that was meant to fix my shadows looking really weird in places.
The other principles are probably still relevant, so if you could figure out a way to make sure the normals of your mesh match those of the terrain you would end up with a seamless results.
But either way, you'd probably be better off looking into that Unity plugin, or other solutions, as mine is most likely hampered by my lack of technical knowledge.
Unfortunately I'm not a programmer, but I guess it's safe to conclude that nobody has yet found a reliable and inexpensive method of accomplish normal-blending between staticmeshes and the landscape in Unreal Engine 4.
Maybe the Unreal devs will do it themselves one day, or a programmer will figure it out in the future.
Just want to point out that the end result of that nicely blended rock isn't much different to just raising the terrain and painting it. I would argue that the transition ended up being too smooth.
I've never heard of this before. How does the terrain material know how to blend selectively into a certain staticmesh?
- A lot of work was put in to reduce the visible disconnect between assets and terrain
-Most assets have terrain radiosity projected onto them
-Texture Arrays (Detail textures) world projected and details match
-Terrain color and normals applied to most assets.
If anybody has more info on that matter (It's been a year, so Iunno), I'd love to find more content on the subject.
Cheers!
Check Ryan B's answer below, which chimes with what PINS said (a year ago) seems pretty straight forward but I'm not having much luck
https://answers.unrealengine.com/questions/61109/how-do-you-manipulate-light-vectors-in-blueprints.html