Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'Assets and Asset Store' started by PrimeDerektive, Sep 12, 2012.

  1. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    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.

    http://u3d.as/content/stu-assets/terrain-mesh-blending-tool/30h

    $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?!

     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    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
     
  3. Knightmore

    Knightmore

    Joined:
    May 11, 2012
    Posts:
    227
    @larsbertram
    Also it would be nice to know, if it works with your Colormap terrain shader.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    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
     
  5. Knightmore

    Knightmore

    Joined:
    May 11, 2012
    Posts:
    227
    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.
     
  6. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    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. :)

    @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
     
  7. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Wow, looks very cool, a bit pricey (for my budget), but looks like something I could use at some point.
     
  8. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    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. :)
     
    Last edited: Oct 18, 2012
  9. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    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?
     
  10. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    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.
     
    Last edited: Oct 18, 2012
  11. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    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?
     
  12. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    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?
     
  13. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    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.
     
  14. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Painting tools sounds great! :) I think there is a way to use wacom pressure in unity, that should be useful for these kind of tools
     
  15. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    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.
     
    Last edited: Oct 18, 2012
  16. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    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.
     
  17. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    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?
     
    Last edited: Oct 18, 2012
  18. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Didja watch the video? He just drops those rocks into the scene, they're not detail meshes :)
     
  19. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    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
     
  20. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    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. :)
     
  21. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    I know, I feel like it would be weird with the colormap shader though. What does it blend with? colormap at a distance, detail textures with colormap hue up-close? Seems like a lot of work, but what the hell do I know.
     
  22. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Yes you are right it does sounds almost impossible. The thing is that sure splatmaps can be blended, but then color map ruins it becouse it has different colors, and the only solution would be if main color map would not be visible at all from close distance.
    Maybe lars has some suggestion.
     
  23. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    94
    So Stu are you going to make a version that works with lars shader? :) I think they'd both be an instant buy if they worked together. Thanks
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hi there,

    the color map should not be the problem…
    but i think the shader would have to be a 2 pass shader as at least the color map Ultra shader uses all texture samplers available in sm 3 – and you would need the textures of the model itself too (at least +2).
    it might work as single pass shader if you could afford to drop lightmapping on the terrain though.

    lars
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hi there,

    just a simple proof that mesh blending works with the ats color map Ultra shader in case you can live with the limitation that the mesh has to be placed at a point of the terrain where there is just a single detail texture at 100%.
    defined terrain detail map, defined terrain detail normal map and the color map are fully taken into account, but you will notice that the lighting has got some discontinuities for the mesh normals are not blended with the terrain normals.


    $rocks2.jpg

    $rock1.jpg


    lars
     
  26. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
  27. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    94
    Lars, does this require a code or shader update?
    thanks
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    it is a completly new shader.

    lars
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hi there,

    i figured out how to blend the normals in order to get less visible seams as far as lighting is concerned.
    right now the shader supports just one terrain texture to blend with but after having though about it i am pretty sure that it should be possible to even support blending with all 4 lower detail maps of the color map ultra shader.

    lars

    $normal_blending.jpg
     
  30. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Great results!
     
  31. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Excellent work.
     
  32. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    I've created a version of the TerrainMeshBlend shader that blends well with lars' terrain shader;



    Using the free colormap shader as a basis.

    This blends well even in slopes, as all our shaders do.
     
  33. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    With lars providing a much more simplified but working alternative to your solution, what tools do you provide to enable a faster integration of these kind of things? Someone posted in one thread about a somewhat automated process for this where meshes would automatically blend, would this be possible with the unity api with meshes tested by, say, collision, and a given threshold to make it a very quick process? I'm just throwing ideas around
     
  34. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    From my understanding, what lars is providing is a shader for blending the texture of the terrain onto a mesh. The most basic shader we provide does that, while our normal mapped versions use the actual terrain tangent basis at each vertex position to blend perfectly with the terrain, even in slopes. We provide several shaders with different performance characteristics, for blending between several terrain textures or simply a single one when you need that extra bit of performance.

    We also provide a full package for quickly painting objects in-place in the editor, without requiring tedious exports from third party modelling packages and the mismatches that will follow. The painting tool comes with a full array of convenient and familiar in-scene hotkeys which artists will love - there is no need to go to the inspector to change your painting settings.
    The process you describe is definitely possible - using the height difference between vertices and the terrain to generate weights - and it's definitely something we'll include in the package if there is demand for it.
    Internally, we prefer painting the weights manually for total artist control - the improved results are definitely worth it. With the included weight painter it's an extremely quick process to fully paint weights for a mesh. :)
     
    Last edited: Nov 5, 2012
  35. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    You've given a perfectly adequate response, i think you provide a great tool for those who need it. As i say to most folk, choice is good, if you could provide an automatic weighted blending routine (with a given falloff/threshold) to quickly blend in a mesh with the artist able to fine tune afterwards you will really have a brilliant solution, well worth the money.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    funny! as you haven’t answered my pm i thought you would not be interested in porting the color map shader and started to write my own script/shader.
    it is just a pretty simple solution and can’t compete with your tool but i still like the result.

    $blend_slopes1.jpg

    $meshblending.jpg


    lars
     
    Last edited: Nov 5, 2012
  37. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    you guys should work together and average out the pricing, then i can afford it and you single handedly contribute to making unity extremely competitive, everyone wins! self serving as ever, i am
     
  38. StuAssets

    StuAssets

    Joined:
    Oct 18, 2012
    Posts:
    11
    Sorry! I honestly did not notice! I've sent a reply.
     
  39. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    some auto blending (not for my good im fine with max) and a price i can afford and unity becomes one step more awesome

    i think unity should ship with pointers to the brightest lights in its asset store because while it suffers without them, and noone thinks to regard it, the asset store sees it step toe to toe with all the main contenders at a fraction of the cost

    i think with some luck i'll be able to provide a lovely shader pack for free, who knows! hope you folks work something out
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    guess so!

    lars
     
  41. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Thanks to Lars StuAssets (I bought both your assets) my dream of proper terrain holes for my project came true. Big ups to both of u!

     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    that already looks quite perfect to me!
    well done – and pm is going to be send.

    lars
     
  43. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,052
    interesting i guess it's now possible to create custom cliffs and overhangs as well as caves and caverns now. The combination of those 2 tools might really create some truly impressive things.
     
  44. CoryChang

    CoryChang

    Joined:
    Nov 7, 2012
    Posts:
    1
    Hi Stu

    After seeing your demo in youtube, we are interested in the Terrain mesh blending tool. However, even we have checked all the articles here, we still have some questions.:confused:

    First of all, basically we are more interested in the "mesh-mesh blending". I mean that can we apply the tool on two custom meshes? And we can have the two meshes blended magically as same as the demo?
    In our case, we are used to input a FBX floor into Unity, and place some FBX props on the floor. So can we apply the tool on the floor, and the props, and then get the magic blending result?

    Second, if not, in order to get the same magic blending result, do we need to ask our programmers to write some scripts or new shaders which can define the XZ components of the vertex coordinates or when we buy the magic tool, and it is already including the scripts or shader?

    Thanks:D
     
  45. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Wait what? With that tool or larses one you can create caves? I dont get how does this works in inverted dirrection. Quickfingers what is procedure to get this working?
     
  46. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    janpec the caves aren't created in this tool, that's just custom meshes, but I'm using this tool to blend where the cave meets the terrain so that there is no visible seam
     
  47. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    You make a big hollow in the terrain then put a lump of mesh over it and blend it? Hadnt thought of that, and very exciting prospect for what can be done, that said, nice!
     
  48. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    I understand what janpec is questioning though... that would only work on caves that go straight down... if you dug horizontally into a cliff, wouldn't you see the terrain showing through in the empty space of the cave mesh?
     
  49. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well, for a cave your model would just be significantly larger as it has to comprise of the cave and the outer walls and ground above until it can meet the terrain again, but the same principle applies
     
  50. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Except the cave mouth opening, there is no way to "erase" the terrain that would be showing through at that point, and you couldn't dig horizontally into the terrain to remove it. That's what I was referring to.
     
    Last edited: Nov 10, 2012