Search Unity

[FREE]MicroSplat, a modular terrain shading system for Unity Terrains

Discussion in 'Assets and Asset Store' started by jbooth, Aug 9, 2017.

Thread Status:
Not open for further replies.
  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Definitely possible.
     
    roxIndie, gecko and StevenPicard like this.
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    That'd be fantastic. I know it sounds simple on the surface but gets pretty tricky once you dig into it (how long do trails persist? How do you handle trail intersections?) but I'd sure love to have a module for this in a couple months :)
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The real issue isn't that stuff, but rather physics.
     
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Ah, well, what do I know.

    Anyways, could you note here if/when you decide to make such a module, so I don't have to worry about finding another solution? (Again, don't need it for a few months.)
     
  5. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Would be really helpful to allow channel selection for some textures.

    AO, Gloss, etc - single channel maps. Would also be nice to have specular mode option.

    Unfortunately I'm using textures from a wide variety of sources with various inconsistencies in terms of quality and format. Ideally, I'd move to pure substances or consistent source like quixel, but in the meantime - you gotta make due.

    Would be nice to have some controls to make this easier.
     
    StevenPicard likes this.
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not sure what you mean- AO textures are generated from the height or normal data if they are not provided, and you can select which channel the data is in on a per-texture or per-channel basis. Same for smoothness, height, etc..
     
  7. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Oh wow! I didn't realize that if you set it to custom it allowed per texture channel selection!

    My bad, that's awesome!
     
  8. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    The MS material for my terrain somehow got corrupted--all shiny and flat, like the default standard shader. Finally I just reconverted the terrain to create a new material and associated files. But I have 64 terrain tiles, and it seems I can't assign the new shader to all the tiles by selecting all of them and dragging it to the Template Material slot. I have to select each one, one by one, and drag the material. Am I missing an obvious way to assign it to all the terrain tiles at once?
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You could copy the new material over the old one, leaving the meta file untouched, and then they'd all point to the new one..
     
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I was gonna do that...but then Unity crashed and lost the material assignments entirely. So I guess the answer is no?
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I don't think that component is written for multi-edit.. Could look into it though..
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Submitted tonight:

    MicroSplat 1.4
    • Fixed bug in per texture UV scales when triplanes blending is on
    • Fixed bug in per texture contrast allowing other textures through
    • Fixed bug in height blending when weight of all textures approaches 0
    • Switch Triplanar to use square matrixes, which are required on some GPUs
    • MicroSplatTerrain component now references AddPass shader to make sure it gets included in the build
    • PropData now uses RGBAHalf when running on the Nintendo Switch (RGBAFloat is not supported)
    • Several per-texture properties were trying to use the same values and would conflict when enabled. Fixed.
    • Fixed issue where prop data is not assigned correctly when converting multiple terrains at once..

    As usual, wait until all your modules are approved before updating.
     
    roxIndie, sylon and punk like this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
  14. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
  15. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    Some of these approaches are not new but to hear the reasoning on why and how to use them for mobile is really useful.
     
  16. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Nice to have:
    - "back to default / recommended" button for each settings group.

    Currently I tend to refer to the screenshots in docs for recommended settings. Not sure if this is best way or not. Probably better to refer to default values in source ?

    (this is extra important because 'ctr z' undo is semi unreliable on material settings)
     
    Last edited: Oct 11, 2017
    AlwaysBaroque likes this.
  17. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    @jbooth, do you have video of your unite talk?

    Extremely impressive. Like, wow.

    That talk is on a whole different level.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unity will likely post it soon- usually takes a few weeks for them all to get posted..
     
  19. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Several lifetimes ago, yes- was the first game I ever made, as it was for everyone else who worked in the basement that became Turbine..
     
  21. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Awesome. I read the story of how the game came to be and it was truly inspiring. Great work, Jason.
     
  22. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Hi Jason.

    After 1.3 or 1.4 (not sure which), my baked shadows are purple.
    I tried baking with the Unity default shader, and then they were black again.

    While i'm here i also have a question.
    When i am painting textures on my terrain, whenever i get to a point where 3 textures meet, blending goes off. Instead of height blending i am seeing hard lines. Is this normal? Or perhaps because of Unity's paint tools?
    Now i figured this was inherent to splat mapping, but a doubt keeps lingering so i thought i'd check with you.

    Grtz
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Can you show me a shot of the purple and your settings? There's not really any lighting code in MicroSplat other than #pragma's which tell it which models to use.

    The number of blends can be controlled with the Blend Quality setting- if you have it on Fastest, then you only get 2 layers, where as you get 4 if set to Best. This is a way to trade quality vs speed, as restricting the blend count can greatly reduce the amount of samples that need to be taken (ie: in triplanar, it's blend * 6, so 12, 18, or 24 samples per pixel).
     
  24. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Baked with MicroSplat:
    link
    standard shader:
    link
    Thanks for the blend quality tip. I will try the other settings to see what it'll cost me.

    (edit) first time trying to include images. Using imgur, but that doesn't work, so links will have to do for now.
     
    Last edited: Oct 13, 2017
  25. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    About screenshot of settings... which settings do you need?
    (I tried to bake with all lighting models)
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    just the material settings at the top..

    Really strange, I have no idea what would cause things to go purple. Do you have a strong purple anything in your scene?
     
  27. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, the only thing that can think of is perhaps one of the shader stages isn’t compiling correctly, and when it goes to compute the light map, it’s getting a pink shader. I would expect it to spew some kind of compile error though. Any chance you can send the scene over for me to have a look?
     
  29. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    I'll send you anything you need.
    But can you help me how to do that?
    Just zip up the project folder?
    Folder is 3.5 GB.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Don’t include the library folder as that doubles the size usually. You can usually break out just the assets in question, but if that’s a pain the whole thing is fine as well. I usually zip them and send a Dropbox mail in a PM. Also, what version of Unity are you using?
     
  31. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    ok. will do.
    Hope i can get it done in time.. i have to go to a wedding tonight.

    Using 2017.1.1f1
     
  32. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Here's a more recent in game shot using Micro Splat for the terrain, Alloy for everything else (they mix very well) you weren't kidding about the speed, I don't notice any impact at all on BOV, just using snow (of course) and the anti tiling pack

    mountain.png
     

    Attached Files:

    jbooth likes this.
  33. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Not sure what the cause of this is - but on occasion:

    TextureArrayPreProcessor : AssetPostprocessor

    This seems to break a handful of my prefab assets. Not sure what the cause is.
    Unity_2017-10-16_20-19-22.png
    Immediately after this, 4 of my prefabs in resources will have their values nulled out.

    Right now those prefabs are doing some work in OnValidate, which admittedly, they probably shouldn't, but that code has been in project (working fine) for well over 6 months with absolutely zero change.

    I believe this only occurs when changes are made to code while running and exiting playmode. Kind of annoying - I have to roll back these 4 prefabs over and over.

    Usually after this problem, all Microsplat materials will be empty and I need to click update on the config in order to update the materials.

    This may be really specific to my project (which is a little extreme at this point), but if it happens to someone else then you may want to dig into it. For my usage, I can just rollback these 4 guys.
     
  34. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    Heya @jbooth ! I spent some time at work watching videos for all of your modules (I love that you go through what all of the options do) today and had a quick question about the snow module - is there any way to apply a different color to the snow? I imagine you could use it for things like dust accumulation in a desert scene.
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, this is only supposed to trigger when the platform is changing. Basically, if you switch to iOS, then the array needs to be recompressed into PVR format instead of DXT, so this enforces that this happens without user intervention. However, if you delete the TextureArrayPreprocessor, it won't cause any issue except you'll have to press Update on your arrays when you switch platforms. Now, why this would effect a prefab, I have no idea.. If you get explicit repro steps though, that would be interesting..

    Snow takes two textures- one with Diffuse + height map, another with Normal (RG), Smoothness (B) and AO (A). You can make them whatever you want, so if you want to drape moss over the scene with snow, fine..

    Also, for the desert scene, terrain blending with the slope feature is a great way to layer sand on top of normally textured objects. (It allows you to apply the terrain texturing to the top of the object as well as the intersection area).
     
    mons00n likes this.
  36. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
    I used microsplat for the terrain, soil texture seen here. Used microsplat's levers to make it look like soil.

    screen_1920x1080_2017-10-13_23-38-11.png
     
    punk and trilobyteme like this.
  37. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    That grass is stunning. Is that Quixel?
     
  38. coverpage

    coverpage

    Joined:
    Mar 3, 2016
    Posts:
    385
  39. ShefShifer

    ShefShifer

    Joined:
    Aug 16, 2017
    Posts:
    16
    In Unity 2017.2.0f3 there are 2 errors
    I created an empty project and imported MicroSplat (without demo scene).

    1. Assertion failed: Assertion failed on expression: 'scriptParameterClass != NULL'

    2. Script error: OnTerrainChanged
    This message parameter has to be of type: int
     
    Last edited: Oct 18, 2017
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Does running the script updater not fix this? I'll have to see what they've changed about that API and fix it for the next patch.
     
  41. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    That is a known regression bug in Unity. It looks like it will be fixed in a patch.
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Joy!
     
  43. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I just purchased the Triplanar module. In the Triplanar demo scene, it sure seems to be working nicely...but there's no Triplaner option in the material. I've restarted Unity, reimported the module...is it there but I've gone completely blind? (I also updated all the other modules before importing this one.)

    triplanar.jpg
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Also, I'm still having trouble using the Normal Noise only on certain textures. If I set Normal Noise #3 to .5, and then in per-texture, set it to zero for most textures, but 1 for a couple of them, it's still applied across the entire terrain, at .5 or greater strength -- it seems to treat the .5 as a minimum strength regardless of per-texture settings, and then uses per-texture only to increase it beyond that minimum level.

    So then I thought: Oh maybe I should set it to zero in the Normal Noise #3 parameter, but that zeros it out across the terrain, no matter what the per-texture settings are.

    I've updated all my modules today. Am I missing something?
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's really odd- The defines are clearly in your project, because the ad for triplanar isn't showing up. If you put a breakpoint in line 59 of MicroSplatShaderGUI.cs, does the triplanar module not show up in the list of extensions it iteratees through?

    There's a collision in the pixel values read in the current version- I'll be submitting an update soon that fixes it, but will test the settings on that to make sure it's all fixed before it goes out.
     
  46. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Uh, sorry, I only use Unitron and I guess I can't add a breakpoint there? (I opened Monodevelop for the first time ever and was pretty baffled.) I'm not a coder, obviously. Anything else I can try?
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Try installing into a fresh project and see if it comes up there.
     
  48. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Works fine in a fresh project, even after I import all the other modules. But back in my project, Triplaner is still not showing in any Microsplat shader -- not mine, not any of the demo scene shaders, nowhere. No errors or warnings.
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You could try re-importing the MicroSplat directory, or worse, killing the library folder and letting Unity re-cache everything. I've had unity refuse to compile a class into the assembly before where forcing it to rebuild everything was the only fix. Annoying, and will take a while, but hopefully will work.
     
  50. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello jbooth,

    I'm having a problem with this shader. The terrains with Micro Splat Terrain component assigned and with material set up, display as pink. The preview of the material is also pink. At one point, I received these errors:

    Code (csharp):
    1.  
    2. Texture2DArray is not supported on this platform/GPU
    3.  
    4. UnityException: Failed to create 2D array texture because of invalid parameters.
    5.  
    I don't know when exactly those errors appeared, though, and it doesn't seem to appear anymore (but the terrain and material are still pink).

    My platform is Windows 10 (Windows is also selected in build settings). My GPU is NVidia Geforce GMX 1060, so pretty much top of the line.

    Thanks in advance for any help you can provide.

    Edit: Another issue:

    Multi-editing doesn't seem to work with MicroSplatTerrain. The script MicroSplatTerrainEditor seems to have the CanEditMultipleObjects attribute, but if you select multiple objects and assign the Template Material, it only gets assigned to one of them.

    I believe I had this problem with my own code as well at some point. I forget the details, but I think the OnInspectorGUI was still applied only for the "real" selected object or something. And it was my job then to apply the changes to the rest of the objects manually...
     
    Last edited: Oct 20, 2017
Thread Status:
Not open for further replies.