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

[Released] MegaSplat, a 256 texture splat mapping system..

Discussion in 'Assets and Asset Store' started by jbooth, Nov 16, 2016.

  1. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Is it possible to save the texture painting so it won't be reverted back to original state after compiling the texture graph? Like generating automatically bottom layer, painting on the top layer, then changing bottom layer via texture graph without touching top?
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, I don't think so, I believe it always overwrites all the channels right now- but that could be a useful addition..
     
  3. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Hello, I just bought Megasplat with the intention of using it to blend between my (non-terrain) ground mesh and my tree meshes in a small environment. I thought I'd be able to use it like the mesh/terrain blending node in Microsplat, but I can't find any tutorials on how to do this with Megasplat. Is it possible to do this and if so, can you point me towards the documentation?
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It's not automatic like MicroSplat, where you just add a component. You can see an example of a mesh to mesh blend in the ObjectBlend scene in the examples folder. Basically, both objects are textured using the same (or similar) shader which uses triplanar UVs so that the UVs will line up between both objects, then I used the included normal blend brush (it's a custom brush in the vertex painter, just like the MegaSplat config is) to blend the normals between the two objects to match.
     
  5. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Thanks for your reply. I'm not finding it easy to follow along with the packaged documentation under "Object Blending"

    "Select the boulder for painting, and the terrain mesh below it as the “Target object” in the brush options."

    I can't see these options, I can see "Blend w/ Mesh" and "Blend w/ Terrain" and that seems to do something, but I'm getting strange black artifacts appearing when I paint with the NormalBlendBrush and they won't go away.

    The documentation also says that I need to use a worldspace triplanar shader on both objects - but I cant find any info on how to set up such a shader. I can see the Procedural texturing section in the documentation, is that what I should be looking at? It doesn't include any info on how to open the Texture Projection Editor and I'm not even sure if this is how I'm supposed to set up a triplanar shader.

    Also, do I need to select the "Megasplat>>ObjectBlend" shader and apply that to both meshes to get two objects blending together?

    If I have to use worldspace/triplanar shaders then I can't see how I can use this to blend my existing tree assets into a ground mesh. Is there another tool somewhere to do that?
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Like I mentioned, it's not as simple as it is in MicroSplat where you just add a component to something and it magically works.

    Under the "Splat UV mode" option in the top of the shader is an option for Triplanar which will do triplanar projections from each axis. The reason for using this is that you need the texture to line up between both objects, and the only way to ensure that the textures between the two objects line up is to make sure they have the same UV coordinates, and the only way to do that without a lot of custom modeling is to use a projected texturing technique like triplanar (you could alternatively use a top down projection). Both the model you are trying to blend with and the terrain must end up with the same UV coordinates, otherwise the texture will not line up. That means you're tree would have to be textured with a MegaSplat shader as well, which you could potentially generate using the Alpha Layer and second UV set options (this allows you to use the Macro texture as the regular texture and paint splat maps on top of the object, and a second UV channel so your splat UVs can be triplanar, and your regular UVs can be used for the macro texture). Once the texture lines up, you should be able to paint on both objects and have a seamless texture - but you'll still have to get the vertex normals to align, which is where the ObjectBlend brush comes in. I have seen the black issue your talking about- I believe it happens when the normals or tangents get squashed to near 0.
     
  7. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Hello, thanks for getting back to me on this. I'll try the alpha-layer method. I'm not sure how I can get around or solve the black dots issue as it seemed unavoidable and I was just trying to blend the boulder into the terrain mesh in one of your example projects.

    I've not looked at MicroSplat, but is it possible to use it to do the blend between a terrain and a mesh, and then use MegaSplat (with the Alpha layer) to paint some moss over the join?

    Can you also point me towards some info on making a triplanar shader to work with the plugin?
     
    Last edited: Nov 7, 2017
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    With microsplat, you just add a component to an object and it blends with the terrain. You can adjust how far it blends up, as well as have the terrain grow over the top of the object, etc. It's all very easy, and will work with most shaders you already have since it's done as an effect on top of your existing shader. It doesn't really have to know anything about the shader you are using for the object. You could use MicroSplat to paint additional splat maps onto your object, but I'm not sure you'd need to unless you have some very specific use case.

    In MegaSplat, you can make a triplanar shader by setting the Splat UV Mode to triplanar. In microsplat, there's a triplanar module that adds a triplanar mode option to do the same (though has an option for height based blending as well).

    If you want to show me a mockup of what you're trying to do, I can likely give you a recommendation of how to achieve it. It can be a lot easier if I know exactly what you're trying to achieve.
     
  9. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    I'm struggeling the new 1.4 Terrain blending:

    I have activated blending in the terrain material

    upload_2017-11-7_21-32-23.png

    However, I can't find a button "Generate Terrain Blending Data" as stated in the docs

    upload_2017-11-7_21-32-48.png

    what am I missing?
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Looks like it was already generated - it now says "Update Terrain Descriptor" because it has a reference to the data. I bet the doc is a bit out of date, I'll update it, sorry for the confusion.
     
  11. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    Sorry, I forgot to mention the actual issue - my object which should blend shows this error
    :
    upload_2017-11-7_21-41-40.png
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have any errors in the console? It looks like it didn't regenerate the shader with the proper code in it.. If you have no console errors, try toggling the setting - it should pause for a second or two while it re-writes the shader.
     
  13. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    Ok, I created a completely new Microsplat assignment and it works now - no idea what was causing this. Thank you!
     
  14. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    I currently own Megasplat, and just noticed you released Microsplat. My use case for Megasplat is with Unity Terrains. Is there any performance benefit with using Microsplat compared to Megasplat on Unity's Terrain system? I do not use more than 16 textures with Megasplat if that helps. Oh and congrats on the new product, it looks awesome.
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat was designed explicitly for Unity terrains, as opposed to MegaSplat, which came from a mesh based technique and was adapted to work on Unity Terrains. MicroSplat is able to take advantage of this more limited focus to provide features like automatic terrain/object blending and dynamically generated water flows, and also performs faster than MegaSplat. Because it uses all of Unity's tools instead of needing it's own, it works with other tools without having to go through conversion steps or doing custom integrations, and it's design took advantage of about a year of work and feedback on MegaSplat, which makes it very easy to use and setup. For Unity Terrains, I personally believe it is a better choice. Finally, Texture Clusters are waiting in the approval line for MicroSplat, which while still being limited to 16 paintable control textures, allows each of those to blend 3 textures for a total of 48 textures on your terrain.
     
  16. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    1. Is it possible to scale up/down smoothness of the texture without changing the texture itself and then updating the texture array?
    2. Per texture normal map strength is capped at [0;1]. How can I change this interval?
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I believe there's a per texture smoothness modifier if you turn on PerTexture Material. For #2, MegaSplat uses a RGBA32 texture for the pertexture values, so the values are limited to the 0-1 range, but the way those values are interpreted is in the shader code, usually megasplat_shared.txt. For instance, I think 0-1 maps to multiplying the normal by 0-2 in the actual code.
     
  18. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    There is just a metallic and porosity slider. Manual states that:
    yet although given texture has no smoothness map, no smoothness slider is present.

    Also porosity slider does not work. As far as I understand, it should work together with wetness feature, yet there is no visual change.
     
  19. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    If I start with a single Unity terrain tile, convert the terrain to Megasplat, then use the Terrain to Mesh tool to convert to a mesh with multiple tiles, will Megasplat still work? Or should I first convert to multiple mesh tiles and then convert each tile to Megasplat? Is either workflow possible? By Terrain to Mesh, I specifically mean the following tool:

    https://assetstore.unity.com/packages/tools/terrain/terrain-to-mesh-47276
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The global porosity or the per-texture one? I will test both. Right, smoothness is currently not available as a per-texture modifier, and it looks like the docs are a bit out of date - as the new texture packer will generate a smoothness map if one is not provided, so basically you always have a smoothness map.

    I have no clue, as I have not used Terrain to Mesh. I would expect that it would still work if you were using the terrain shader type, but then the tools would not work since you wouldn't be able to paint on it anymore. if you converted it to a mesh type shader, and ran the mesh through conversion, then you could paint on the vertices, but whatever paint job you had would still be in the textures and not transferred.
     
  21. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    per texture; global one works fine
     
  22. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @jbooth Hi Jason just out of curiosity have you ever tried making the flow map and speed be directed by angle/normal and gravity? or would it all be the same speed down a hill and onto a flat area? I've been a bit busy on other projects so I'm not yet aware of your latest advances. I thought it would be a great effect and time saver if any stream system could just respond to physics or automatically emulate it.
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I do this in MicroSplat, actually, because it only works on Unity Terrains, and thus we know the surface is a height field with a fixed UV topology. MegaSplat works on completely arbitrary meshes, with arbitrary UVs, so while that option would work when working on terrains, it would completely fail on arbitrary meshes.

    You can't really use gravity though- flow mapping is a trick to make it seem like the UVs are moving at different rates, but if they really did move at different rates, the texture would slowly pull itself apart into an infinite stretch.
     
  24. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Will it be ported to MegaSplat terrain module?
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, because it would only work in some cases (terrains). Having different options for different material types is a support and code complexity nightmare, so I try to keep everything working in both workflows in MegaSplat..
     
  26. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Why won't you separate those two workflows then? It's not like anyone can change terrain type by just one click in shader. I know it made sense at first since megasplat evolved from this vertex tool with horribly long import times, but now wouldn't it be better to create lets say "nanosplat" (which would be tool for just meshes) and then megasplat would be just a package of both "splats"?
    It's just an idea, but you know, as a megasplat user, I feel sad I can't use such fine feature as mentioned earlier :(
     
  27. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    That's awesome you had already integrated the concept but sadly not in Megasplat.
    I just meant to use the values, the math for speed using angle/normals and gravitational force values.

    So if Microsplat works on height map based terrains maybe procedural Voxel based as well since height might be specified? I wish this was in Megasplat.

    I guess that might require custom code since Voxeland's height for example is set in the generate menu but it can additional be based on a height map.
     
    Last edited: Nov 10, 2017
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Voxels have no particular rules when it comes to topology and UV layout. A surprising amount of doors close when those things aren't known. UVs in particular are extremely problematic on meshes, since they can be laid out with overlaps, jumps, mirroring, etc. And voxel based terrains can have mesh based overlaps as well, which means you can't just store the state for something like dynamic water flows in a texture, because then the flow on the top would also be in the cave.

    It actually is one click in the shader, from mesh->terrain.

    I mean, I could remove terrain based workflows from MegaSplat and make it mesh only easily enough, but I don't see how that would help. The technique and code used in MicroSplat is totally different than MegaSplat, and has a very different look and set of limitations (16 control textures max, for instance), so it's not like they are at all interchangeable.
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    My talk from Unite has been posted:

     
    trilobyteme, antoripa, RoyS and 8 others like this.
  30. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    Hi Jason, I checked the first 5 minutes and saved it to watch later with more time and attention... I love the "procedural" prefabs so far... congrats on the speech.


    EDIT: Watched it all, very nice presentation full of great ideas. Are you planning on releasing some asset store tool based on this ? (I am thinking procedural world editor/spawner...)
     
    Last edited: Nov 11, 2017
  31. DiggingNebula8

    DiggingNebula8

    Joined:
    Oct 2, 2016
    Posts:
    21
    With PBR textures and brilliant art team, can one achieve Uncharted quality terrain with the help of Megasplat?

    Extra information: We're thinking of using World Machine and Splatmaps for generating terrain.
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, Asset Store stuff is what I do for fun in my spare time, anything on the company's dime stays property of the company, though we have open sourced things in the past.

    I would argue that you only get to Uncharted levels of quality by using tools you write yourself, that are extremely custom designed for your game's particular problem space. Things off the asset store may get you closer, faster, though..
     
    DiggingNebula8 likes this.
  33. DiggingNebula8

    DiggingNebula8

    Joined:
    Oct 2, 2016
    Posts:
    21
    One last question, Terrain Vs Sculped mesh in Zbrush? Which one do you suggest?
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Either can look good, just depends what you're after..
     
    DiggingNebula8 likes this.
  35. DiggingNebula8

    DiggingNebula8

    Joined:
    Oct 2, 2016
    Posts:
    21
    Sorry for the inconvenience, Does this asset support TerrainComposer2?
     
  36. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    yes it does... it is a terrain / mesh terrain shader
     
    DiggingNebula8 likes this.
  37. john_mike

    john_mike

    Joined:
    Jun 19, 2017
    Posts:
    6
    Thanks, a very good presentation with plenty of useful information. The improvements you made to the engine regarding dynamic batching and DrawMesh optimisations, will they be integrated to the official Unity releases?
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, though I believe they have plans for some kind of persistent draw mesh structure to eventually make it into the engine.

    MegaSplat has a converter which will convert from a traditional splat map terrain to a MegaSplat terrain. You basically map each splat texture in the terrain to a texture cluster in MegaSplat. This allows it to work, but means there's a conversion step you have to do after working in something like TC2. MicroSplat, on the other hand, works directly with Unity's terrain format, so doesn't require these types of conversions.
     
    DiggingNebula8 likes this.
  39. Emile-Swain

    Emile-Swain

    Joined:
    Jun 23, 2015
    Posts:
    35
    So, just fell foul of not clicking the Save button in Terrain painter. Honestly, i did not realise i'd not clicked that button having painted in a tonne of detail.

    Any chance of like making that button bright red when changes have been detected. Even a help comment to remind users to commit their edits. I'm also wondering if there are any unity pre-exit hooks you can tie into to warn users before editing they have unsaved edits.

    Feeling kinda dumb that i'd totally forgotten to save.
     
  40. daniel_toastvr

    daniel_toastvr

    Joined:
    Nov 13, 2017
    Posts:
    4
    Hi, @jbooth

    Currently MegaSplat has only Parallax Mapping right? Am I missing anything to enable Parallax Occlusion Mapping?

    We are looking at being really lazy with making buildings and sharp edges using POM and if we can do that using MegaSplat it would be amazing. Do you think it is possible to have some sort of integration between the Amplify Shader and MegaSplat?

    Atm Im stuck at trying to figure out how to feed DDX and DDY info into your MegaSplat Sampler Amplify Shader node - do you think that it is possible?
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, it happens often enough that I should make a warning appear above the button and turn it red or something..

    Yes, there's no POM. Due to the way MegaSplat blends, doing POM would be really expensive. I looked into doing a variant on it called Octree Occlusion Mapping, but abandoned it because it introduced a bunch of other potential issues. Overall, I think tessellation is a better solution for these types of effects as it tends to be faster, and POM will tank any hardware that can't handle tessellation.

    There's a MegaSplat node for Amplify that lets you do the basic height map based blending, but POMing through that would be unbelievably slow, so not advised.

    And you don't want to use the gradient samplers in a shader unless you absolutely cannot help it (I assume this is why you are using ddx & ddy). This is because it breaks the quad sharing on the shader which allows one texture lookup to be shared by 4 pixels, which can cut your shading rate to 25% of it's potential throughput. A reasonable (but slightly lower quality) approach is to precompute the MipMap level using ddx/ddy and use the lod samplers instead, which will operate at a slightly faster rate than the regular samplers do (This was a surprise to me, but something I recently discovered).
     
  42. daniel_toastvr

    daniel_toastvr

    Joined:
    Nov 13, 2017
    Posts:
    4
    Thanks for the fast reply Jason! I considered tesselation, but since Im trying to make sharp straight lines, it doesnt quite work that well. I guess Ill find another workaround, maybe using LODs with different meshes and materials.

    Will keep following your work with interest!
     
  43. RoyS

    RoyS

    Joined:
    Jan 12, 2009
    Posts:
    664
    I just purchased MegaSplat recently. I have purchased Gaia and Terrain Stitcher https://www.assetstore.unity3d.com/en/#!/content/42671

    I've researched both arguements - 1x large terrain vs multi-terrain. What is the max size single terrain that MegaSplat can handle and turn out good textures?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It works the same regardless of terrain size.
     
  45. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Hi Jason, I recently updated to the 1.5 version of streams/lava and am returned the following error in Unity 2017.1.1.f1 when building for the hololens (the previous version worked).

    Shader error in 'Hidden/MicroSplat/StreamUpdate': unable to unroll loop, loop does not appear to terminate in a timely manner (83 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number at line 124 (on d3d11_9x)

    Compiling Fragment program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_CUBEMAP_ARRAY UNITY_NO_SCREENSPACE_SHADOWS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_MOBILE UNITY_HARDWARE_TIER2 UNITY_COLORSPACE_GAMMA

    Any suggestions? Do I need to upgrade Unity?
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So that shader hasn't changed at all since streams was released. However, you can change like 59 to:

    Code (CSharp):
    1. float4 _Colliders[64];
    It seems like the shader compiler maxes out at 83 iterations of the loop. 64 colliders should be enough for just about anything though, so I'll change it down to 64 for the next patch anyway..
     
  47. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Ok, great, thanks I'll try that- this is also when building for the hololens so I'm sure that has something to do with it
     
  48. NightElfik

    NightElfik

    Joined:
    Oct 27, 2014
    Posts:
    27
    Hi Jason!

    First, thanks for the great shader and tools! We are looking to use MegaSplat for our game and I wanted to ask you a few questions to ensure that it can do what we need.

    1) Can MegaSplat handle LOD? We have a custom terrain mesh that has LOD levels. If we augment it with vertex colors, swapping different LOD level might introduce "missing" terrain textures, right? Also, we would have to keep all LOD updated with the vertex color info.

    We were thinking of using it through control texture like Unity's terrain does would allow for LODs without missing pieces of terrain, right? Would that be possible? We might have slightly different mesh setup than Unity though.

    2) We load our game dynamically, including all textures. Can we build the Texture Array on the fly during game startup and hand it to MegaSplat? Is there any detailed documentation on how this Texture Array should be setup?

    3) Is there any performance problem when updating control texture of the terrain very often? Say, every frame. I assume there is not, but for example Unity's terrain cannot handle this.

    Thanks!
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, changing vertex density will change your paint job, so to speak. What you can do is bake out the paint job to regular textures, so that at a distance you're just using a regular shader and not doing any splat maps (like the base map optimization Unity Terrains use). You can even use this map as your macro texture and cross fade to it in the shader automatically based on camera distance.

    You could use Graphics.CopyTexture to swap out textures at runtime, but I don't think it makes a ton of sense to do this- you can have 256 textures in your array, and if you were to blit new textures in there, you would have to load those new textures as well as the array, which is twice the memory. So you might not actually save that much verses just having one array with everything, or loading new arrays with each chunk.

    There's an example of how to paint efficiently on the mesh at runtime - note that meshes use vertices, and Unity Terrains use textures, each having different performance characteristics. (You can blit to textures, which is really fast, but with meshes you have to reupload the mesh - so speed depends on the size of your mesh).
     
  50. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    I'm not using vertex painter anymore, yet, I'm getting VP related errors, how to get rid of them?