Search Unity

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

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

  1. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    112
    Well, depends what you mean exactly ;)

    It is always a tradeoff depending on the scale of your map, looks vs performance and so on.

    Yes, normally it would be rather lo-res... But your map is a large one you would need a hi-res colormap to still look decent...
    With the Terrain Composer/World Composer/RTP combo for instance you could have many terrain tiles with one big height map and a color medium-res map for each tile.
    The old 24-hour demo made by them of 900 sq miles was made from 4 color maps of each 8000x8000 as far as I remember...

    My own colormaps are usually 2048 x 2048 or 4096 x 4096, I guess.
    The whole point is that the eye is forgiving on rather low res for distance viewing but when you get close up you need real texturing.... The trick is to pull it off so the transition between them is perfect... Havent totally succeeded yet,,.. But I hope Jason can help me there ;):D
     
    coverpage likes this.
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    best thing to do is send me a scene so I can take a look. There are a lot of lighting pathways in Unity, so perhaps I've missed blending something that your scene is using.
     
  3. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    381
    @jbooth just wanted to swing by and say thanks for making this its fantastic bro
     
    magique and jbooth like this.
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,015
    Although I'd finally gotten reasonably comfortable with MegaSplat, this looked too good to ignore, so I've now got the base module plus anti-tile, global map, and tessellation modules. It's just fantastic, andI expect to buy the rest soon.

    MicroSplat has to be the winner among all the terrain shaders (and I've tried them all): quick and easy setup, simple and very usable interfaces, gorgeous results, and unbelievable performance. In a scene with a 4x4 tille (7km total) terrain, with the default Unity terrain shader, Camera Render used 1.5ms. I switched to the MicroSplat material with most options in the above modules enabled -- and Camera Render usage increased by just 0.5ms. Simply fantastic on all counts. (And Normal Noise, where have you been all my life!?)

    But of course, I do have a few questions:

    1) When I converted my terrain, the shader defaulted to Diffuse+Normal. I changed it to PBR, but I can't figure out how to make it generate those additional textures.

    2) Global Texture: I have a 4x4 terrain tile setup. Is there (or could there be) any way for these global textures to account for that and spread themselves over all the tiles?

    Oh, and +1 for Enviro integration

    thanks!
    Dave
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    Thanks Dave,
    Glad your loving it- I think this is some of my best work. But anyway:

    1. It always generates those additional textures. In fact, if you only put one texture in there, any texture, it will attempt to generate all the other maps from whatever data you supply. It just never shows them to you on the interface, because that interface is for you to fill out whatever you have. Everything goes directly into the arrays. If you only have Diffuse and Normal maps, you can just leave it on basic and it will generate the rest. However, providing your own height maps gives the largest difference in quality of any of the maps- this is because a higher quality normal can be generated from the height map if one is not provided than what would be generated from a diffuse map. And the AO/Smoothness are generated from the normal map (be it provided or generated).

    2. Right now you'd have to split it into 4 and set each one on each terrain component.
     
  6. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Heavy vegetation scene using microsplat.

    screen_1920x1080_2017-09-01_04-11-25.png
    screen_1920x1080_2017-09-01_04-00-18.jpg



    4k photos downsample to HD -_-



    compressed4.jpg
    compressed3.jpg
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,346
    Excellent! now if only there was a microsplat mesh edition with vert attributes...
     
    nxrighthere and Teila like this.
  8. evilangel89

    evilangel89

    Joined:
    Feb 8, 2017
    Posts:
    268
  9. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    You're right they are not speedtrees. I got the Realistic Nature Pack by Patryk Zatylny https://www.assetstore.unity3d.com/en/#!/content/58429

    Alot of the vegetation you see is from this pack as well.
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    So, my talk for Unite 2017 in Austin was just accepted ("The Walking Dead: March to War - Rendering 10,000 objects on Low-End Mobile Devices". We just shipped this game into the Google and Apple stores yesterday, and it's currently being featured in both stores. The game runs on OpenGLES 2.0 mobile devices, and I'll be talking about how we draw and animate a massive number of objects without access to modern features like instancing, as well as how we stream the world to users as they move around the map. We replaced most of the Unity lighting, shading, and post processing systems with our own custom solutions, wrote our own systems for packing nested prefab like structures, custom navigation and AI which handles hundreds of AIs on the map at once (including flocking ambient life), and more. The game features a massive world with day night cycles, weather, dynamic music, and survivors and zombies running around the map fighting each other.

    Here's a few shots to give you a sense of what I'll be talking about..






     
    Alverik, punk, frosted and 7 others like this.
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,346
    Super impressive but you guys replaced so much I wonder at times if there's a point to you using Unity :D Perhaps scriptable render pipelines will make the task easier if it would be used in future.
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    SRP is going to be a big win for us. We may have replaced large parts of Unity's normal rendering, but hardly anything close to what it takes to make a full engine from scratch.
     
  13. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    I cant wait to check that out! Its extremely impressive you guys managed to get so much going on on moble.

    So I am having a issue with trees. They aren't showing up on the terrain (speedtree or unitytree). I tried rebuilding the materials and double checked if they were appearing on standard terrain and they are. I haven't got a chance to see if the last patched fixed it yet. Any ideas on this?
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    None - MicroSplat just generates a shader, so it really can't control the drawing of trees. The only thing I could think of is if your tree's and not ztesting correctly and are drawing after the terrain, but that's unlikely unless you are using a custom tree shader.
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    Did the new options for the global texture module tonight:


    Instead of a checkbox and a blend mode, there's now just a single enum for the texturing modes (which can be Off if you don't want the effect). This makes the UI a little more compact and understandable. The new option is crossfade.



    All blending modes (except Off, of course) now have a fade start, range, and opacity values at the start and end of the fade. This means if you want 20% of your tint texture blended in up close, with 80% at the end of the cross fade, you can easily do that. This works for non-cross fade blending modes as well, so you can use it to tune the strength of the global tint/normal based on distance, etc.

    And as always, each texture can control the strength of this effect independently.
     
    Boz_1, evilangel89, Teila and 2 others like this.
  16. Veteran66

    Veteran66

    Joined:
    Jul 12, 2015
    Posts:
    21
    wauu thx :)
     
  17. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    Tessellation has issues related to grass rendering as well as physics calculation (foot placement).
    Reducing the tessellation distance to .1 is adequate for feet, but there's still noticeable problems with grass, especially low/dense.

    Any thoughts on this? I'd hate to need to build a custom grass solution for this.

    I remember you mentioning work on physics and tessellation - is that still in play?

    Compared to RTP - tessellation is very important for MicroSplat - and tessellation is a superior effect. But these kinds of problems are hard to overcome :/
     
    gremberman likes this.
  18. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    Extremely impressive. Nice to see an asset store vendor working on real games!
     
    Teila likes this.
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    If your trying to put very small grass objects along the surface, then you need to offset the placement according to the tessellation. There is at least one grass solution on the asset store which does this, as it uses the depth buffer to determine where to put the grass (can't remember the name right now though). Note that you can reduce the overall offset error by turning on the per-texture offset and pushing the button below it which will calculate the ideal offset for each texture.

    For MegaSplat I have a component that allows you to calculate the tessellated offset of a given position on the CPU, which would allow you to write a grass placement system that uses that displacement and places the grass accordingly.
     
  20. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    Are you planning on releasing the same component for Micro?

    I can't imagine using depth to place grass would work without a fixed camera angle? Let me know if you remember the name of the asset. I'm definitely not a shader wizard yet, so if this is possible I'd like to learn how they did it.
     
  21. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    Also - reducing the amount of fresnel is fairly straight forward.

    Here's the before and after:
    Unity_2017-09-02_11-21-27.png

    After ... because dirt and stuff may not want to be that shiny. Especially if stuff like grass isn't equally effected. I could reduce further, but I think this is adequate for my needs and very very minimal in terms of change (one line in cginc).
    Unity_2017-09-02_11-21-09.png

    Only change is to use a different bdrf calc:
    Code (csharp):
    1. #define UNITY_BRDF_PBS BRDF2_Unity_PBS
    you can optionally adjust via multiplier - but this requires more maintenance and i thought the one liner was just less annoying and works for my needs at least.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    You know, it might be possible to do this in the MicroSplat shader as an option without the cginc by undefining the macro and redefining it. If that works, then I'll look into incorporating this as an option in the shader compiler for 1.1 so it's just a checkbox.
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    I think the idea is that they only use it for really low lying grass where that isn't an issue. You can reconstruct the world position from the depth buffer, so you place really small instances based on that. As for the component, yes, but it might be a while as I have some work on MegaSplat to do first. It would also be useful for the streams component, as it will make it easy to tell if your on lava/etc without having to dig into the data yourself, which I think people are going to want.
     
    Last edited: Sep 2, 2017
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    Another new feature this morning, the ability to adjust the height of the geo texture across the terrain using a curve. Excuse the unpolished testing screenshot.

     
    Teila and coverpage like this.
  25. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    If that's possible then great - this issue will be a common complaint once people start using this outside of demo scenes. RTP uses a more elaborate system with more customization, but for my needs at least - this is adequate.

    Again, the primary problem (at least for me) is grass.
    Grass on BDRF1
    Unity_2017-09-02_11-47-48.png

    Grass on BDRF2
    Unity_2017-09-02_11-48-48.png

    Sorry about the super rugged testing surface - I'm just using for testing. Obviously Microsplat is capable of far better visuals (edited in spoiler tag so ppl don't have to look at fugly screen clips).
     
  26. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    208
  27. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    208
  28. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    @jbooth
    Just a heads up - the full fix for the fresnel is more significant. The one line fix only works in forward rendering. In deferred there is unfortunately a more complex process which I think will require overriding UnityPBSLighting (although I am no expert, so I could be wrong).

    I can send you code if you want - although I'm sure your work is superior to my filthy shader hacks.

    Uncorrected:
    Unity_2017-09-02_15-22-16.png

    Corrected:
    Unity_2017-09-02_15-21-44.png
    Without adjusting the specular term on ground - the highly reflective ground highlights stuff like grass detail culling.

    This kind of thing is especially apparent when you need to set a lower culling distance to save performance and stuff - since ideally ground texture and grass color should kind of blend.
     
    Last edited: Sep 2, 2017
    gremberman and Lysander like this.
  29. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    I'm really very impressed with MicroSplat. The code is really well organized and clean (incl. shader code which is always a mess generally).

    I've worked with RTP for a long time, none of the other terrain shaders came close to the same quality of result if used well. With MicroSplat I was able to put together a result that's finally better. Most of the work transitioning was done in 2 days and was fairly minor (this is not just moving splat maps over, I have a bunch of tools also - and had made custom modification to RTP).

    The tessellation issues are a drag since tessellation isn't really usable until there's physics integration - but the clean code makes all the difference.

    @jbooth - excellent work dude. I'm not impressed with most asset store junk, but this appears exceptionally well done from top to bottom. There are a few minor problems but man - really slick work.
     
    Alverik likes this.
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    Complex shader systems tend to devolve into what I call "The Tower of Macros"; eventually the layers of macros on top of macros becomes an unmaintainable mess, so you have to work very hard to prevent this from happening. (Unity's Standard Shader is exactly this). MicroSplat is actually the fifth shader generation system I've written, and I find the approach very preferably to the traditional way most of these systems are created.


    Glad you like it- please spread the word or write a review, as it can really help. Happy to address those problems if possible. In regards to specular model, I'll see if I can come up with a simple way to add an option to choose specular models that works in all rendering modes - but I'm only going to add something if it fits into Unity's Surface Shader model. For MegaSplat, I used both surface and vert/frag shaders, and maintaining compatibility with Unity's undocumented and constantly changing lighting pipeline has been a total nightmare. A big goal of MicroSplat was to keep the project simple and clean, even if it means some features are out because of it.
     
    Last edited: Sep 3, 2017
    Alverik, gremberman and hippocoder like this.
  31. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Sometimes I stay up way to late and do stupid things.. like forget to check all the terrain settings then post on a forum, turns out the tree distance was just set to zero. haha.

    Well I finally found my terrain shader. I own pretty much all of them on the asset store and this one was the magic gem.
    I also finally came around to tessellation, I got the perfect setting to get the small details I love with very little performance impact. This shader is just blazing fast all around! Visual3.png
     
    punk, Lysander, jbooth and 1 other person like this.
  32. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    In terms of preparing PBR ground textures, do you have any recommendations? I'd rather not add Substance Designer/B2M to my workflow, but I'm not sure if there are any other real choices.

    I'll be giving you a 5 star review soon.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    The thing that matters the most is the height map, followed by the normal map. I usually use some combination of Photoshop and Substance Designer, but occasionally Crazy Bump with some touchup. There's also stuff like Quixels scanned texture library, which is very high quality.
     
  34. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    394
    Very nice pic - are you using a third party grass system?
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    The problem with deferred is deeper than that, actually. In deferred, lighting is applied to the GBuffer, so it's not really a per-object kind of thing. You basically have to replace Unity's lighting pass shader entirely. The only way to do it per object is to start marking stencil bits for materials (or write into another render target or free channel in the GBuffer). This can be done, but won't be as simple as checking on option for the user, and would likely cause support issues for me and other assets which attempt to modify the same pipeline.

    The only option I could see working is to force the terrain to render as forward when these modes are set. Not sure if you can do this with a surface shader or not, but I'll look into it..
     
    evilangel89 likes this.
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    @frosted So this is in as an option- it will force the shader to render in forward rendering when used, so it will "work" under deferred rendering..
     
    Last edited: Sep 3, 2017
  37. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    208
    frosted likes this.
  38. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    I ended up having to delete Microsplat from my project because it was somehow causing Windows standalone builds to crash when changing scenes. It was an odd one a it would work fine in the editor. I did have Megasplat in the same project so maybe there was some kind of conflict as it did not really seem to work properly. The PDF file seemed to indicate that it would build any missing texture (normal, height) but that did not happen either. Tried removing and installing the package again but that did not help. I am assuming that Megasplat on a mesh terrain will still be much faster so I intend to do that way anyway but was trying Microsplat out for a better looking quick prototype.
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    That seems really odd- I developed MicroSplat with MegaSplat installed in the same project, so as far as I know they don't have any conflicts..
     
    antoripa likes this.
  40. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Nice, the style is consistent and pleasing.

    You should really upload the video (into a video sharing site), I'm running Linux so I'm not too concerned, but when I'm on windows I typically won't dare download attachments.
     
  41. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    It was certainly weird. If I get a chance and I still have a backup of the project with the problem in place I'll see if I can strip it down and shoot it over. I was additionally odd as the same scene seemed to be working fine if it was the first scene on startup. The crash seemed to happen when loadscene was used to load it. After much hair pulling looking for was was causing the crash, it turned out that removing Microsplat from the project and going back the standard terrain shader stopped that crash. No other changes were made at that point. Given that I need max speed possible, I intended on using Megasplat with meshes anyway so I was not overly concerned. Just need to find a good mesh workflow for that approach.
     
  42. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Not currently, just standard unity grass. I think the grass is the largest performance hit in the scene at the moment (using 10 different grass types!). I will probably use VegetationStudio when it's released. If you're interested in the visuals of the grass I am using AFS v5 and NGSS with the contact shadows on for grass shadows.

    Check out the OnTerrainChanged method in the MicroSplatTerrain script. I had to change this method to accept a integer before I could build my project. Without doing this it was throwing me warnings about a missing texture and a incorrect message value even though it worked fine in the editor.
    Code (CSharp):
    1. void OnTerrainChanged(int flag)
    2.    {
    3.       var flags = (TerrainChangedFlags)flag;
    4. // The rest is original code
    @jbooth I guess this is also a bug report as well as possible solution.
     
    Last edited: Sep 3, 2017
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    What version of Unity is this happening under? I wonder if they change the API for some reason, though I can't imagine why they would make it less typesafe..
     
  44. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    I'm cool with whatever, honestly, most of the "tower of macros" is beyond my competence level. I have a hack that works for my needs, there are artifacts - but for me, it's fine.

    If you can find something better then I'll switch, if not - cool. Keep your code base manageable.
     
  45. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    I personally think you should build a grass system next. I need to get rid of unity grass and don't trust unature or critas. :)
     
  46. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    I am using 2017.2.0b2

    I also recently installed the latest Unity beta but apperently it introduced a bug with generating Mesh's that can not be fixed (With out source code) and broke UMA2 from working on the latest beta so I went back to using 0b2. So I am not sure if having it installed would effect anything from running other versions of unity or not.
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,570
    Ok, given that it's beta2, I'm going to not worry about this until it gets a little more mature..
     
  48. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,595
    two new tools are coming soon Infini Grass 2, and VS .. both in beta atm.. and look super nice with either Micro splats or mega Splats terrains)
     
    antoripa and Baraff like this.
  49. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,496
    I think critas is probably the most believable, he's also trying to use his product in game, so it really needs to work.

    Benchmarking his trees though - I saw very little difference compared to more recent Unity vanilla. So I skipped it - since it took more work and was certainly less tested than Unity's out of box system.

    Infinigrass was so slow - his demo area needed to be a meter wide in order to not completely tank his framerate.
     
  50. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,595
    https://forum.unity3d.com/threads/wip-vegetation-studio.479244/

    One tool I was talking about, very amazing, I believe Jason was or is not 100% working with these guys but not for sure. I know he works with a few people...

    Tool is in beta very amazing..

    I have a mobile game with InfiniGrass 1 abput 25 Km x2, never had issues, using it now for a 50 KM X2 PC game, no issues either. So not sure...why you had issues, InfiniGrass 2. is way faster as well, which is in beta ....and nearly released, so another one I suggest. Again not 100% Jason works with the first tool or not. But I know both tools look great with Jason shader tools. regardless. I never have performance issues. with any of these.
     
    antoripa likes this.