Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[FREE]MicroSplat, a modular terrain shading system for Unity Terrains

Discussion in 'Assets and Asset Store' started by jbooth, Aug 9, 2017.

  1. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    212
  2. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Hi.

    Has anyone tried MicroSplat on a (recent) android phone?
    On my laptop MicroSplat performs just great. Whatever i throw at it, my framerate is about the same.
    Even when compared to the legacy diffuse terrain shader. And it looks so much better.
    But when i had my weekly Phone test session, my framerate dropped from 60 to 20 fps.
    Phone specs :

    Chipset Qualcomm MSM8953 Snapdragon 625
    CPU Octa-core 2.0 GHz Cortex-A53
    GPU Adreno 506

    My MicroSplat settings are all basic and fastest, and i am so far using 6 textures (512)
    I am totally hooked on how my terrain looks with MicroSplat, but obviously 40fps drop is weird.
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    I've done a fair bit of profiling on iOS using instrument's GPU capture, but haven't looked at it in an android GPU profiler yet (not sure there's a good one out there?). An interesting test without GPU capture would be to see if you are memory or ALU bound. You can do this by simply moving the camera away from the terrain, such that everything uses a lower mip map. If this increases your framerate substantially, you know that you are bound by the amount of texture data it has to read. If not, then it is most likely bound by arithmetic instructions.
     
  4. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    I did a quick test and found that moving away from the terrain indeed get's my framerate back up to 60.
    As soon as i get closer...
    So, memory bound it is.
    I'll try the k256 setting and report back to you :)
     
  5. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Unfortunately the k256 setting didn't help much. Maybe a fraction faster.
    Is there anything else we can try or am i doomed to a crappy looking terrain?
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    You can set the blending mode to fastest, which will limit the number of sampled texture sets to 2 per pixel. This should make it faster than a Unity terrain shader in most cases, since (if it was on a 4 texture terrain) it would have to sample 4 sets of textures. You can also set the max texture setting down to how ever many textures your terrain actually uses- I don't think this will be a big difference, but likely worth doing anyway. Other things to try are removing any features or per-texture properties to see if they are the bottleneck. PerTexture properties are stored in a very small texture, which means they are a dependent texture read, but since the texture is tiny the actual performance cost is very low, but on a mid-range mobile chipset this may have an effect.

    The real thing to do is to get this under a GPU profiler on your chipset- good ones will show you what percentage of the time is spent on each part of the shader, allowing you to easily figure out where the bottleneck is. I'll look into doing this on Android soon, but it will likely be after Unite, and the hardware on android varies so much that it's unlikely we'll see the exact same results. If you want to move forward on this yourself, I would suggest the following:

    With everything off, there are two parts of the shader that potentially make it more expensive than the Unity shader. Both are pretty easy to hack out, so you can see if either of them is part of the performance bottleneck. The first is the Setup routine- this routine is a pre-optimization step the shader runs to determine the minimal set of samples it needs to make. Setup returns a set of weights and indexes, if you hack out this function to return a fixed set of weights and indexes (weights as 0.5, 0.5, 0, 0 and indexes as 0,1,2,3, for instance), then it would screw up the look of the shader, but remove the performance cost of doing this step. The other is the ComputeWeights function, which could just return the input weights, skipping the height based blending all together. Also, if you attempt this, make sure to either do it in the fragment files, or do it in BOTH shaders the system produces.
     
  7. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Thank you so much for your in depth answer. I'll get into GPU profiling. Never done it before, but i'll figure it out.
    Need that skill anyway.
    I will also try your suggested hacks and get back on that.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Please let me know what you find- so many android devices, if we can find the bottleneck, I'm sure we can come up with something..
     
  9. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,093
    I need to set up several terrain materials for different platforms/quality levels, but I've run into a weird problem: If (on the Terrain settings), I switch the terrain to the default terrain shader, then switch back to Custom and assign the Microsplat material, the terrain shows only the first splat. I have to go to that MS material and slide the Per Texture Properties slider righward, and then the other splats appear. Any ideas?

    (Happens with your Demo scene too, at least the one in Core.)

    I'm on MBP with AMD 560, happens with both Metal and OpenGL editor.

    thx
    Dave
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Each terrain has it's own copy of the material- it doesn't actually use the template material directly. Whenever you change the template material in the editor, it automatically syncs the changes across all the terrain's internal materials. So if you change the settings via code or outside of the editor, you need to sync those changes across these internal materials- that's what the Sync All button does- but when you change a property on the material, it effectively calls this for you.

    So if you are going to setup multiple LODs, you need to call MicroSplatTerrain.SyncAll() after the change is made to propagate those changes from the template material to all the internal materials the terrain uses.
     
  11. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,093
    Got it, thanks!
     
  12. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    289
    I encountered the same problem with one of my terrains. The problem turned out to be caused by varying values for the per texture UV scale. If only the global UV scale is used, or if per texture UV scale is used but all values are the same, there is no issue. Varying the UV scale for different textures causes the problem.
     
    Last edited: Sep 18, 2017
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Most likely it's something with the texture derivatives being computed differently for neighboring pixels of different texture indexes. I had coded a fix for this a while back, but then couldn't seem to get it to happen without the fix, so backed out of it. I'll see if I can get it happening again and figure out what my fix was..
     
    camta005 likes this.
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    MicroSplat 1.1 submitted for review, with all modules updated. Please note that this is an internal version changing upgrade, which means that all modules need to be updated together, so please check the asset store version numbers before upgrading. Here's the change list:

    MicroSplat 1.1

    • Global Texturing Changes
      • Added distance mode to global normal/tint textures
      • Added opacity at near/far distance to global normal/tint textures
      • Added ability to warp Geo texture with an animation curve
    • Terrain Blending module
      • can now blend terrain on the tops of objects with a separate slope filter slider
      • You can now paint terrain blending strength in the color.a channel of your mesh, so you can blend a flat piece of geometry with the terrain, then paint 0 into the areas you was to show the original texture instead of the terrain.
    • Streams/Lava Module
      • “HeightWetness” added to the streams module, allowing you to specify a wetness level based on height which can be animated up and down for shorelines
    • Core Module
      • Modules you already own removed from ad carousel
      • Added lighting mode option that allows you to force a particular BDRF for Unity’s lighting. When doing so, the terrain will be forced to render in forward rendering mode.
      • You can now disable height based blending for a speed boost on low end platforms
      • Fixed issue with lighting being too dark on terrain blended objects in deferred when in shadow
      • Hash id added to fallback name to prevent naming conflicts causing the fallback to find the wrong shader
      • Fixed issue with Undo on PerTexture properties
    • AntiTiling Module
      • Fixed issue with 2nd and 3rd normal noise not being applied when per texture properties are enabled
     
    gremberman and coverpage like this.
  16. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    89
  17. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    89
    These fixes would be very helpful! Looking forward~
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Submitted at the same time - it was rejected for a trivial issue, so I resubmitted it with the 1.1 update tonight. Hopefully it'll all come out at the same time reasonably soon. Updates have only been a few days for me lately, it's just new assets that seem to be taking a while.
     
  19. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    For the most part they are two ways to solve the same issue - splat maps are a form of compression- low res control data used to paint blends between highly tiled textures to produce a highly detailed terrain. Where as virtual texturing systems are about having a really, really large and highly detailed texture that you load/decompress for the areas around you. Each has an advantage, but they don't really work together.

    Regular old loading techniques should be good enough to load in any non-splat map data in use, such as tint textures, control textures, etc. The compression used in streaming systems is also not a good fit for this kind of data, since it is usually based around lossy jpg compression, which is designed around perceptual colors- not data.
     
    coverpage likes this.
  21. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    I see now I understand it better. Am I right to say that lossy compression of the PBR maps (other than albedo) would mean streaming solution might not match splatmap approach when up close?
     
  22. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    89
    All right~The fixes mean much more to me, so worth the wait~
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Depends - in Rage, for instance, they baked lighting and shadows into these maps, so what they were streaming was not a PBR stream of data that gets lit, but the final result as a giant JPG. If you were streaming a full PBR spec, then you'd need to compress it into 3 textures (no alpha channel in JPG), which means you'd have to have 1/3rd the resolution for the same data rate, and wouldn't be able to use linear information and take advantage of packing things into alpha. Since the RGB channel would be packed together as a Gamma color, it would greatly reduce quality on things like normals. And the process for creating data in this manner is also a bear- a Rage level took 3 days to bake. For most cases, the idea of precomputing a giant JPG and streaming it is not that useful.

    Where Virtual texturing is really useful is as a runtime cache- basically, rather than rendering into the screen, you render materials into a texture page and use it as a cached result so you can use simpler shaders in your scene. Battlefield, for instance, does this for terrain- the terrain is your basic splat map approach with decals all over it - they render each chunk into a giant texture sheet, then map that onto the terrain. New approaches in rendering take that even further- at Siggraph a few years back the Assassin's Creed team presented a paper on GPU driven rendering, where every surface in the scene is cached to a Virtual Texture page as needed, then the entire scene is rendered from that in one draw call. Surfaces which stick around from frame to frame can use the previous rendering, so you get great amounts of savings per frame and most of your scene can actually draw in a single draw call. Anyway, great paper, you'll see stuff like this become a thing in Unity after SRP is mature.
     
    TeagansDad and coverpage like this.
  24. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Hi there, I would like to know the difference between microsplat and megasplat, does mega the full state of micro or they use different methods?

    Edit: by using micro for a while, it seems it still uses unity terrain's splat map but a custom material, does this mean I can get the splat info directly from unity's terraindata?
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Yes, MegaSplat is a replacement system for the whole texturing workflow, where as MicroSplat is a replacement terrain shader, and uses all the standard Unity workflows for terrain, for the most part (it reads splats from terrainData). The two shaders use very different techniques - MicroSplat is generally the faster shader, but MegaSplat can have hundreds of textures and work on meshes. MicroSplat is generally much easier to use than MegaSplat, as MegaSplat has to deal with terrain conversion, multiple workflows, managing large numbers of textures, etc.

    There are lots of other differences, and I really need a comparison chart for people, but haven't gotten to it yet.
     
  26. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Thanks for the reply!
    I'm wondering if I want to use micro instead of mega, though I've already own MegaSplat.
    But I really don't need 256 terrain textures in my game, and without unity terrain's splatmap can make several other assets I need a bit difficult to use.
    16 textures with micro is quite enough for me, but I'm wondering which one is faster and whether it's possible to have a discount with micro's addon assets if I already own Mega.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    For most terrain uses, MicroSplat is going to be faster than MegaSplat. There's not really a great way to do a discount for MegaSplat users within the asset store structure. You can do upgrades, but MicroSplat is actually 9 different assets, not a replacement/upgrade for MegaSplat, so that doesn't really fit into that structure. However, the MicroSplat modules are all very well priced for what you get, and most likely your game doesn't need them all, so for most people I think MicroSplat works out to be cheaper than MegaSplat if all you really need is a good replacement shader for terrains.
     
  28. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    Got it, I actually only need triplannar and tiling reduce, but I can't find triplanar in the store, the icon does show inside micro's inspector though
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Yeah, they just approved it today- unfortunately they approved the 1.1 version, which means you really have to wait for them to release the 1.1 update of MicroSplat/Anti-tiling first (hopefully within a day).. If you install it now, it will just show a warning saying that the versions don't match.
     
  30. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    818
    I can wait :)
    Playing MegaSplat for now.
    Texture clusters are very useful, but I found different height maps may not blend nicely.
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    1.2 submitted for review tonight.

    • Vegetation Studio Integration
    • Ability to disable anti-tiling techniques on bendable object shader, as these can cause streaking when relying on triplanar to prevent smearing on vertical surfaces.
    • Render baking
      • Bake out all channels of your PBR terrain to textures
    • Fix to streams module on terrains not at 0,0,0
    • Fix error when converting a Unity Terrain with no textures
    • Fix issue where parallax offset wasn’t working when tessellation is disabled
    • Fixed issue with per-texture properties bleeding across texture boundaries
    • Parallax now has a fade start and distance
     
    punk, antoripa, one_one and 4 others like this.
  32. Hitch42

    Hitch42

    Joined:
    May 12, 2015
    Posts:
    98
    Is there any chance of you making a short video showing the Terrain Holes module in action? I'm wondering how it works. Do you paint the holes with a brush, and/or can you import an image as a mask? Can you animate them? Could you use 3D models to "subtract" a hole in the terrain? Is there a way to limit them to certain textures? And so on. Also, I find your demonstration videos a good source of inspiration as to how to use these tools. Thanks.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    I include the documentation for all the modules in the main module, so that's the best place to check if you have questions about other modules. The holes can painted by designating one of your textures as the "hole" texture and using the normal painting workflow, or you can set a water height to clip all terrain below that height.
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Well, looks like Unity released 1.2 of the core module, but has not approved the other modules yet. I submitted them all in sync, so hopefully they'll all come through in the next few hours- but I would recommend not upgrading until all the modules you use have been updated, as otherwise the modules will disable themselves because of the versioning difference.
     
    gremberman likes this.
  35. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    89
    Hi, Mr Booth! I've got another question today..
    I've been busy trying MegaSplat and MicroSplat 1.1 recently, and really like latest terrain blend feature, but when I try to blend a MegaSplat Plane with the terrain blend function, things got a little weird.. I tried to fill the blend alpha and then reveal the mesh material by hand, but the result seemed not very under control, the blend edge was kind of messy and the revealed area was not quite what I originally painted with MegaSplat, like this:
    upload_2017-9-27_14-44-57.png
    I used a two layer MegaSplat 1.5 shader by the way. Is there a different progress when dealing with MegaSplat Material? Or they are not very compatible by now?
     
  36. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    89
    upload_2017-9-27_14-55-10.png
    The blend alpha and painted material seem to be affecting each other..
     

    Attached Files:

  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Let me verify- you are using MegaSplat for the mesh, and MicroSplat with the terrain blending module for the terrain? If so, the way terrain blending works in MicroSplat is that it simply draws a custom shader over the object after the regular shader draws- it doesn't know what shader it's being drawn over- could be any shader, so the edge should look the same on any material. Since it doesn't know anything about the shader it's drawing over, it can't really do a nice height based blend, so it does a linear blend and uses some noise from the height info it does have to rough it up a bit. Anyway, from the shots you've provided, I'm not exactly clear on what you are expecting it to look like vs. what our seeing.
     
  38. Sovogal

    Sovogal

    Joined:
    Oct 15, 2016
    Posts:
    89
    Quick question: are there any plans for official Map Magic support, or is the recommendation to use the generic custom shader output node? I've been having a difficult time making that work.
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    You'd have to ask Dennis- he has full access to my repositories, but I would expect it to just work with the custom shader output node, since the workflow uses all the standard Unity Terrain stuff (unlike MegaSplat, which is really different). What are the issues your seeing?
     
    Sovogal likes this.
  40. Sovogal

    Sovogal

    Joined:
    Oct 15, 2016
    Posts:
    89
    Thanks, Jason. I'm essentially having trouble understanding the custom shader output node (while the megasplat, rtp, and cts nodes were incredibly simple), which is a problem with map magic and not microsplat. I'll do the homework on it.
     
  41. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    387
    @jbooth this my first go with Micro Splat, I really like it. BOV_grimstead.png
     
  42. Sovogal

    Sovogal

    Joined:
    Oct 15, 2016
    Posts:
    89
    Jason, I know this isn't your area, but I really do appreciate the help. This is the issue I'm seeing trying to integrate Map Magic and Microsplat. Using this custom shader node, wiring it up to the first control texture in various channels, I see only the first texture in the texture array. I can change any of those layer dropdowns to any available value and the result is exactly the same. If I use megasplat mode (or cts, or rtp, for that matter), however, everything appears nicely textured. I'm more than willing to admit I'm a complete scrub when it comes to working with terrains, or understanding exactly how texture arrays are parsed. I apologize if I'm missing something remedial.

    upload_2017-9-27_12-45-46.png
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    Can't you just use the regular output node? I'm not exactly sure what the custom node does, as I haven't looked at this since we wrote the MegaSplat one together, and it didn't exist then.
     
  44. Sovogal

    Sovogal

    Joined:
    Oct 15, 2016
    Posts:
    89
    I can use the texture output node for the painting, followed by the standard Microsplat workflow of ingesting the maps into the microsplat material. Thanks, Jason.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    how'd you do the tracks? Decals, or another texture? Looks great!
     
  46. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    387
    Thanks bro, they're Decals
     
  47. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    387
    Do you have any plans to have rain drops? also I've not looked into texture arrays yet is it possible to change a texture at runtime?
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    I have them in MegaSplat, so it'd be pretty easy to port them over- I just left it out because it didn't seem like something people were using much, so it helps keep code complexity down. They'd go into the wetness/streams/lava module.

    You mean swap the whole array, or just one texture? The whole array is easy. If you want to swap one texture, you can use Graphics.CopyTexture to copy things into a texture array's slice (index). The main issue is that the size/format/compression/etc all have to be identical, so you'd want to get them all into the same format and do the copy's then. You could likely just pack everything into one giant array, and CopyTexture the ones you were actively using into the correct indexes.
     
  49. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    387
    Ah ok I have most of your modules, I might get mega splat also I have some biggish terrains 4k x 4k, but the action mostly takes place in smaller areas. I'm now thinking of creating meshes just for the walkable area's and using mega splat for those, so I can have more detail. From a performance point of view do you that is a good way to go? Also given that setup and the terrains being mostly vegetation free, do you think there's any performance benefit to converting unity's terrain to a mesh also and using mega splat for the whole thing? it's a PC/console game.
     
    Last edited: Sep 28, 2017
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,342
    MicroSplat is usually faster than MegaSplat for raw performance - the big benefit of MegaSplat is really the texture clusters, high texture counts, and ability to work on arbitrary meshes - but the workflow and blending can be pretty different at times, so it really depends on your needs.
     
    gremberman and antoripa like this.
unityunity