Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[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,446
    A lot of stuff with wetness and puddles got unified a few patches ago, so that wetness, puddles and streams would all blend correctly. so it's quite possible that those changes are causing the difference you're seeing. However, if I recall correctly specular fade does not affect the albedo, only the smoothness values. But I'll take a look at the code..
     
    mmaclaurin likes this.
  2. Kelevra

    Kelevra

    Joined:
    Dec 27, 2012
    Posts:
    87
    Hello, @jbooth ! Thank you for writing such a great plugin!
    I've found some issues which make usage of the plugin with version control harder.

    1. Even forced texture compression cause texture repacking and hash recalculation on different platforms (Win/Mac).
    Code (CSharp):
    1. static int GetNewHash(TextureArrayConfig cfg)
    2.       {
    3.          unchecked
    4.          {
    5.             var settings = TextureArrayConfigEditor.GetSettingsGroup(cfg, UnityEditor.EditorUserBuildSettings.activeBuildTarget);
    6.             int h = 17;
    7.  
    8.             h = h * TextureArrayConfigEditor.GetTextureFormat(cfg, settings.diffuseSettings.compression).GetHashCode() * 7;
    9.             h = h * TextureArrayConfigEditor.GetTextureFormat(cfg, settings.normalSettings.compression).GetHashCode() * 13;
    10.             h = h * TextureArrayConfigEditor.GetTextureFormat(cfg, settings.emissiveSettings.compression).GetHashCode() * 17;
    11.             h = h * TextureArrayConfigEditor.GetTextureFormat(cfg, settings.antiTileSettings.compression).GetHashCode() * 31;
    12.             h = h * TextureArrayConfigEditor.GetTextureFormat(cfg, settings.smoothSettings.compression).GetHashCode() * 37;
    13.             h = h * Application.unityVersion.GetHashCode() * 43;
    14.  
    15.             // FIX
    16.             // We already have different logic per platform in GetTextureFormate so we don't need this
    17.             // #if UNITY_EDITOR
    18.             // h = h * UnityEditor.EditorUserBuildSettings.activeBuildTarget.GetHashCode() * 47;
    19.             // #endif
    20.             return h;
    21.          }
    22.       }
    The problem is in the last lines that add an active build target to the hash. This is redundant because you already have logic inside the GetTextureFormat function that changes a compression depends on the current target platform.
    Also, it breaks a "Forced compression" logic because will cause hash change on different platforms.

    2. Always changing the name of texture array asset object.

    Texture Array asset has Name serialized property which is written to the asset file. When you create a texture array you do not fill this property. I suppose that it fills automatically when you create an asset with AssetDatabase.CreateAsset. But when a file already exists you calling CopySerialized which blindly copying all fields from one object to another what can cause an empty name inside the texture array object.

    Code (CSharp):
    1. {
    2.             var existing = AssetDatabase.LoadAssetAtPath<Texture2DArray>(diffPath);
    3.             if (existing != null)
    4.             {
    5.                // FIX:
    6.                // We need to copy a name from existing file before copying.
    7.                diffuseArray.name = existing.name;
    8.  
    9.                EditorUtility.CopySerialized(diffuseArray, existing);
    10.             }
    11.             else
    12.             {
    13.                AssetDatabase.CreateAsset(diffuseArray, diffPath);
    14.             }
    15.          }
    I hope that will make your plugin a little bit better :)
    Have a nice day!
     
    mmaclaurin and jbooth like this.
  3. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    @Kelevra Great work there... been struggling with things like this in our git.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    Awesome! Thanks so much for this! I'll run some tests and include these in the next patch. You'd think that CopySerialized would copy the name too, but I can also see why someone wouldn't want that copied and it might be an exception case.
     
  5. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Hi @jbooth , i bought your Lava & Puddles stream add-on today. Great product as others of your tools.

    I’m having a little issue with the Terrain Painter. My game is a big terrain splitted 8x8. When I select any of those terrain, Terrain Painter doesn’t recognize the terrain I’ve selected. Working nice tho when I create a new terrain and I assign the same MicroSplat texture to it.

    Any idea what can cause that ?

    Thx
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    as long as they are using MicroSplat you should be able to select them all and paint on them like they are one giant terrain.
     
  7. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    That’s what I’m expecting. All my 64 terrain tiles ( using SECTR complete ) are using MicroSplat textures. All is working fine. Can paint easily with my 16 textures and enable any of your module. In game mode I’m streaming only required terrains but in world building mode, I have all terrains loaded and selecting one or many having the same effect.

    I even deleted all your assets from my project and re-imported them. Same results. But i kept the same MicroSplat config. Maybe something wrong or corrupt ( but all is working fine) .

    Thx Jason, I’ll do more testing tomorrow and see if I can find out where the error message is coming from in your code and maybe it will give me a hint on what’s wrong in my setup.
     
  8. ClocktimerGamer

    ClocktimerGamer

    Joined:
    May 25, 2017
    Posts:
    5
    For the most recent version of MicroSplat :

    1. I import the latest version 3.4102 into my project running on 2019.2.17

    2. I get the following error :
    Assets/MicroSplat/Core/Scripts/TextureArrayConfig.cs (275,17): error CS0246 : The type or namespace name ‘Substance’ could not be found (are you missing a using directive or an assembly reference ? )

    3. I tried resetting packages to defaults, but no improvements.

    I am working with someone on the project and I am concerned something has been deleted. Is there an easy fix for this error? Frustrated as I want to apply this to a terrain I am working on.

    (I can get MicroSplat to work in other projects.)
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446

    The project had substance installed at some point, so you have a define in your build settings and MicroSplat is trying to link against the substance code because your project is saying it’s installed.
     
    ClocktimerGamer likes this.
  10. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    509
    I'm using ShaderVarientCollections in my project to preload shaders so that my scenes can load smoother when using SceneManager.LoadAsyncScene.

    I keep seeing terrain shaders being compiled during gameplay (even though I added them previously to the ShaderVarentCollection that I'm preloading). Would you know if this is something with Microsplat or how Unity Terrains work?
    I'm trying to pinpoint why this is only happening with my terrains...thanks.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    MicroSplat doesn't really use shader keywords or variant compiles, it rewrites the shader code when you change a shader option instead. (Though the surface shader and terrain systems do use a few keywords, so you will see a small number of variants per shader. The main one for terrain is the ones set for DrawInstanced).
     
  12. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    @jbooth It turns out this was user error, I was doing a quick demo scene and left the color model as Gamma. Sorry for the distraction, here's a beauty shot in recompense

    upload_2020-5-17_10-44-54.png
     
  13. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,842
    @jbooth I just heard :D

    epicmegagrant.jpg

    Congrats on the Epic MegaGrant!!!

    With your excellent skills, I'm sure it's well deserved. Can't wait to see what you create with it :)
     
    Last edited: May 18, 2020
  14. Casanuda

    Casanuda

    Joined:
    Dec 29, 2014
    Posts:
    53
    Hi Jason,

    Having an issue, but unsure what setting to change.
    This screenshot is after immediate conversion to microsplat without any extras added.
    The default (left) looks fine, while the microsplat (right) has blocky banding.

    I did play with the compression settings after taking the screenshot, but nothing fixes it.
    Anything you would reccomend?

    https://ibb.co/MRVdnBq


    Unity 2019.2.11
    Microsplat shader: 3.4

    Thanks
    Cas
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    See if it happens with no compression, or use the quality packing mode (which has to be set on both your texture array and shader, and will output different texture arrays which you need to assign to the material).
     
  16. Casanuda

    Casanuda

    Joined:
    Dec 29, 2014
    Posts:
    53
    Hi,

    Thanks for the reply. Ended up adding a bit of noise to the texture which solved it.

    Two questions if you don't mind (which may be sliiighlty not in the realm of Microsplat) :
    - I can get tessellation looking good on a small terrain (50x50), because it subdivides small enough to pick up the detail. On a large terrain eg. 500x500, the subdivisions are much larger and the detailed tessellation does not pick up. Do you know if there is a good setting for the terrain to allow for detailed tessalation on larger terrains?
    - Is there any (easy) way for a collider to respect the tessalation?

    *If these are too off topic, feel free to say so :)

    Thanks
    Cas
     
    Last edited: May 19, 2020
  17. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    @jbooth , I am using teh global snow plugin. We are resetting world origin for an open world, which gives inconsistent results since the snow is projecting from world space. We tried doing an offset but still having some issues. Is it possible I could bake the results of the snow into the existing splatmaps?
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    Hardware tessellation can subdivide a triangle up to 32 times. So you want to increase the resolution of the terrain on your larger terrain, such that it has smaller triangles to begin with.
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    There's an option for enabling floating origin in MicroSplat; you can then set the matrix via a global shader property.
     
    BIGTIMEMASTER likes this.
  20. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    sorry but can you point me to where this is? can't find in docs or in the shader
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    It's under the core/advance section and called "Origin Shift", and you set it with Shader.SetGlobalMatrix("_GlobalOriginMTX", myMatrix);
     
    BIGTIMEMASTER likes this.
  22. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    ah I needed to update, now I see that section.
     
  23. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    @jbooth , can you show any example of this being implemented?
     
  24. ade72

    ade72

    Joined:
    Mar 20, 2019
    Posts:
    17
    @jbooth thank you for the great Stochastic Height Sampling for ASE tool! It works like a charm. Only problem is that I get a compiler error message, when I put it into a shader function and use it inside that function more than once; I get a "Stochastic ###number###" REDEFINITION error... any clues? Thank you so much!
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    That would essentially be it, but I think you'd want the world to local matrix instead..
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    I'm not totally sure- I think a user fixed this a while back and was talking to me about the changes, so I'll have to dig it up. I think the fix was to give it a more unique id so the function wouldn't get defined twice.
     
  27. ade72

    ade72

    Joined:
    Mar 20, 2019
    Posts:
    17
    Ah, okay, thank you. I will try that...
     
  28. ade72

    ade72

    Joined:
    Mar 20, 2019
    Posts:
    17
    @jbooth I cannot find a way to give a unique id to this function.... if you find the time to dig for the answer: Would be great!
     
    Last edited: May 20, 2020
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,842
    I just toyed around with making a golf game and was wondering about how to make a hole for the ball without modeling and texturing too much. Turned out that the Mesh Blend feature is quite helpful. In case anyone has a better idea, please do share. Anyway, here's mine, maybe someone else has use for this:

    I created a terrain hole which is naturally a square. Problem was how to get the area around the cylinder filled. So I created a cylinder with a hole and a disc around the top, could as well be a square of course. Looked like this in Blender:

    hole.jpg

    Then I added the MicroSplat Blend on it. I have to say I'm impressed how smoothly that all worked. You can see the orange outline in the edit view which is the disc on top:

    mesh blend.jpg

    I had to add a MicroSplat decal to the ball after that :D
     
    Last edited: May 20, 2020
    f1chris and camta005 like this.
  30. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    The hole itself is using a stencil mask to remove the terrain in front of it I guess?
     
  31. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    3,842
    No, it's a cylinder, ie the hole is modeled in the cylinder. I removed the terrain with the terrain hole feature of Unity 2019.3. But good idea, that would be another option.
     
  32. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Great idea and a cool application of terrain blending but be careful @Rowlan you don't want the rumor to start that you're making a game!
     
    Rowlan likes this.
  33. WingsOfAltair

    WingsOfAltair

    Joined:
    Dec 12, 2012
    Posts:
    12
    I'm having a problem with Microsplat Trax.
    It does not make a terrain track or change the texture of the path.

    I first tried it on a Terrain using Gaia Pro, didn't work. I tried also adding CTS. Nope.

    I Even tried using the provided test scene with the package.

    I have:
    Microsplat Core
    Microsplat Trax
    Microsplat Dynamic Snow
    Microsplat HDRP Support
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    You have to use MicroSplat on your terrain, not CTS. Also, Trax does not support HDRP or URP currently, as is clearly listed on the asset store description.
     
  35. WingsOfAltair

    WingsOfAltair

    Joined:
    Dec 12, 2012
    Posts:
    12
    Acknowledged. Thanks for the quick response.

    It worked flawlessly in the provided example scene without HDRP or URP.

    Just out of curiosity, is it possible to tweak MicroSplat settings/scripts to work with CTS on a Gaia Pro terrain, as I want to combine Trax effects with CTS and compare it with purely MicroSplat? Or do I have to choose one or the other?

    Also, any ETA on Trax and Tessellation HDRP support?
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    You can generate terrain with Gaia just fine, but CTS is not a shader that can be extended with new module's like MicroSplat can, so it's not possible to extend it with new features. And even if you could extend it, you'd run into performance problems with it pretty quick. Terrain itself can only be drawn with one shader. MicroSplat is actually a shader generation system, so it can be infinitely extended with new features and capabilities, unlike other terrain shaders, which is why it has like 10x the options of any other shader out there.

    I don't have an ETA on HDRP support of trax/tessellation- a lot of that depends on Unity providing a stable, documented pipeline, which so far they have completely failed to do. I've been tinkering with getting Trax working in SRPs for a while, but there are just too many undocumented features and bugs both URP and HDRP right now, and generally Unity breaks the pipelines every other release forcing large re-writes of code, so increasing the amount of code that has to be constantly rewritten doesn't seem particularly wise.
     
  37. WingsOfAltair

    WingsOfAltair

    Joined:
    Dec 12, 2012
    Posts:
    12
    Agreed. Good luck to you with development and sales.
    Thanks for this masterpiece.
     
  38. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    I recently compared Microsplat with CTS and there is no doubt Microsplat has better performance particularly if you want to use any advanced features. However I did notice one thing I liked more about CTS and that is the brightness per texture property looked better in CTS than in Microsplat, which looked washed out when increasing brightness where CTS seemed to retain the color definition in the texture. A quick look at the code and it showed that brightness uses addition in Microsplat and CTS uses multiplication. With some of my darker textures that I increase the brightness for they really looked better in CTS even when playing around with contrast and saturation in Microsplat.
    Would you consider adding an equivalent per texture property? You could call it something like intensity.
     
  39. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    Hi, in regards to the lava system, I was just wondering if its possible to have different variations of the texture/colour? I realised it can be used to simulate not only lava but also crude oil and mud for example. The way the system works now I think it is only possible to have one texture, is that right? If its not possible to have different variations I will leave this as a suggestion for future releases. Thanks!
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    There is a saturation control as well, can you not get the same effect by boosting saturation when you increase brightness?
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    Right now there is only one lava system- having two would mean needing to store additional masks, compute additional dynamic systems and buffers if they are dynamic, etc..
     
  42. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    I understand. As a workaround I can always change the colour via script depending on the player position, this will suffice for now.
     
  43. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    when using the Substance plugin and dropping a .sbar file in a MicroSplatConfig slot, the GUI stop displaying and getting those errors.

    Just tried on a fresh project with one your demo and the latest ( from yesterday) Substance plugin.

    thx
     

    Attached Files:

  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    Repro'd and fixed
     
    f1chris likes this.
  45. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    I played around with both contrast and saturation after using brightness and was not able to get as good a result. I can just change it myself, but I thought I would mention it as it does actually make a difference.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    I'll toy with it and see what I think. If it is closer to what people expect, then it might make more sense- however, changing it is preferable to adding a new control, but then there isn't a great way to make it backwards compatible.

    Edit: Ok, it's "Color Intensity" - too different from the current control, so made it it's own.
     
    Last edited: May 22, 2020
    Rowlan and camta005 like this.
  47. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Thanks for implementing this :)
     
  48. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    688
    I would like to have parts of my terrain appear wet(darker, increased smoothness) that under a global water plane. Is there a way to do that currently?
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,446
    I think there is actually the opposite, a way to turn wetness off underwater (specular fade), because many underwater effects already apply this to the terrain. Right now the only way would be to create a mask yourself, either with the painting tools, or in photoshop.
     
    knxrb likes this.
  50. knxrb

    knxrb

    Joined:
    Dec 16, 2018
    Posts:
    21
    There's a Wetness Height feature that's part of the Streams Module (also included as part of the Terrain Collection) that helps with making the ground under a specific height look wet.

    That's what I've done for my game to make the sand look wet where the waves/water reach s they come to shore, and slightly below.

    If you don't change the specular fade value then it'll look shiny and "wet" all over the ocean floor if that's what you're wanting, and if not you can fade it out so it just applies it at the level you're needing for the shoreline/water height and not everywhere beneath the water.

    Theres also settings for having the height adjust up and down gradually, to mimic the effect of waves going in and out at the shoreline.
     
    jbooth likes this.
Thread Status:
Not open for further replies.