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

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    787
    Hey that looks pretty nice, but I was wondering if you could add another copy of this and rename it to "clouds" (so we can project realistic cloud shadows onto the terrain)
    Would that be possible? I mean if it is possible to have a black overlay (or generally darker, to simulate the shadows) as well instead of colored?
     
  2. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    42
    Hi, I can confirm I have version 1.6 and the issue seem to be still there...
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Please tell me this is an older version of MicroSplat? If this is 1.5 or newer, then it means this issue is now specific to the GPU in use. If you are interested in the tech details, it's posted a bit back in this thread, but basically I thought I had fixed this in 1.5, but if it's still happening on some GPUs, the most likely option if for me to reintroduce the option to force mip maps to be selected manually (well, by my code, instead of the driver). This is actually faster, but breaks anisotropic/trilinear from working, and generally produces a slightly blurrier result on edge angles.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    What GPU are you running on? I can put the option back in which fixes this, but I was really hoping to not have to do that..
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Do the various cloud solutions on the asset store not project the cloud shadows onto the terrain? I have not used enough of them to know, but it wouldn't be hard to add such a feature- the main issue is in getting them to somewhat match the shape/density of those in the sky...
     
    mwituni likes this.
  6. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    42
    hi, my gpu is radeon hd 6900 series/2gb. Is there a way you can add a flag to turn this option on/off (force mip-maps) instead of changing the core? if its a big issue, then people can always work on the texture itself to be scaled accordingly in an external editor instead of using the uv scale option...
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    I have to add it to all the code, but since I've done it before, it's not that big of a deal to do again. It will be optional, and when people turn on per-Texture UVs I'll either force that option on or put a warning that suggests they turn it on themselves. I removed these options because I thought I had managed to fix the issue completely, but unfortunately not. Since this will require a sync-locked update, it'll be in the 1.7 version - I have some small fixes to wind and glitter coming out in the mean time..
     
  8. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    42
    no worries. thanks for replying so quickly!!!
     
  9. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    1)
    That's a great idea, especially if can be kept cheap.
    Most cloud systems don't project cloud shadows ... some simulate it, but at a cost.

    2)
    I get a similar issue, probably a bit worst as mine affects painting with textures ...

    ie. when i paint, the texture doesn't always blend in like it should, it (sometimes) fills to the line ... see below ...

    upload_2017-11-29_16-46-4.png

    I'm on Unity 2017.1.0f3
    NVIDIA GeForce GTX 1060 3GB

    I use your TP module too.
     
  10. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    I'm not sure on my MS version, I think its 1.5.
    Where can we see the MS installed version?

    Can you maybe add version info on the editor headers for MS modules etc, or in readme files.
    I guess mine is 1.5 as the AS shows an "Update" option to 1.6. And I updated quite recently ... maybe 2 weeks back.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    I can likely do a pretty good morphing clouds thing in 2 samples, with a density and opacity control that allows you to make it cloudier or clear..

    Feels small enough to go into an existing module, but which one? Maybe core? hmm..


    Do you have your blend quality on Best or something lower? The second kind of artifact you mention can occur if the blend quality is too low and too many textures are used in one area, but I have not seen it happen when set to best. Come to think of it, I think I can write a tool that scans the data prevents this from happening when you are on Fastest, which would be great for VR and such where using a lower blend quality can really help with performance..
     
  12. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,823
    I see a lot of the screenshots use Map Magic - How do you go about setting up Microsplat with Map Magic? The documentation says to convert your existing terrain, but I don't have one. And to put a Microsplat component on the terrains - but they're created at run time. I'm missing something obvious, I realize.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    My screenshots were all done with MapMagic generating static, not infinite terrain. I know Dennis has a generic output for working with standard unity terrains with MapMagic, and I suspect that would just work, but I haven't tried this myself. If it doesn't, I can talk to Dennis about getting it working, because it really shouldn't take much time to do. (For the most part, MicroSplat is just like a regular Unity terrain with a custom shader- unlike MegaSplat which is an entirely different type of system).
     
  14. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Core would be perfect ... it'll add a lot of extra value to the free core. It's already a no-brainer ... but extras like that would make it more difficult to resist for those already using other solutions.

    Brilliant, thanks - that was it ... although I'm not sure we should get that at "Balanced" (which I used) ... maybe it needs tuning.

    Thats an awesome idea.
     
  15. treshold

    treshold

    Joined:
    Nov 9, 2013
    Posts:
    217
    I think this general question regarding manipulating materials runtime via script and I'm ashamed to ask this :D but
    Code (CSharp):
    1. public Material MsT; // Here i dragndrop micro splat material but problem might be here, I'm not setting the instance of material?
    2.  
    3. MsT.SetFloat("_GlobalPorosity", myValue);
    4. MsT.SetVector("_RainIntensityScale", new Vector4(MyRippleIntensity, MyDropSize,0,0));
    5.  
    6.  
    Values doesn't affect the material until I change something from Inspector on runtime. What I am missing. Should the material show changes runtime or do I need to refresh it somehow?

    EDIT. in short I think How do I reference instance of MicroSplat-material?
     
    Last edited: Nov 30, 2017
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    A few things:

    1. You can get the actual instanced material from the terrain itself- that will be the instance, but will only affect that one terrain. If you want to change a value on all terrains that use a given template material (the one assigned in the MicroSplatTerrain component), you can change that material and call MicroSplatTerrain.SyncAll() to sync that to all instanced materials across all of your terrains.
    2. In your case, I think what you want to do is use the new global properties system when possible. In 1.6, there is a G toggle next to many properties. Pressing it will make the property global, and you can do something like:

    Shader.SetGlobalFloat("_Global_RainIntensity, rainIntensity);

    The main advantage this has is that it effects all MicroSplat shaders- so ObjectBlend shaders, which can now have snow on them, will also be effected. If there are particular properties that people would like me to make a global option for, let me know and I will add them. A table of global properties and their names is in the core documentation. Note that I also recently released by PlayableShaderGlobals system on my GitHub which allows you to animate shader global properties in Timeline.
     
    treshold likes this.
  17. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,823
    Unfortunately it doesn't just work. Each new terrain gets the default Microsplat textures - I assume there is some setup with the texture array that isn't being done somehow. If you can talk Dennis into integration, that would be fantastic.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Yeah, I'll get this underway..
     
  19. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    474
    First off Microsplat is amazing. It was working great *earlier*, but now, when I change the Per Texture Properties, they're all being ignored. What could cause this?

    Also, there's an error "Assertion failed: Assertion failed on expression: 'scriptParameterClass != NULL'" but I don't know if it's related. There's a lot going on in this project.

    Thank you!
    -Chilton Webb
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Check on the MicroSplatTerrain object and make sure it has the correct object hooked up for the PropData field. This holds the per-texture property values, and constructs a small texture to hold them for the material.


    This is a Unity regression in the latest versions of Unity from what I understand. Seems to have no effect and is happening to tons of assets.
     
  21. chilton

    chilton

    Joined:
    May 6, 2008
    Posts:
    474
    You nailed it. That's what it was, exactly.

    -Chilton
     
  22. treshold

    treshold

    Joined:
    Nov 9, 2013
    Posts:
    217
    Thanks, got it working now :)
    Only thing is to fine tune speed of how values change, could spends countless of hours lol

     
    ice2011, beatelove, osss and 4 others like this.
  23. Hexaedre

    Hexaedre

    Joined:
    Jan 23, 2015
    Posts:
    109
    Hi,

    Is it possible for you to make a height blend for the terrain blending on meshes ? That could be very nice, even if the mesh's material must have a heightmap.

    A triplanar option for the terrain blend may look very good, have you considered it ?

    Is there an impact on performance when using per Tex settings instead of global parameters ?

    Have you considered clustered streams ? The Lava could look much better, but will probably cost more performance.
    Same for the clustered snow (if not allready possible) ?

    Well, that's a lot of questions. So thank you very much for your time and your amazing assets.
     
    Last edited: Dec 1, 2017
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    You mean height blend the terrain texture onto the mesh? This is not possible without doing a special shader for the mesh. The current workflow will work with existing shaders and doesn't lock you into to using specific shaders for your mesh, but because of that it doesn't know anything about the mesh's shading.

    The terrain blend is triplanar if triplanar is enabled on the terrain.

    Yes, but in most cases it's very tiny. That's why there's a toggle to turn them on/off instead of always having them active.

    I can improve the tiling on the lava without going to clustering, it's been on my list for a while, and will only make the lava slightly more expensive..
     
  25. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    In what cases is it not tiny?
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Per Texture UV coordinates have side effects that can effect performance. The actual lookup of the scale value is tiny, but the ramifications of scaling each texture in wildly different ways has consequences outside of the per-texture lookup. In the current version this is only the cost of drawing a larger (more expensive) or smaller (less expensive) version of the texture that you would normally. But once I add MipMap selection modes back in to get around the black line issue you will essentially have 3 choices- the current way, which lets the GPU select the mip map, but gets the tiny black lines on some GPUs, having my code select the mip map, which seems to be actually faster than letting the GPU select it, but disables anisotropic and trilinear, and using the gradient samples, which is very expensive but should make sure every pixel is absolutely perfect.

    Most of the other Per-texture properties have very small amounts of ALU associated with them- they sample the value and do a few math operations at best.

    Note that during development I actually implemented several different methods for storing per-texture values; from the standard way Unity wants you to store material parameters, to using uniform arrays, and the current technique, and looked at each under GPU profilers. There were some really surprising results. For instance, using the unity method I originally did something like this:

    Code (CSharp):
    1. float[] perTexValue = float[] { _PerTexValue0.x, _PerTexValue0.y, .....}
    2.  
    3. float value = perTexValue[index];
    I would have thought this would have been very fast, as you pack the values into a table and sample from them via an index. Strangely, this pattern turned out to be thousands of times faster:

    Code (CSharp):
    1. float value = _PerTexValue0.x;
    2. if (index == 1)
    3.    value = _PerTexValue0.y;
    4. else if (index == 2)
    5.    value = _PerTexValue0.z;
    6. ...
    7. else if (index == 15)
    8.    value = _perTexValue3.w;

    Which seems insane, since it does 15 branches. My only thought is that the first technique blows out the register count.

    Turns out the current technique I'm using was the fastest of all I tried, and unlike pretty much every other shader on the store, mine compile out when not in use, so you don't pay the cost for looking up the value or doing any math unless you are actually using that feature.
     
    gecko likes this.
  27. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    Hello Mr. Booth,

    I really like the new global variables. That's a really great update. :)

    However I seem to have some problems trying to set global puddles via script. Here is what I already tried:

    Code (CSharp):
    1. Shader.SetGlobalVector("_Global_PuddleParams", new Vector2(0, puddleAmount));
    Edit: I also tried a Vector4 here...
    Code (CSharp):
    1. Shader.SetGlobalFloat("_Global_PuddleParams", puddleAmount);
    None of these work for me. However using the "SetGlobalVector" method for "_Global_WetnessParams" works just fine. Could you give me any advice on that?

    Thanks in advance.

    Regards,
    Wurlox
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    On the GPU, all Vectors are Vector4, so either of those should work. I'll see if I can replicate it tonight, maybe there's some conditional compile mismatch or something and the value is not being set to the global value.
     
  29. treshold

    treshold

    Joined:
    Nov 9, 2013
    Posts:
    217
    I'm using two values in "_Global_PuddleParams" same way as when the puddles doesn't use global value.
    isn't it still puddleblend value and puddlemax value?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Well, it's a choice now- you can enable them to be global or not.
     
  31. treshold

    treshold

    Joined:
    Nov 9, 2013
    Posts:
    217
    What I mean is that there might be some sorta bug in how does Puddles work now and how it should work.

    For example Default porosity can be changed with slider when Wetness Range is set as global BUT

    if I set Puddle Max as global , then Puddle blend slider ain't working and I control both with
    Shader.SetGlobalVector("_Global_PuddleParams", new Vector2(puddleBlend, puddleMax);

    same goes with RainDrops, drop size field doesnt function if the Intensity is set as global.

    What I'm trying to say is that if Puddle Blend value is intended to adjust with slider after Puddle Max -value is set as global - it isnt working that way atm.
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Yup, I'll check it out tonight, likely some minor logic issue.
     
  33. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    I experience the same problems as @treshold and can only manipulate the variables using the microsplat material directly. Therefore the global flag must be turned off.

    I'm not in a hurry but it would be great if we can get a fix for that anytime :)

    Thanks and regards,
    Wurlox
     
  34. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Hi @jbooth , firstly I'm digging the texture cluster feature. However I got into a problem, when I switch on texture cluster, the smoothness seem to go up.

    To be clear I'm using roughness maps and I check the "invert" checkbox in the smoothness map input.

    It works great without texture clustering:
    bugreport_texture cluster off.PNG

    But messes up when I switch it on (I did nothing else this is literally A/B comparison):
    bugreport_texture cluster on.PNG

    These are my settings:
    bugreport_texture cluster settings.PNG

    It looks like the the smoothness map is inverted? Appreciate any help. Thanks.
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    By any chance did you not check invert on the other two textures in the cluster? Can you send me the textures which are doing this so I can have a look?
     
  36. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    I definitely checked inverse.
    import settings.PNG

    Sure I'll send you a link by PM.

    Also, it might be useful to know that I'm using texture clusters for everywhere, not just this texture. And they all turned glossy.
     
  37. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    I am having these build fail errors on 2017.1.0p5. On windows. It does seem to actually produce the build.

    Shader error in 'MicroSplat/Landscape': maximum ps_5_0 sampler register index (16) exceeded at line 986 (on d3d11)

    Compiling Fragment program with SPOT SHADOWS_DEPTH
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME

    Shader error in 'Hidden/MicroSplat/Landscape_Base707672406': maximum ps_4_0 sampler register index (16) exceeded at line 981 (on d3d11)

    Compiling Fragment program with SPOT SHADOWS_DEPTH
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    So, shaders have a max number of texture samplers. This is 16 on older shader models, and 32 in DX11, and in DX11 some samplers can be shared. This error means you are using too many texture samplers. The reason you don't see it cause an issue is likely that the actual lighting your scene uses doesn't use this particular shader variant, but if it did, you would get pink under that lighting condition (Unity uses some samplers for certain lighting effects).

    The fix is to set the shader model to 5.0, or reduce the number of features you are using at once if you need to run on non-DX11 devices.
     
  39. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    OK good to hear. I will check it out. I am only targeting dx11 and only have direct3D11 selected in build settings anyway.
     
  40. Hexaedre

    Hexaedre

    Joined:
    Jan 23, 2015
    Posts:
    109
    Hi,

    I am working with substances but I can't have the smoothness map to be grabbed by Microsplat.
    I tried to set the output in Substance Designer both on roughness and glossiness but none of them worked.

    Is this working for you ? Is there some specific setting to set in the sbsar ?
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    The output has to be named roughness or smoothness and then it should just grab it. Worse case, just output the textures from Substance directly and slot them in where you want them.
     
  42. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    @jbooth I am just trying out the shadow mask for VS and it does not seem to be working. Just ran through it with Lennart and it seems to be setup correctly. Any ideas on what else to check. I have turned off all other things in the shader but have not seen any result yet.
    Update: The above has been taken to skype.
     
    Last edited: Dec 4, 2017
  43. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    @jbooth On another note.... It seems that when I use texture clusters that the landscape is darkened for some reason.
    Nothing is changed between shots except enabling clusters.


    upload_2017-12-5_9-41-22.png

    upload_2017-12-5_9-42-18.png
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Yes, I fixed this last night, actually. If you open up the microsplat_func_clusters.txt file and add:

    Code (CSharp):
    1. cluster.rgb *= cluster.rgb;
    to the top of the ClusterSampleNormal function, then recompile the shader by toggling an option on it, this should be corrected.
     
    Baraff likes this.
  45. YHS

    YHS

    Joined:
    Aug 10, 2014
    Posts:
    31
    Hi jbooth

    I use Triplanar module but found out on the single texture, "Disable Triplanar" seems not work. Did I miss some thing? Thank you.

    Pasted image at 2017_12_05 11_59 AM.png
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Disable triplanar forces the individual textures to just use the top-down projection. I just tested in the example scene and this seems to be working fine, did you expect it to do something else?
     
  47. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Hi,
    Yes ... The label is a little confusing (it should be something like "TP value")... To disable TP you need to drag the slider so value is 0. Value of 1 means fully enabled.

    The tickbox is only to enable TP on per-texture settings ... It is not "disabling TP" just because ticked.
     
    YHS likes this.
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    Yeah, maybe I should work up a custom control here that uses another checkbox? A little confusing since it would be one to enable the feature, and another to disable/enable on this texture..
     
  49. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Not sure this is the correct place to enable/disable per-texture settings. Maybe something more global like a checkboxes at the shader features level to enable them .... Something like a check box with colored background looking like a small texture. Or just a "Per Texture" drop list one can expand to enable/disable the options one wants.
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,624
    It's like that in MegaSplat, but it feels really disconnected from the area where you are working on them, which is why the enable is inlined with each property in MicroSplat. Overall I much prefer it, but having a property which is essentially a toggle next to another toggle just feels odd, which is why it's a slider right now.