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:
    3,573
    All the splat weights are stored in the Unity Terrain itself, is some of your gameplay code interacting or setting this data?
     
  2. AERwaevs

    AERwaevs

    Joined:
    Feb 28, 2013
    Posts:
    3
    Hi Jason, strange issue with what I've narrowed down to be the Texture Clusters module - specifically the stochastic sampling option. It appears as if when stochastic sampling is enabled, the highest (sharpest) mips of the normal maps are causing ambient light contribution to be 0, like so:
    upload_2019-7-8_17-5-17.png
    After much trial & error I found that if I adjust the mip-map bias in the normals texture-array to be around 2 (so that lower mips are used closer to the camera) the issue disappears. Obviously that is not an ideal solution when I'm trying to push fidelity ;)
    upload_2019-7-8_17-5-58.png
    I seem to recall finding a problem like this far earlier in the thread but never found an answer (I may have skipped past it) but do you know if anyone else has encountered a problem like this in recent times? Or might you have any idea what could be causing it? Cheers!
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    That doesn't make much sense- However, if your biasing your mips down, you are also averaging your normals (and smoothness/ao) towards the average value. There's actually not a good way to generate normal/smoothness mips, because in real life they don't average, but rather roughness/smoothness is effectively defined by the sub-pixel normals, so to speak. Anyway, my only thought is that as the high frequency information of your normal is actually causing the issue, and that as you reduce to lower mip levels (thus removing this high frequency information) you're getting the result you want.
     
  4. AERwaevs

    AERwaevs

    Joined:
    Feb 28, 2013
    Posts:
    3
    Hah, I know it doesn't make much sense. I've spent much time trying to work this one out on my own before asking here. It's worth mentioning that I have the textures packed using the quality option, so adjusting the bias only affected the normals, however having a lightbulb moment (of course only after asking you about the issue) I decided to try and put the packing mode back to fastest, and the issue disappears! It seems that this may be the way to solving the issue but I was wondering what the actual quality difference might be between these two options, and also why that then causes such an issue like this?
    Many thanks for your speedy reply, your product and support for it are absolutely top notch!
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    In quality mode, the normals and smoothness/ao are packed into separate textures, which helps with texture compression quality. Basically, the RGB channels of a texture are compressed together and treated like color gradients, so if you only pack data into the G/A channels, they get compressed separately and the quality of the compression is better, with the downside being more texture data to load/sample. In practice I find the difference minor, but it really depends on the textures you are using- if they are more gradient and less noisy it can make a bigger difference. For instance, if I was doing a car model, I wouldn't pack normals and Smoothness/AO together because the normals are very subtle and it would crunch them too much- but for rocks and such it's usually fine.
     
  6. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    127
    No, I'm pretty sure I have nothing that would be changing the splatting. Here is what it looks like in the editor. (I have updated the terrain data etc. It is blending fine:

    upload_2019-7-8_16-26-27.png

    Once I run I get this:
    upload_2019-7-8_16-29-58.png

    I have noticed that the blending is running, but not properly. I can change the Blend Distance to something really high and the blend will appear but it is not possible to modify it (hardly).

    I tried updating the Terrain Descriptor Data when running and this is what I then get:

    upload_2019-7-8_16-34-10.png

    It is like a really contrasty version of the blending.
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Oh, you're talking about the terrain object blending, not the terrain itself. Hmm. Well, you could put a breakpoint in the TerrainBlendableObject script and see if it's not finding the required data correctly. It throws out warnings in most cases, so check the console as well.
     
  8. Harjawalda

    Harjawalda

    Joined:
    Sep 1, 2018
    Posts:
    10
    Hi Jason,
    the Advanced Details Asset created by WMPunk has not been updated for quite some time, and I was unable to reach the author, the latest compatible microsplat version is 2.5. I thought maybe I can fix it myself if its just a small reference issue, in the script, I get the following error code, any idea? And sorry for bothering you.

    NullReferenceException: Object reference not set to an instance of an object
    DupeEditor.MicroSplatModule.AdvancedDetail.OnPostGeneration (System.Text.StringBuilder sb, System.String[] features, System.String name, System.String baseName, System.Boolean blendable) (at Assets/MicroSplat/AdvancedDetail/Scripts/Editor/AdvancedDetail.cs:223)
    MicroSplatShaderGUI+MicroSplatCompiler.Compile (System.String[] features, System.String name, System.String baseName, System.Boolean blendable) (at Assets/MicroSplat/Core/Scripts/Editor/MicroSplatShaderGUI_Compiler.cs:467)
    MicroSplatShaderGUI+MicroSplatCompiler.Compile (UnityEngine.Material m, System.String shaderName) (at Assets/MicroSplat/Core/Scripts/Editor/MicroSplatShaderGUI_Compiler.cs:499)
    MicroSplatShaderGUI.TriggerCompile () (at Assets/MicroSplat/Core/Scripts/Editor/MicroSplatShaderGUI.cs:314)
    UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:209)
     
    gecko likes this.
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    None, I haven't really looked at that code except for the initial code review I gave when he first created the module.
     
  10. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, Jason, I'm using source control and it seems like the following files are changed very often.I'm not doing anything related to Micosplat, but saving Scene will cause the file change.
    upload_2019-7-12_13-50-12.png
    When you look inside what's changed, the only change is really "hash" values and nothing else.
    upload_2019-7-12_13-51-15.png

    Related to this is that Microsplat also checkout the following files even if there are no changes made.
    It's really annoying that I have to revert them every time I check in.
    upload_2019-7-12_13-53-13.png


    The expected behavior is to checkout only when changes are made.
    Thanks for taking a look.
     
  11. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    Hi @jbooth , having a small request which will improve the workflow ( well at least mine :) )

    Could you consider draw the inspector of "MicroSplatConfig" file in MicroSplatTerrain" inspector below the other stuff ( may be enable it by a toggle ). Going to search for the asset in the the project is a little tedious. I know clicking on the material will lead me to the asset but still, improving the workflow is better !

    So let me know if you are interested in this ! Thank You !

    upload_2019-7-12_10-8-15.png
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    So can you figure out why the hash value is changing? And does it stay consistent if you check those in? Basically, the hash value should be based on the resulting texture compression format and only change if something which could affect it changes (such as platform, unity version, etc)
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    I'd rather not for a few reasons:

    - The config is not directly related to the terrain, so it would have to be looked up by name or some other mechanism, which could fail if the user renames things
    - The terrain should not have a pointer to the config, as this would pull in all of it's data at runtime, which is not necessary. Only the resulting arrays are actually needed at runtime, and the config has references to all the original textures.
    - As more things are shown in the terrain inspector, it will get slower to draw.

    I do get the utility of the idea though. If you are editing both a lot, consider adding a second inspector window and locking it to the config (or terrain).
     
  14. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    I am actually working on different terrains, switching between them constantly as trying to improve quality by playing with different textures and need to constantly go and search for these assets for different terrains on different levels or in the same level.

    But anyway, i understand the difficulties, so i will just deal with it !
    Thanks for the input !
     
  15. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    Hi, sorry i forgot to ask about one more thing.
    Is it possible to keep existing textures ( height, smoothness, ao ) if we "Grab From Scene Terrain" in case the albedo is already loaded in the asset? Now it removes height, smooth and ao and should add them again by hand !
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    That could be done- but could cause a lot of issues, because those textures aren't on the terrain. So for instance, if you do a grab and the number of textures has changed, then suddenly you have wrong AO/Height/Smoothness textures in the slots. What I could do is support grabbing form the new mask maps unity has in newer versions, such that if your textures are packed into that format and assigned, it assigns them to the config as well with the proper channels extracted.
     
  17. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    864
    Hello,

    just wondering if there is any ETA for the next update. The thing I think (as I am not sure if it will help) I need the most are the baking and the terrain instancing (which may be solved by the first one) working in LWRP
     
  18. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    31
    MicroSplat terrain hole tutorial please, i can't seem to understand how it works...
     
  19. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, you are right. My collegue and I were using different version of Unity and causing the conflict. Thanks for the tip.
    Cheers!
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    It’s described in the included documentation.
     
  21. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    127
    I have identified the issue with terrain blending. The issue happens when the terrain is moved for floating point reasons. As well as horizontal movement we also position it vertically. Any thoughts about why it might happen and a workaround? Thank you.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Call sync, or manually assign terrains to the object by adding a reference to them directly.
     
  23. martman100

    martman100

    Joined:
    Sep 4, 2013
    Posts:
    13
    So I was recently trying out Microsplat and have determined it isn't the tool I need right now. I deleted it from my project but this has resulted in the Unity terrain tools not functioning from a painting standpoint. Now when I click on the paint option there is no way to manage the terrain layers/textures. Any idea on the best way to remove? I am using unity 2018.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Remove the component from the terrain and remove the MicroSplat folder. You can also remove the defines, but they shouldn't have any effect..
     
  25. sunseeker1988

    sunseeker1988

    Joined:
    Jul 10, 2014
    Posts:
    386
    Hey, Is there a way to apply a roughness map?
     
  26. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    Add the Roughness map to the Smoothness slot and press the toggle below the slot to invert values !
     
    sunseeker1988 likes this.
  27. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    127
    Could you explain a bit about what the problem is and what the script is doing? Enabling the script calls Sync and I have also called Sync directly after moving the world with FloatingOrigin. Neither seem to do anything - at least consistently.
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Well, the MicroSplatBlendableObject script basically raycasts down to find the terrain under it. Once it finds the terrain, it grabs various data from it to do the blending (terrains position and size, the shader associated with the terrain which does the blending, etc). The sync function itself syncs the terrain data between the template material and the actual material used for the terrain, and effectively triggers the blendable object script to do its work. You can most likely step through the script and see why it's failing.
     
  29. sunseeker1988

    sunseeker1988

    Joined:
    Jul 10, 2014
    Posts:
    386
    Microsplat such a great tool. MicroSplat_Unity_Terrain2.png MicroSplat_Unity_Terrain3.png MicroSplat_Unity_Terrain1.png
    MicroSplat_Unity_Terrain3.png
    MicroSplat_Unity_Terrain1.png

    MicroSplat_Unity_Terrain2.png
     
    Last edited: Jul 18, 2019
  30. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    HI @jbooth ,

    i am using microsplat in current 20192 b9. It's all good except one main warning that appears constantly.
    Is support for 2019.2 coming when it if officially out or you may consider take a look soon, as 9.2 is around the corner !
    Thanks !

    Here is the warning:

    upload_2019-7-18_7-14-14.png
     
    sebas77 likes this.
  31. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    201
    Hey, successfully moved to LWRP for Microsplat. Smooth! Using Crest LWRP ocean, it's pretty killer as well.
     
  32. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    201
  33. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    864
    The terrain is rendered first, is there a way to change the render queue in such a way it's rendered last?
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Terrain is rendered geometry+100 currently.
     
  35. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    864
    as agreed in chat, I hacked the shader to be at alphatest and that did the trick, but maybe it would be useful to expose the parameter (btw it actually saves quite a bunch of GPU clocks on our intel hd 4000)
     
    Last edited: Jul 24, 2019
  36. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Hi Jason

    I'm having a problem with terrain blending with occlusion mapping. Basically:
    1. create an empty project in 2018.4.4f1 or 2018.4.1f1 (Windows)
    2. import microsplat and the terrain blending module
    3. open the example scene for terrain blending
    4. select the two spheres and enable static occlusion.
    5. Try to bake occlusion. Fails with "Failed getting triangles. Submesh index is out of bounds"

      If I remove the terrain blending material & disable the terrain blending script on the spheres, baking work...

    Halp?

    Thanks
    Larz
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Sounds like a Unity bug- it's not like any code is running from MicroSplat when baking happens.. I suspect they aren't handling multiple materials correctly, assuming that two materials means two submeshes, but that isn't how the rendering code works..
     
  38. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Makes sense -- I assume it's also related to the warnings we get with the two materials / one submesh as well.
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Yes; it’s a useful behavior to be able to stack shaders like that but it’s not surprising that assumption don’t line up everywhere in the code.
     
  40. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    127
    Every time I run my project the terrain collider materiel creates new instances .ie. Rock (instance)(instance)(instance) These gradually build up and I'm not sure if they have a performance hit or not. Is it possible that my Microsplat configuration could be causing this? I am on Unity 5.6.
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    MicroSplat has no interactions with physics materials.
     
  42. Japi

    Japi

    Joined:
    Jan 13, 2010
    Posts:
    8
    Does the new Low Poly Look module support already LWRP (with the MicroSplat LWRP module)?

    And does the Low Poly Look and LWRP modules maybe support the Unity 2019.2 beta by any chance?
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    It works in LWRP, but I don’t test in betas..
     
  44. Japi

    Japi

    Joined:
    Jan 13, 2010
    Posts:
    8
    Thanks, good to hear that there's already LWRP support.

    Or has anybody else maybe tried MicroSplat in the Unity 2019.2 beta (LWRP)?
    [Update] It seems that the 2019.2 just got out from beta today, so I assume 2019.2 support is coming soon
     
    Last edited: Jul 30, 2019
  45. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    32
    Hi Jason, I have twice now run across an issue with terrain blending, and I think I understand the source of the problem well enough to prevent future issues - maybe others here will benefit:

    I use microSplat with Map Magic. In order to integrate them, I followed Denis's guide, which shows a workflow that is not a conversion from an existing terrain - that is, he manually creates the Texture Array, adds a microsplat shader, and creates a new material for it.

    In this case, he names his material differently from the shader, which leads to issues when the terrain blending code tries to make a blending material on compilation. See relevant code -

    MicroSplatShaderGUI_Compiler.cs: 568
    MicroSplatTerrainEditor_TerrainDesc.cs: 211

    the compiler will create a 'MicroSplat_TerrainObjectBlend.shader' but the TerrainEditor will look ( in my case ) first for a 'PrimaryMaterial_TerrainObjectBlend.mat', and failing that, will look for a 'PrimaryMaterial_TerrainObjectBlend.shader' to use to create the material. It will fail, and there will be no material associated.

    Proposed solution:

    MicroSplatTerrainEditor_TerrainDesc.cs

    216 //string shaderPath = path.Replace(".mat", ".shader");
    217 string shaderPath = AssetDatabase.GetAssetPath(bt.templateMaterial.shader);
    218 shaderPath = shaderPath.Replace(".shader", "_TerrainObjectBlend.shader");

    maybe I am missing some implications here - it seems to work for me.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    Yeah, I like that.. Going to have it check for both just in case..
     
  47. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    Hi Jason, undoing changes in material sliders seems to not update the effect, only values !
    Could you please check this and fix if possible. Thanks !
     
  48. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    874
    Got a couple more requests !

    1. Prevent microsplat from creating new layers for each added texture in case the terrain has already added a layer with same textures ( if terrain has a layer based on an albedo and normal map, a new layer is still being created )

    2. Being able to load textures based on an existing layer - may be drag and drop a layer into a MicroSplatConfig slot and use that layer as well to add it to the terrain. Got so many copies of the same layers now because we are relaying on many terrains for different levels. Could this get optimized ?

    Thank you !
     
  49. Mysado

    Mysado

    Joined:
    Feb 22, 2016
    Posts:
    3
    Hello


    I wany to buy and use only the triplanar shader. I'm working in lwrp, i have to but microsplat lwrp version and then triplanar shader or just one of these?

    Thanks for help.
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,573
    You'd need both.