Terrain mesh blending extension: Why haven't I seen a post for this?

I found this thing on the asset store (I am not the developer of it), but it’s probably the coolest terrain-related unity extension I’ve ever seen.

$125, but worth every penny. This is impressive, AAA-level stuff.

StuAssets, where the heck are you and why aren’t you pimping your kit?!

hi,

i have seen this a few weeks ago and was very impressed.
everything looks pretty cool but i would really like to know something about performance…

lars

@larsbertram
Also it would be nice to know, if it works with your Colormap terrain shader.

probably not right out of the box, as they have their own shaders. but i can imagine that you are able to tweak them to make it fit even with the colormap shader.

lars

i think basically there shouldn’t be a problem if both shaders don’t overwrite some same functions. 120 € for testing is really a lot, a demo for testing would be really nice.

Well I took a closer look at the video and at 2:30 he does the magic “fetch closests blend texture”, to use the colormap shader you’ll probably have to modify that part to get both closests texture and color. But this pretty much guarantees that you could modify it to work with any terrain shader, as you’ll only use 1/4 of the terrain shader variables there should be plenty of room in the shader for his stuff.

This is really some damn impressive stuff, I remember seeing a video of an mmo world builder which did this automagickally when you dropped meshes on the terrain. Think it was wow, but I’m not sure.

@PrimeDerektive: Thanks for bumping this, definetely worth some attention. :slight_smile:

@Stu: How are you storing the blend data? in a map, per vertex, or how? Could you have a chat with Lars and make a version with all the magicks combined? I’d be most interested in a combination of Lars terrain decals and your stuff.

Cheers

Wow, looks very cool, a bit pricey (for my budget), but looks like something I could use at some point.

We store all blend data per vertex, in the color channel - R is the weight for texture blending, G is the weight for blending normals and BA are used to store the normal of the terrain, sampled using the vertex position.

Performance depends on the type of blend shader you use, of course. All shaders try to emulate the blending of the terrain shader and blend this with the mesh color normal. The most expensive one does 11 texture samples (4 terrain normal maps, mesh normal map, 4 diffuse for terrain, diffuse for mesh and the terrain splat map) while the cheapest one does one more texture sample than a regular diffuse shader. “Single” shaders are not required to sample the terrain splat map.

The “bumped” versions of the shader are a bit more involved, requiring one more matrix multiplication than regular shaders.

Regarding Lars’ things, I looked at the colormap shader and from a quick glance I believe integrating it would be fairly straight forward. The terrain blending code for the Terrain Mesh Blending tool is separated into separate shaders and that’s the only code that would need to be modified. Not sure what package to include the modifications in though. :slight_smile:

Really love this tool! and I too hope you can make it work together with Colormap terrain shader,

Are substance textures supported?

And could you make the painting work with normal meshes too? not just terrain.

I would love to use this on mobile devices to blend my mesh terrain with mesh objects.

last questions, does it support multiple objects at the same time? Or we have to combine them in external application?

Yes, on the mesh.

Mesh-mesh blending? It’s very tricky - the reason it works well for terrain is that we can compute the UV coordinates from the XZ components of the vertex coordinates. It can work with any mesh that compute UV coordinates from position data - such as custom mesh terrain.

That is definitely possible as long as the mesh terrain computes UVs from position data.

You can draw as many as you like. We store the blending data per vertex in the mesh asset which means you will need one mesh copy per object with custom blend weights, but reuse the material. The benefit is that Unity can batch all blended objects with the same material in one draw call.

Thanks for the answers.

So if I understand this correctly it possible to connect a mesh to the terrain blend target in the inspector script? it does not look for type of object=terrain and accepts a mesh which I converted from a unity terrain?

Stu, do you have to paint the blend? If you just wanted an evenly distributed blend along the intersection and didn’t care about hand painting it to look more natural, could the extension do that automagically?

If you mean having a certain blending value applied over the entire mesh, then yes - just pick your values and press the Fill button. If you mean distribute it in some form of gradient, then no - but we do have some cool painting tools in-house that could be used to accomplish this. I’m sure some of those will trickle out into our Asset Store portfolio in the future.

Painting tools sounds great! :slight_smile: I think there is a way to use wacom pressure in unity, that should be useful for these kind of tools

It does restrict the type of object to Unity terrain currently. To get the tool to work with an arbitrary mesh you would need to use a shader similar to the Unity terrain’s, calculating UV coordinates from vertex positions and using a splat map (for multi-texture versions) to control textures. The guarantee that the connected mesh behaves somewhat like terrain needs to be there.
It would require some modifications to code, but it’s definitely something I’d be interested in implementing if there is demand for it.

I don’t know what that means, about the blending value thing. I think I meant a gradient, yes. I remember seeing very similar tech to yours in a dev diary for WoW: mists of pandaria, where when the artist sank a mesh into the terrain, it automatically blended the splat textures along the seam/intersection of the mesh and the terrain in an evenly-distributed meter-high gradient. That’s what I meant.

StuAssets I would purchase it for sure but only if you could meet those two or at least 1 goal. First is to get this tool working with larsbertrams color terrain shader, and second not that important but still would be great to have it is if this tool could work with any custom mesh positioned on terrain and not really being terrain detail mesh.I think that in overall that would help many people since plenty of them are using Lars shader for terrain and custom meshes.

Also would it be possible to get some idea how much of additional performance cost are we talking if we are using this tool?

Wait now after watching video again, on video it seems that you are not using terrain detail mesh at all but just standard mesh. Does that means its working with default non terrain meshes?

Didja watch the video? He just drops those rocks into the scene, they’re not detail meshes :slight_smile:

Yes i did, i guess i missunderstood what he was replying on before in last reply. Well good thing now this seems like a must have as if we only could get this tool working with lars shaders. Also his lightbeams are amazing, i dont get it he doesnt really do well job on displaying his products:P

Yes, I believe they use a similar approach to ours. I think this is the video you are talking about:
http://youtu.be/B7SL8mscXA8?t=36m13s
In the video, the assets are already prepared with blend values already painted into the mesh. This can be done with the Terrain-Mesh Blend shader by painting the vertices with Red (texture weight) and Green (normals weight) in regular modelling software (Maya, Blender etc) or just do it using the in-editor tool.

All you need to do when you have this prepared mesh is use the Terrain-Mesh Blend shaders (and maybe click Modify in the component to let it do some magic) and you’ll have the result displayed in the video, with the added bonus of normal maps if you use them. :slight_smile: