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. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    What aspect do you prefer and what are you not liking? Hard to tell from your description.
     
  2. pselok

    pselok

    Joined:
    Feb 9, 2019
    Posts:
    3
    On a screenshot with microsplat enabled textures are like much less resolution than original.
    It's a sand and pebbles 2K texture: without microsplat i can see sand and more details as it should be but with microsplat enabled it becomes like low resolution texture. I tried to set everything to max in microsplat config but nothing changed
     
    Last edited: Feb 12, 2019
  3. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Ahh my bad. 2018.3.4. What is the latest version its working with? 2018.2?
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    The texture resolution is set in the TextureArrayConfig, and in newer versions of Unity you can see the textures and resolution on the arrays themselves. So check the output on the arrays themselves and make sure they are not set to 1k.
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    I've tested in the latest version of Unity, you should be fine as long as your are on the latest MicroSplat and not running a beta Unity version.
     
  6. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    57
    Hi, trying to add a shadow mask for Vegetation Studio Pro but can't seem to find where to add it to Microsplat, have checked the material and the MicroSplatTerrain script but no shadow slots.
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    I believe Vegetation Studio sets this- there's a setup guide for this on the Vegetation Studio site..
     
  8. pselok

    pselok

    Joined:
    Feb 9, 2019
    Posts:
    3
    Thank you very much
     
  9. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    57
    Thanks will take a look.
     
  10. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Great! With MegaSplat i use code like this to paint procedurally generated mesh terrain.. is there a way to do this in MicroSplat too?
    Code (CSharp):
    1.    if (megaSplat)
    2.             {
    3.                 c1 = new Color(light_v1, 0, 0, texture_v1 / 255f);
    4.                 c2 = new Color(0, light_v2, 0, texture_v2 / 255f);
    5.                 c3 = new Color(0, 0, light_v3, texture_v3 / 255f);
    6.             }
     
  11. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    118
    Hi, can instancing be used with the mesh-terrain blending module? For large amounts of rocks, etc.
     
  12. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Ahh i just read the megasplat vs microsplat comparison.. looks like its a no go.. hopefully i can get megasplat working for android..
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Yes, but it's stored in Unity's splat map format, which is one texture with 4 weights in the RGBA channels for every 4 textures on the terrain. You can use Unity's Terrain API for this, or if your doing this at runtime you can set it directly on the control maps unity generates to avoid the cost of using Unity's API.
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Yes, but you'll need to make sure the required data is on each instance of the mesh. This is what the MicroSplatBlendableObject does, and with instancing that won't be present on every instance.
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    So this weekend I did some more research into a technique that was released a few months back. I had messed with it and discarded it, but this week Unity released their own version that made it much easier to evaluate the technique and not wonder which errors were mine and which were deficiencies of the technique.

    While I'm most likely not adding this particular technique to MicroSplat, it did yield some interesting results, and lead me to come up with a variation on the idea which I think is much more suited to my needs. It's basically Texture Clustering, but without the need to author other textures.

    I posted my results here:

    https://forum.unity.com/threads/procedural-stochastic-texturing-prototype.628522/#post-4225696

    Here's a clip from the post, comparing a tiled image to texture clusters with 3 layers, and my new technique which uses only one texture (partially based off the ideas presented in their technique).

    Tiling Texture:


    Texture Cluster, 3 textures:


    Stochastic Height Blend (my new technique, only uses one texture):


    I'll be shipping this in the next version of the Texture Cluster package. Hopefully monday, before I head to Guatamala to relax for a week.. Quality wise, Texture Clusters are still better, but this is one button and your done..
     
  16. spinaLcord

    spinaLcord

    Joined:
    May 25, 2015
    Posts:
    29
    I don't know this a default behavior jbooth but i lose my layer textures on my terrain while syncing. I changed some code in MicroSplatTerrain script, so its working maybe for some other as well. But i have no idea this supposed to be, but i can paint now.

    MicroSpaltTerrain.cs Line: 269

    Code (CSharp):
    1.  
    2. [..........]                
    3. protos = new TerrainLayer[count];
    4. for (int i = 0; i < count; ++i)
    5.  {
    6.                        //Old: string path = UnityEditor.AssetDatabase.GetAssetPath(cfg);
    7.                             string path = UnityEditor.AssetDatabase.GetAssetPath(cfg).Replace("MicroSplatConfig.asset", "");
    8.  
    9.                             path = path.Replace("\\", "/");
    10.                             path = path.Substring(0, path.LastIndexOf("/"));
    11.                             //Old: path += "microsplat_layer_";
    12.                             path += "/microsplat_layer_";
    13. [..........]
    14. }
    15.  
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    So the code which is in my repository is:

    string path = UnityEditor.AssetDatabase.GetAssetPath(cfg);
    path = path.Replace("\\", "/");
    path = path.Substring(0, path.LastIndexOf("/"));
    path += "/microsplat_layer_";


    I note that your "old" comment has += "microsplat_layer_" without the first /. Otherwise, the two would get the exact same result..
     
  18. spinaLcord

    spinaLcord

    Joined:
    May 25, 2015
    Posts:
    29
    i was not able do edit my code (Spam timer).

    Code (CSharp):
    1. protos = new TerrainLayer[count];
    2. for (int i = 0; i < count; ++i)
    3. {
    4.     //Old: string path = UnityEditor.AssetDatabase.GetAssetPath(cfg);
    5.     string path =
    6.     UnityEditor.AssetDatabase.GetAssetPath(cfg).Replace("MicroSplatConfig.asset", "");
    7.  
    8.     path = path.Replace("\\", "/");
    9.     path = path.Substring(0, path.LastIndexOf("/"));
    10.  
    11.     //Old: path += "/microsplat_layer_";
    12.     path += "microsplat_layer_";
    13.  
     
    Last edited: Feb 17, 2019
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Oh, might be a double slash screwing up windows.
     
    spinaLcord likes this.
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Video on the new texture cluster stuff:

     
    Kirsche likes this.
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,057
    How many samplers does it require?
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    None.. it uses the ones it was using anyway.
     
    gecko likes this.
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,057
    excellent!
     
  24. Willbkool_FPCS

    Willbkool_FPCS

    Joined:
    Jun 13, 2018
    Posts:
    143
    Ok, I need anti-tiling(repeating patterns) for my terrain textures. It would seem that your Anti-Tiling Techniques add-on for MS would be what I want. But after watching the Texture Clusters video above, that might work. So what would be better for me?
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Depends on a few factors, and they can compliment each other too. I’m general, the Anti-tiling package contains more traditional and low cost techniques, while Texture Clusters has techniques of my own invention which are focused on the higher end of quality and cost. Previously one big difference was having to author texture variations, but the new technique doesn’t require that.
     
    Willbkool_FPCS likes this.
  26. Willbkool_FPCS

    Willbkool_FPCS

    Joined:
    Jun 13, 2018
    Posts:
    143
    I have about half a dozen 8k PBR textures that I'm using for the terrain. They look good close up, but some have quite a bit of repeating patterns, while one is only noticeable from a distance. Which module would allow me to reduce the textures to 4k but still look good closeup?

    BTW, enjoy your vacation!
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Ha, either, but in different ways. Anti-Tile has several techniques which are based on introducing noise; detail texturing, which blends in grain up close to prevent blurry pixels, and noise normals, which uses a second normal texture to perturb the first one over a larger area, preventing the overall lighting of the surface from tiling. These are both effects which have been used for years in games.

    With Texture Clusters, if you can author variations of your textures, then you could use 3 2k textures blended together to create a non-tiling surface which is the combination of all 3 surfaces. A noise texture is used to determine the weights of the texture, so this means that the point in which things repeat becomes very large, effectively creating a complex meta-surface from your three texture variations.

    The stochastic method I just added allow it to do this without needing to have extra textures- it's not as high quality because, well, you have less texture data, but it looks pretty good considering. As far as I know, the Texture Clustering concept was invented with MegaSplat, and remains something that only my products do. And the stochastic mode I added is also unique, as the original paper used a very different (and complex) blending method.

    Likely the best way to decide is to watch my videos on them, and see which one produces the kinds of looks your going for.
     
    Willbkool_FPCS, hippocoder and Rowlan like this.
  28. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,503
    I love your work on terrains. Really something everyone needs!
    (One day Unity will stop diddling with HDRP then it's time for me to buy all the microsplat modules, assuming you port!)
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Let me know when that one day comes. They're still futzing with LWRP and not documenting the changes. With no general abstraction layer, and few customers, it becomes a hard sell to port any time soon.
     
    hippocoder likes this.
  30. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    Hey, Microsplat beginner here.

    I added a new texture to the array and after pressing Update the textures don't show up in the Terrain layers.
    I was able to do it with one texture but upon adding the second it seems to have glitched out somehow.
    Any ideas how to fix this?

    microsplat.png

    ps.
    I saw in one of your videos you were using something called Vertex Paint (Megasplat video), should I refrain from using the native Terrain paint and use something else?

    Regards.
    H
     
  31. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    I figured out that this was due to some redundant files in the MicroSplatData folder.
    Deleting all the "microplat_layer_......" files and have them regenerated fixed it. :)

    I'm pretty sure that these redundant files were created when I re-arranged the order of the textures in the Texture array.
     
    Last edited: Feb 18, 2019
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Let me know if this happens again and what steps are causing it. I think there's still something funky in there with the new 2018.3 terrain stuff..
     
    Hallur90 likes this.
  33. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    I went ahead and got some of the MicroSplat extensions... very promising so far!

    That being said I get an error with the Tessellation and the Parallax.

    Shader error in 'MicroSplat/Example_Tessellation': invalid subscript 'instanceID' at line 924 (on d3d11)

    The Tessellation makes the camera partially clip the geometry and nothing happens to it visually. (See screenshot).
    The Parallax seems to shift the texture a tiny bit to the sides when the height is adjusted.


    tesselation error.png

    Any idea on what could be the cause?

    edit:
    I created a new project just to try the Tessellation on a new terrain and I get the same error as soon as I imported the Tessellation extension asset.

    Regards.
    H
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Do you have terrain instancing turned on in the terrain settings? Because Unity has a bug where tessellated surface shaders won't work with terrain instancing. I reported it a while back but have not heard back about it.
     
  35. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    I turned off "Draw instanced" and the clipping went away.

    The Tessellation effect does not impact the terrain though.

    Could it be my materials? What should I look into?
     
    Last edited: Feb 19, 2019
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Did you provide height maps for your textures?
     
    Hallur90 likes this.
  37. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    Yes.. at least I thought I did. Flipping through the channels on the Mask provided with the PBR texture raised the terrain.

    I'm using Megascans PBR and the Mask for the Height was set to use the wrong channel.
     
    Last edited: Feb 19, 2019
  38. Plumpman

    Plumpman

    Joined:
    Sep 7, 2012
    Posts:
    24
    Maybe I'm doing something wrong, but when I enable Stochastic it creates ugly lines on the terrain, almost like between the sampling points.
     

    Attached Files:

  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Does switching to the gradient sampler fix it? I might just need to force the gradient/lod samplers for this mode the same way I do for Per-Texture UV scale..
     
  40. Plumpman

    Plumpman

    Joined:
    Sep 7, 2012
    Posts:
    24
    Yeah gradient sampling fixed it!
     
  41. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    416
    Hello

    I'm playing around with the per texture brightness and contrast, but somehow i cannot get the desired results that I normally expect from a contrast. Normally in something like Photoshop, if I make the texture brighter, then I would also put up the contrast to the the darker parts "black" again. However with MS I cannot get a proper darkness back, just a grayish. Is there another setting or solution for this that I'm missing? Otherwise it seems like I have to edit the texture file in a photo editor.

    Here's an example, this is the default:


    now I would like it a bit brighter, but then I lose the dark parts, so I put up the contrast - but even at full contrast I lose the dark parts:


    Many thanks
     
    Last edited: Feb 27, 2019
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    So, I'm prototyping a change that would remove keyword usage from MicroSplat. If your not aware, Unity has a limit of 256 keywords project wide for shaders. MicroSplat has never *actually* used keywords- because it doesn't use shader_feature or multi_compile, as it would completely blow up Unity's shader compiler if it did (ever notice how much of your build time is spent in compiling shader variants for other shaders, and how MicroSplat shaders are never in that list?). However, it stored what features were active in the shader keywords string[] on the material, mostly as a matter of convenience since it's the only arbitrary data you can easily write into a material.

    The new system uses a scriptable object to hold the string[] instead; when MicroSplat loads, it automatically revisions the old data and removes the keywords. However, this presents a few challenges:

    - At runtime, I need a way to query this data for a few features. The MicroSplatTerrain component now holds a reference to this scriptable object for this use.
    - At runtime, I need a way to figure out if certain shaders are microsplat shaders. I used to search the keywords, but now I look for a string in the shaders internal name.
    - 3rd party applications might be testing for shader keywords to detect MicroSplat shaders. I will contact the authors I know of and see if they are doing this. (I might leave a single keyword in for this use?).

    Hopefully this will be an automatic and invisible conversion for people. But I figured I'd post this before I do the release of the next version.
     
    gecko and Rowlan like this.
  43. Hallur90

    Hallur90

    Joined:
    Dec 4, 2017
    Posts:
    34
    I've been trying out the Wind add-on and it looks pretty good for the most part.
    A problem though is when an area falls under shadow the wind highlights become very dark and it looks unnatural.


    dark specks.png
    Is there a trick you know of to make it look more natural?

    Regards.
    H.
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,057
    that would be hugely helpful, thanks!
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Can you send me a repro (threres like 5 different lighting engines in Unity) so I can have a look?
     
  46. Protolith

    Protolith

    Joined:
    Jan 18, 2013
    Posts:
    16
    Hello,

    I just started using Microsplat, and I've tested both the Triplanar shader and the Global Texture shader. I'm seeing normal map issues with both when turning on Triplanar texturing and when using a Global Normal Map. I'm using a bubble normal map to debug how the normals are being lit by the sun, and it appears that the calculations are incorrect. This can be hard to identify with noisy normal maps mixed with albedo textures, so you have to use a gray albedo, and the bubble normal map to be able to see it.

    Additionally I noticed the terrain isn't casting shadows even though the terrain mesh and the light are set to cast shadows.

    Any help you can provide would be greatly appreciated..

    normals4.png
    debug_normal_map.png
    normals1.png
    normals3.png
     
  47. Protolith

    Protolith

    Joined:
    Jan 18, 2013
    Posts:
    16
    normals_nav1.png normals_nav2.png normals_nav3.png normals_nav4.png This is a continuation of my previous post since the forum only allows 5 image attachments..
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    So, a few things. If you have a global normal map and triplanar on at the same time, normals can be incorrect in some areas because the tangents are based on the triplanar mapping. You can't have two sets of tangents for a surface shader; and you either need to base the tangent off of the dominant triplanar projection (to have the triplanar normals correct) or base it off the terrain (to have the global normal be correct). I allow it, because as you mention, in many cases for what we're doing (terrain) you can get away with it and be ok.

    Note that the global normal in MicroSplat is a blended normal (ie: blended into the terrain normal), rather than a normal replacement (which is what some other shaders do, reading the normal from a texture so the shading stays consistent through LODs). Not sure what you exact use case is here.

    As for the shadows, I'd double check your lighting settings and perhaps look in the frame debugger under the shadow pass and see if there's some reason it's not getting drawn.
     
  49. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    416
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,015
    Actually, I may have a way around this in the next version- I was working on something similar for a job I'm doing, and needed to have tangents correct for multiple mappings like this..
     
unityunity