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,728
    There's not really docs on it- but if you choose one of the simpler modules it should be pretty easy to follow along. Basically every module derives from an interface which has functions to add properties and source code to the shader. Features get added/removed via shader keywords, and theres a step to pack and unpack these from the material. In most cases, the calling code ("DoSnow()") is put into the core module while the actual function is stored in the fragment files in the module, though the advanced details module (which isn't written by me) uses a search/replace style method to add it's code so he can change the calling code without me having to update core.
     
  2. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    242
    Thank you.
    I will try to figure it out.
     
  3. SOIL

    SOIL

    Joined:
    Sep 2, 2011
    Posts:
    143
    Can you help me with MicroSplat under Unity beta9? I have a job to do under the beta9 for a client :/ don't ask my why :/ and microsplat sends me an error message on the texture array script "invalid texture size". I used the same four textures already with micrsplat without problems. If you need more information, I can make a screesnhot of the error message, when I am back at my pc.

    Appriaciate every help!
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Don't use Beta's, Unity broke Graphics.CopyTexture.
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    I don't suppose this is the fix we've been waiting for? (It's listed under Features, not Fixes, for b10, so I assume not...)
    • Graphics: Added texture 3D CopyTexture support.


     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    No, that’s what broke it in version 4.
     
  7. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    I see, I misread it entirely. So do you know if Unity is working on this...or aware of it? What can we do to get it moved to high priority?
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    It's been bugged, posted on the beta forums by several users, and @Tim-C said he'd poke the dev's about it but no luck so far. It basically breaks all 13 of my assets, along with a bunch of other ones, so hopefully they won't ship 2018.3 with it.
     
    TreeMSI likes this.
  9. SOIL

    SOIL

    Joined:
    Sep 2, 2011
    Posts:
    143
    I see. Thanks for the info!
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    PM me, along with a description of what issues your actually having..
     
  11. FastKillteam1

    FastKillteam1

    Joined:
    Sep 20, 2017
    Posts:
    31
    Oh so please bring support for hdrp, I love microsplat and the results achieved, but I would love it even more if I could use it with hdrp
     
    PROE_ likes this.
  12. Willbkool_FPCS

    Willbkool_FPCS

    Joined:
    Jun 13, 2018
    Posts:
    143
    I'm sure/know he will after 2018.3 has a stable release. No point in doing it many times for beta releases.;)
     
    TreeMSI likes this.
  13. FastKillteam1

    FastKillteam1

    Joined:
    Sep 20, 2017
    Posts:
    31
    I totally agree, just showing my interest in the product :)
     
    PROE_ and Willbkool_FPCS like this.
  14. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Hi, I'm trying to build my game in unity 2018.2
    I've used microsplat in previous versions of unity, like 5.6.
    It worked fine in editor and build.
    But in 2018.2, it shows error in the build, several hidden shaders are not found, this was not in the old builds, any ideas how to avoid these errors? Should I include microsplat shaders in some places?
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Can you post the error?
     
  16. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    I don't know about @Harekelas but this has been a problem in my builds for a very long time and I have not been able to resolve it despite your suggestions. You did say it was not a big deal (just an early out) so I have not really followed it up.

    Shader 'MicroSplat/Landscape': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728

    Oh, this thing. Yeah, never been able to figure out what it wants, but it doesn’t cause any problem and it actually finds the shader at runtime anyway..
     
    Baraff likes this.
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    So I got 2018.3b12 and opened my project...and get this error-- any suggestions?

    Assets\MicroSplat\Editor\TextureArrayConfigEditor.cs(1308,123): error CS0104: 'TextureCompressionQuality' is an ambiguous reference between 'UnityEditor.TextureCompressionQuality' and 'UnityEngine.TextureCompressionQuality'
     
  19. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    I think Unity 2018.3 betas are still broken for CopyTexture anyway. At least it seemed to be still broken in the latest b12 when I did a quick test yesterday, so maybe no point trying it with Microsplat just yet.
     
  20. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    Darn it, they said that was fixed in b12!
     
  21. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    174
    are microsplat shader for terrain will be support for beta 3's terrain instancing?
     
  22. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    242
    It will, or does. If only that CopyTexture bug in Unity would be fixed in time..
     
  23. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Hi,
    I've met this error when building my game in unity 2018, it was not present in unity 5.6:

    Shader error in 'Hidden/MicroSplat/Survisland_High_Ultra_Base2035933029': maximum ps_4_0 sampler register index (16) exceeded at line 1553 (on d3d11)
    Compiling Fragment program with UNITY_PASS_FORWARDADD SPOT SHADOWS_DEPTH SHADOWS_SOFT
    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 UNITY_LIGHTMAP_FULL_HDR

    here are the features I've enabled:
    upload_2018-12-1_9-50-6.png

    Would love to know the sampler cost for each feature. I've tried to tweak some settings: enable/disable parallax or tessellation, enable or disable global snow. But there still will be index exceeded error. Any suggestions?

    PS: this error also does not show up when I choose different features in the material, but if I try to compile and show the shader, this error shows up.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    There's no way to get an exact sampler count other than to go over it. This is because the sampler count is actually dependent on lighting as well as the shader itself- for instance, if the shader needs to sample a light probe it can require an extra texture for the light probe. The closest approximation would be to look at the shader's texture count (you can see this by selecting the shader) and you'll see how many MicroSplat is actually allocating..
     
  25. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Shader 'MicroSplat/Survisland_Mid': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
    Shader 'MicroSplat/Survisland_High': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
    Shader 'MicroSplat/Survisland_High_Ultra': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
    Shader 'MicroSplat/Survisland_Low': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
    Shader 'MicroSplat/Survisland_VeryLow': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
    Shader 'MicroSplat/Terrain 0,0': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found

    These are the errors in the output log in a build game.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Yeah, these don't seem to cause any issue- the shader actually gets found at runtime, so I'm not sure why the build log throws these errors..
     
  27. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Bad news..it looks like they introduced the Graphics.CopyTexture bug into 2018.2.19f1 and it's still there in 2018.3.0f1
     
    Crossway likes this.
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Of course they did..
     
    Larzarus likes this.
  29. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
  30. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,177
    I really hope they fix this - I've seen it mentioned a few places and it would be a real shame to impact amazing assets like MicroSplat, especially with all the hard work you put into developing this.
     
  31. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    57
    Man, been waiting for the fix so we can update our project :/ Worrying that they think it is fixed.
     
  32. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    Thanks for the heads up on this one. That was poor form from Unity. I wonder whether this needs to have a new bug report submitted given that they closed the original one?
     
  33. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    We have a large game world, so we're loading and unloading Unity and mesh LOD terrains in additive scenes. We've decided to put some environmental objects like rocks into the main scene, since they are visible from most areas of the map. (This is a change of plans since I chatted with you on Discord a few days ago.)

    These have the Microsoft blendable object component on them, but that doesn't work when there's no terrain underneath the rocks initially at runtime -- the component shows an error: Can't find terrain underneath. If I toggle that component off and on again, then the rock turns pink, with a second material slot added, but no material assigned to it, and two errors: Terrain shader not setup for blending, and Terrain does not have blending data. We could manually assign a material with the Blend shader, but even when I do that, the blending doesn't work, and the MS Blend component still shows those errors.

    Also, for the rocks that initially have a mesh LOD terrain (with MS mesh shader), they simply lose the second material entirely at runtime, and the MS Blend component shows an error "Terrain not detected."

    So....is there a way to get this to work with additive terrain scenes?

    thanks
    Dave
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Well, you're going to need to figure out a way for it to access the data it needs when the terrain isn't there. The object blending uses a custom height/normal map that gets generated so it can figure out the terrain topology in the shader, as well as the bounds of the terrain. At startup, it finds the terrain the object is on and caches that stuff. You could change it to cache this at editor time or manually enter the data- the reason it does this is so you can move objects and terrains around and everything just works as it should.
     
  35. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    Okay, thanks for the pointers. We'll look into it.

    Also: After pulling the most recent MS updates, I've started getting some errors when I change settings and regenerate the MicroSplat material. We use Assembly Definitions so I have to manually move all Editor scripts into a main MS/Editor folder, and I suspect I did something wrong there, but I've reviewed and recopied them and can't figure it out, and I keep getting the errors. Sorry for the bother, but can you see what it might be from these errors?

    Shader error in 'Hidden/MicroSplat/AmethystTerrain_x6_y1_Base-1289839447': 'ApplyAntiTilePerTex': no matching 5 parameter function at line 2584 (on d3d11)

    Shader error in 'MicroSplat/AmethystTerrain_x6_y1': 'ApplyAntiTilePerTex': no matching 5 parameter function at line 2584 (on d3d11)

    Shader error in 'MicroSplat/AmethystTerrain_x6_y1_BlendWithTerrain': 'ApplyAntiTilePerTex': no matching 5 parameter function at line 2586 (on d3d11)
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    If your pulling from the github it may be a bug I introduced.

    Yup, fixed..
     
  37. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    yes I was, so will pull again, thanks!
     
  38. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    89
    Just confirming this is the same 2018.3 bug. Upgraded from 2018.2 to 2018.3 (release) and updated microsplat to latest on the store and it throws this. I am guessing the release version of 2018.3 is still incompatible with Microsplat until that copy texture bug is fixed. Just looking for confirmation that we would not be able to use MS on 2018.3 at this point.

    Thanks

    NullReferenceException: Object reference not set to an instance of an object
    MicroSplatTerrain.RestorePrototypes () (at Assets/MicroSplat/Core/Scripts/MicroSplatTerrain.cs:245)
    MicroSplatTerrain.Sync () (at Assets/MicroSplat/Core/Scripts/MicroSplatTerrain.cs:208)
    MicroSplatTerrain.OnEnable () (at Assets/MicroSplat/Core/Scripts/MicroSplatTerrain.cs:53)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    MicrosplatTerrain.cs

    line with the null ref.
    if (protos.diffuseTexture != cfg.sourceTextures.diffuse)
     
    Last edited: Dec 13, 2018
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    I have not had the copy texture issue since upgrading to the released version from the beta, so as far as I know they actually fixed that bug. This looks like you don't have your config assigned correctly in the MicroSplatTerrain component- check the debug section, maybe the upgrade borked the reference or something.
     
    mmaclaurin, PROE_ and mons00n like this.
  40. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    203
    Are others running well on 2018.3? Been holding off because of CopyTexture() bug but if that's all clear I'd love to see the perf changes for many terrains on iOS....
     
  41. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    Couple questions about Snow:

    1) Having weird streaking once the UV Scale is above 1. See screenshots (UV of 3 and 50). Is something misconfigured?

    2) On objects with MS blending, as I increase the amount on that material, it creeps in VERY slowly along the blended areas, and then suddenly the entire object has snow on it. I thought it would only affect the top surfaces?


    snow 3.jpg snow 50.jpg
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    Can you attack a screenshot of your material settings (top section) so I can repro?
     
  43. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    sure, here you go
    Screen Shot 2018-12-13 at 6.09.46 PM.png
     
  44. kepesh

    kepesh

    Joined:
    Dec 29, 2017
    Posts:
    85
    I have the same error. How should the debug menu be setup to work?
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    There’s a rollout on the MicroSplatTerrain component labeled debug, click to open it.
     
  46. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    45
    Hi there,
    I've successfully managed to get Microsplat working with 2018.3 and all the paid modules, which is great.
    Now I was just wondering if there's any plan to get it integrated with the new terrain instancing system? If I try to activate the flag (Draw Instanced) I get the whole terrain disappearing and I get the error below:
    "Shader error in 'Hidden/MicroSplat/_Base-640971990': invalid subscript 'instanceID' 'UnitySetupInstanceID': no matching 1 parameter function at line 2201 (on d3d11)"
    I suppose there would be performance benefits by using this flag, am I right?

    Thank you for your time!
     
  47. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    Also, regarding snow on MS Blendable objects: There's no "G" button on that component to sync the snow with Enviro weather....possible to add?
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    You need to regenerate the shader in 2018.3, otherwise MicroSplat won't write out the requited #pragma's because they don't compile in 2018.2 correctly.
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,728
    On which property? Those apply to shader properties, not components. If you make them global it will apply to the terrain blending shader as well.
     
  50. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,033
    I meant on the mesh objects with the Blendable component. I have "G" toggled on and working nicely on the Unity and mesh terrains, but no snow is accumulating on the blendable objects at runtime when Enviro snows....so I was looking for something I might have missed. But maybe it's part of the above issues....