Search Unity

  1. Unity 2019.1 is now released.
    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. Kats4

    Kats4

    Joined:
    Jan 12, 2013
    Posts:
    186
    Fantastic @jbooth . I am very satisfied with MicroSplat. Met all expectations. Congratulations for the Active and thank you
     
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    So I'm wondering if you have any ideas for a particular need: I have large outdoor environments, and am switching from lightmaps for fixed times to a dynamic day/night cycle. The main problem that creates, of course, is that trees only cast shadows within the shadow distance limit, which means that the ground under more distant trees and forests isn't as dark as it should be. Ideally, there'd be some way for me to darken certain splats at a specified distance (with a fade transition, of course) to mimic the effect of shadowed ground. Is there any way I could do this (now or maybe with a future module) of MicroSplat?
     
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    I'm having a problem with the Terrain Blend module: I have a 4x4 terrain tile set, and the blending only works on one tile (well, I haven't tried them ALL, but it works on one tile but not the one I really want it to work on.)

    The shader generated by Microsplat is named Terrain_x1_y1_BlendWithTerrain, and blending works on that tile, but not on Terrain_x2_y2. I have regenerated the Terrain Descriptor Data on x2_y2...is there another thing I should do to get that to work? (And is there a way to have one shader work on multiple terrain tiles? I'm running out of shader keywords so I sure hope so....)

    thx
    Dave
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    You may need to apply the fix listed above. Each object finds the terrain below it and uses the terrain descriptor unique to that terrain.
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    Sorry, you mean this?

    void Start()
    {
    Sync();
    }

    To MicroSplatBlendableObject.cs
    ___

    If so, where in that script do I add this? I'm clueless about coding.
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    Anywhere, really. Ot send me the invoice for all your microsplat modules and I'll send you the 1.1 version of those modules.
     
  7. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    I also get the stitch effects on borders. This is, I believe related to dramatic height differences.

    It's most noticable on roads in my case:
    Unity_2017-09-02_18-37-15.png

    In this case it might actually be a 'feature' - but it's definitely something to look at
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    I would love a repro case of this so I can check it out.
     
  9. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Would it be possible to have a option in the anti tiling to blend in or lerp into the tiled normal or just remove the splat normal so that distance noise can replace it? Personally I think that blending out the splat normals and letting distance noise functions produces way smoother results and lets the distance normal effect really shine.

    Also I think that a contrast adjustment slider for the tilemaps could be handy as aswell to fine tune the distance sampling.

    I attached a picture of a hard transition to show the undesired effect.
     

    Attached Files:

    Last edited: Sep 11, 2017
  10. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Did this on a slow intel M convertible laptop while killing time. It was all done in slow motion but what I like about microsplat is that everything is quite intuitive and easy to get a feel of the levers, such that I can reduce the mouse clicks needed to get a decent result.

    Used mostly low res textures with a couple of high res ones.

    20170911_122230.jpg 20170911_120008.jpg 20170911_120734.jpg

    I will try to post something more polished in the future. Especially keen to test out the snow function.
     
    Last edited: Sep 11, 2017
  11. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Sorry for the late reply, I was abroad. We are all glad that you created Microsplat as competition is always good to bring the best out of everyone. If it's beneficial to you as well, I'd definitely vote for POM, as I'm pondering if it'll make things even prettier.
     
  12. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    86
    Wow,thanks for that!This forum really helps, Mr Booth!
    I have a suggestion here about the terrain blend feature, this picture below is about a function from the RTP geometry blend feature:
    upload_2017-9-11_16-28-37.png
    It can just blend the geometry border with height maps, so that we could blend flat pieces as well even though they are not intersecting with the ground. I think this will save some artificial pavement textures or something like that from terrain textures because normally they will just appear in some specific areas and not worthy to be part of terrain textures.
    I think this is more like the decal functions that UE4 does, but with more flexibility if we could paint geometry directly on the terrain, which is still a RTP function that really helped a lot. I prefer MicroSplat for a lot of reasons, so this is a just a suggestion that hopefully could make it better~
     
    coverpage likes this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    Added for 1.1- what you do is set the distance enough to cover the whole object, then paint 0 into the alpha channel of the mesh colors where you don't want the terrain blending to appear. You can use my vertex painter to do this, which is available for free on my github.
     
  14. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    86
    Cool,Mr Booth! That should be enough to do the job~
     
  15. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    86
    I've tried to follow your instructions using Vertex Painter Pro of MegaSplat:
    upload_2017-9-12_11-6-13.png
    upload_2017-9-12_11-6-40.png
    upload_2017-9-12_11-7-4.png
     
  16. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    86
    Am I missing some steps or having configuration problems, Mr Booth? Anyway, didn't work as expected, no matter I painted 0 or 255..
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    Well, you have to wait until 1.1 is released first..
     
    hippocoder likes this.
  18. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    86
    All right, cool~:)
     
  19. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    I'm still having some trouble with the Terrain Blending module. The blending works now, but I get several console errors (using MacBook Pro 2017, Metal Editor enabled, Linear lighting on 5.6.3):

    Metal: Shader[MicroSplat/AmethystTerrain_x1_y1]: Pixel format [MTLPixelFormatRGBA32Float] of texture bound at index 0 is incompatible with texture parameter [half _PerTexProps]. Compatible types [float]

    Metal: Shader[MicroSplat/AmethystTerrain_x1_y1]: Pixel format [MTLPixelFormatRGBA32Float] of texture bound at index 0 is incompatible with texture parameter [half _PerTexProps]. Compatible types [float]

    Shader 'MicroSplat/AmethystTerrain_x1_y1_BlendWithTerrain' uses 17 texture parameters, more than the 16 supported by the current graphics device.
    UnityEditor.DockArea:OnGUI()

    And the object with blending is dark, like it's unlit (and no effect from the normal map). Attached shows the same mesh, with blending added to the left one but not to the right one.

    (I have used Shader Control from the Asset Store to ensure I'm under the 256 shader keyword limit.)

    thx
    Dave

    blending.jpg
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    So, on OSX, Apple limits the number of texture samplers you can use to 16 - the GPU itself can use 32 and can share them, but for no apparent reason under OSX Apple limits them to 16 and does not support sharing them.

    So to get around this, you can either remove a feature that requires a texture, or reduce the maximum number of textures allowed on the terrain. For instance, if you're only using 12 textures on the terrain, then there's no reason to sample the control map Unity provides for textures 13-16, so you can reduce this down to get a sampler back.

    If you reduce the count down, do the other errors go away? The per texture properties are not stored in an RGBA32Float texture, rather a RGBAHalf, so the other error seems a little odd. If fixing the sampler count still has this error, send me your scene so I can take a look.
     
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    Reducing texture count to 12 did eliminate all those warnings, but didn't solve the problem. BUT I just noticed that another instance of the same mesh in the scene IS blending--though it seems to be blending more than it should -- the terrain splat covers it completely. Here are the two meshes side by side. Is there an issue with blending multiple instances of the same mesh?

    The project is huge, so if you can't tell anything from afar, I'll try to set up a small repro.

    thx
    Dave

    blending2.jpg
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    No, should work fine - though it looks like the terrain is set to totally cover the first mesh where as the second one is blending partially. There's a control on the component which controls how far the blend goes over the object..

    Also, note the issue with deferred rendering is fixed, but not posted to the asset store because I'm stuck in line on my last submissions (been over 2 weeks now). I'll submit those fixes as soon as they approve the stuff waiting in line..
     
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    1,980
    EDIT: Oh, sorry, I read back and realized that this darkness IS the deferred rendering issue. Looks great when I switch to Legacy Deferred. So never mind, I'll just sit tight and wait for the update.

    ____
    Yeah, it looks like that, but it's not. Anyways, we can ignore that, as I can't reproduce it. If I duplicate the dark mesh, it is also dark. So the problem is: Blending works but mesh is dark. It happens with other meshes too, even a sphere.

    Bummer about long wait for the new modules -- I really want to play around with water!
     
  24. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    Just a heads up.
    MicroSplatShaderGUI_PerTex.cs
    Code (csharp):
    1.  
    2. var path = AssetDatabase.GetAssetPath(targetMat);
    3. path.Replace("\\", "/");
    4.  
    needs to assign the return back to path.

    Also, it's possible to get the material and terrain assigned MicroSplatPropData out of synch if you rename the material after synch'ing to terrain. Easy to fix manually if you recognize the problem, but figuring out what happened can be a pain.


    Also - is there any way to edit in a fix for undo not working on the per texture settings? Editor code is my real weakness, I hate that stuff.

    Code (csharp):
    1.  
    2.  
    3.    public void SetValue(int x, int y, Color c)
    4.    {
    5.       #if UNITY_EDITOR
    6.       Undo.RecordObject(this, "Changed Value");
    7.       #endif
    8.  
    I added these on the prop setters. Not sure if this is the correct fix?

    ____
    Suggestion: Working with the microsplat material is a real pain if you need to switch between things in editor. I might recommend making an editor window for the material in scene so that you can switch to a material or the config asset.

    You may also want to roll the entire config interface into the shader editor.
     
    Last edited: Sep 14, 2017
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    Yeah, it will generate a new one if it doesn't find it. I thought about wrapping all of the objects in the MicroSplatData directory into a scriptable object, so people couldn't get access to them, but that would prevent you from doing things like sharing the texture arrays. For the most part, you shouldn't need to mess with that data though..

    Yeah, I can add that to the ToDo list. Your fix will likely work now that the data is stored in a scriptable object - it was originally stored in an HDR texture (and is at runtime), but Unity's HDR/EXR save/load seems to change between linear/gamma space somewhere during the chain, so I store it all in a SO now instead.

    This is basically what CTS does (well, it's all in an SO, not a material editor, but combining them into one object and one interface)- but I don't like it because it means if you want two sets of settings, then you end up with two sets of texture arrays. This basically means duplicating all the textures just so you can have a different set of parameters which is a crazy waste of memory. That said, do you know you can open two inspectors and lock one so it stays on whatever object you want to keep open? There's a small lock icon on the top of the inspector window- easy to miss, but crazy useful when you have an object you want to edit a lot.
     
  26. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    Fair enough. I have one last problem I'd really love your input on. I'm painting textures procedurally and I'd really like more control over which is visible at any given point.

    I imagine you're doing something like height * opacity per pixel.

    Do you think something like height * opacity * height_mid_grey (like some normalizing factor) might work?

    Any ideas on how something like this might be implemented?
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    I'm not exactly sure what your asking for. What do you want it to look like?
     
  28. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    284
    How does the terrain blending module work for objects that are in LOD groups? Could I just add the blendable object to the LOD group gameobject, or does it need to be added to each individual model in the group?
     
  29. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    If there are two textures on the terrain (plus base) and they're both painted to the same value - I'd like those two textures to have roughly the same amount of visible pixels regardless of the heightmap of each.

    You may actually be doing this already - I might have assumed you just blend the textures largely based on heightmap.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    I haven't actually tried this- but I would expect that you'd have to add it to each one.

    The way to do this right now is to normalize the height maps so they are at approximately the same average value. I could possibly add a pertexture property and button to compute this- I already do this for the tessellation offset, so it would just be a matter of figuring out how to best apply the offset to the height data as some kind of bias.
     
    frosted likes this.
  31. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    Not sure if this is something worth adding for most people or not, I've never heard someone else asking for it on other tools. But it'd definitely be useful for me.

    But could you give me a pointer to where you're calculating the offsets for tessellation?
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    If you look in the tessellation modules C# file you can search for the button that computes this by sampling from the low res mip of the height map and averaging the results. I think you'd want to use these values not as an offset, but rather as a way to bend the height data towards a center point. If you were to simply offset the height values of each texture, you'd end up not being able to fully blend to the next texture, or end up with undesirable artifacts. This is something I can play around with soon to see if it would be useful and understandable for most users.
     
    frosted likes this.
  33. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    just tried the 1.1 blending module ... perfect !
    thank you for implementing the slope feature .. awesome results :)

    would it be possible to have a runtime version of the Microsplat Blend Object Script ?
    i need to procedurally place the blendable objects ... but currently it won't let me.

    2s2.png
     
    Last edited: Sep 15, 2017
    StevenPicard, frosted and coverpage like this.
  34. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    I'd also be interested in runtime blend - I did this previously with rtp (nightmare) and would like to again.

    is this just done via vertex paint?
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    What do you mean by runtime version? It's fully movable at runtime. The only thing you may have to do is call sync on the BlendableObject component if you move it across terrain boundaries.

    No, you just add a component to your object and it does the rest.
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    I seriously need to do a MegaSplat/MicroSplat screenshot contest soon. Love seeing this stuff..
     
  37. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    to procedurally place objects (instanced), i need to put the Blendable script on a prefab ... and currently this doesn't work
     
  38. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    a few more then :)

    2G2.png

    2m.png

    2p.png

    2r2.png
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    Interesting- I'll see if I can fix this before the 1.1 release. No reason it shouldn't be able to work..
     
    sarum likes this.
  40. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    StevenPicard likes this.
  41. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    they are from the Speedtree Desktop tree package
     
    frosted likes this.
  42. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    lol, I own that, gotta go through some of the shrubs again. Thanks for the tip.

    Your environments really do look fantastic man.

    Oh - also if you don't mind me asking - how'd you do the road? The tracks following the direction of the road looks great.
     
  43. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    EasyRoads3D
     
  44. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    3,263
    You got a real talent for level design dude!
     
  45. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    sarum and jbooth like this.
  46. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Sorry missed this. I'm afraid I didn't do any objective comparison. Every try was to get accustomed to each one of the shader and not to compare them. But nonetheless here are some of the results. I'm not sure how helpful it would be:

    RTP:






    stylized

    CTS:






    Microsplat:



     
    Last edited: Sep 16, 2017
  47. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    164
    Hello could you add module for microsplat that will increase number of texture at least 32-64 we need? It will be very good for our projects we need terrain with a lot of textures on them.
    Microsplat additional textures something like this).
    Why we just don't use megasplat? Well it's too large and big things
    our project on unity connect.com
    https://connect.unity.com/p/585060a732b3060024579be6
     
    Last edited: Sep 16, 2017
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,491
    MicroSplat is limited by the techniques and tools Unity choose for terrains. They only support 16 textures. If you want to go beyond 16 textures, then you need an entirely different shader technique and tools workflow, which is what I built with MegaSplat. Almost the entire size of MegaSplat is the textures which come with it, which can be deleted if you are not using them.
     
    antoripa likes this.
  49. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    239
    first scene done with microsplat ;D
     
    sarum and coverpage like this.
  50. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    207
    5a2d.png

    5a3.png

    5d2b2.png

    5f3.png

    5f4.png
     
    coverpage likes this.