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

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Hey Jason, I just picked up the tessellation add-on and I am having some trouble with it turning the terrain black. It works just fine on the example terrain that comes with MicroSplat core, but I cannot get it to work on any other terrains. I tried to create a new scene, add a terrain, convert to MicroSplat, and then add a texture through the MicroSplatConfig. I used the MicroSplat provided "Shore Sand" texture and provided normal, height, smoothness, and AO maps. After turning on Tessellation, if my view is within the tessellation range, the terrain goes black. I can adjust the range in inspector and the terrain textures will appear again when the tessellation "Max Distance" drops low enough.

    On my projects actual terrain, the terrain only turns black in squares up to the "Max distance" it seems, like this:


    Thoughts?
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    look for compile errors on the shader? What unity version, render pipeline, etc?
     
  3. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Unity 2020.3.13f1. Using built-in render pipeline. I do not see any errors, however there are warnings present when I enable tessellation:
    All of these same warnings show up on the MicroSplat example shader when I enable tessellation on that, but that example scene works with tessellation.

    EDIT: For what it is worth, I do see that the geometry is there when I fly my camera through the terrain and the clipping plane begins cutting through the ground, it is just black/unshaded.
     
    Last edited: Aug 6, 2021
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    those warnings are from some other shader than MicroSplat. One thing to check is toggling draw instanced on the terrain? Should work in both cases, but it’s the only thing I can think of that might affect it.
     
  5. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Thanks Jason! Checking "Draw Instanced" did the trick!
     
  6. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Another quick question. It sounds like the "Up Bias" should make the displacement move along the surface normal vs world up. This does not seem to have any effect and displacement always occurs straight up in my case. With a large amount of displacement on a near vertical surface, it should be pretty obvious that things are changing when I adjust that slider right? For example:
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    this doesn’t work in draw instance because the vertex normal is up. It could be added, but would make tessellation more expensive as it would have to sample the textured normal. Something I might add an option for.
     
    gtzpower and Rowlan like this.
  8. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    Hey Jason.

    Just wondering if there is a time line for Procedural Texturing support in HDRP. Using Unity 2019.4.8f1 LTS and HDRP 7.3.1 and would love to be able to us this feature. Maybe there's already a work around or something I'm missing. I have the Microsplat Terrain Package and HDRP support package installed. Maybe I need to update or reinstall a package somewhere?

    Thanks.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    PT works in HDRP fine..
     
  10. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    195
    Hi there! Reported this issue when I moved from 2020.1.17f1 to any unity version after that, but I can't get MicroSplat to work on iOS anymore (every other platform works fine).

    I've gone back to the most minimal possible project now. New project->Install MicroSplat->Build and run on iOS device. Just to be extra sure, I also regenerated the texture array and shader.

    With development build instead of a release build enabled it at least gives me more data now:

    Code (CSharp):
    1. Initializing Metal device caps: Apple A8X GPU
    2. Initialize engine version: 2020.3.15f2 (6cf78cb77498)
    3. async texture load: failed to load MicroSplatConfig_normSAO_tarray from /private/var/containers/Bundle/Application/969C4458-2CD5-4D4A-8F35-C4822B55A7F8/MicrosplatRecreation.app/Data/sharedassets0.assets.resS
    4.  
    5. 2021-08-09 15:12:35.031634+0100 MicrosplatRecreation[33651:2291069] Unbalanced calls to begin/end appearance transitions for <UnityViewControllerStoryboard: 0x10072c3e0>.
    6. UnloadTime: 4.062042 ms
    7. validateFunctionArguments:3797: failed assertion `Fragment Function(xlatMtlMain): incorrect type of texture (MTLTextureType2D) bound at texture binding at index 2 (expect MTLTextureType2DArray) for _NormalSAO[0].'
    I opened a bug report with Unity but was closed immediately stating that I just needed to regenerate the texture arrays so it does seem like I'm rather stuck and desperate at this point as I'm finding a few bugs with 2020.1.17f1 now that I'm being told "oh just update" when thats not an option because of this issue on iOS. Any help at all would be greatly appreciated.

    Note - the *only* thing the fresh project has in it is the MicroSplat core package, building for iOS.
     
  11. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    Oh sorry I imported it and had some compiler errors with the scripts. I tried closing unity and letting it open/re-import but still had the errors. I then looked on the asset store page for runtime procedural texturing and it said it is only compatible for Built in which lead to me asking about it.

    anywho, this is a screenshot of the errors I'm getting. If you could let me know how to approach solving these errors that would be much appreciated.

    Thanks.
     

    Attached Files:

  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    you need to update your old modules to the latest.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    data loading is all handled by Unity, and the error says it can’t load the texture data- I don’t have any loading code in MicroSplat.
     
  14. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    195
    Thank you, I'll try submitting another bug report to unity
     
  15. IvanMelnikov

    IvanMelnikov

    Joined:
    Aug 10, 2018
    Posts:
    4
    Please explain, I'm not quite sure I understand. To work with terrain in an urp-based project, in unity 2020.3 which of your programs should I download? I need to achieve anti-tiling terrain
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    You'd need MicroSplat's free core module, and the URP2020 adapter. For anti-tiling, there's either the anti-tiling module (which offers most common solutions to tiling textures), and the Texture Clusters module, which offers my own solutions to those problems (Texture Clustering and Stochastic).
     
  17. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    Hey Jason, thanks for the quick replies.

    So i'm still getting an error with updating and re-importing all of the microsplat packages. I deleted the core modules "Microsplat" folder and imported everything from scratch. I even brought everything into a fresh project and still had the same error.

    I've attached a screen shot of the error. Would I be correct in thinking it's because the HDRP 2019 package says version 3.8.4 and the "Terrain Collection" pack says 3.8.6? Would the different versions be looking for something that wouldn't import due tot he version difference?

    Thanks.
     

    Attached Files:

  18. IvanMelnikov

    IvanMelnikov

    Joined:
    Aug 10, 2018
    Posts:
    4
    Thanks!
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    The package manager is broken in a bunch of versions of Unity, including the early LTS versions of 2019 and 2020. It will say you have latest, but install the old version from the asset store cache. So you have to manually delete the asset store cache.
     
  20. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    So I've done everything I can and still have the compiler error when importing the HDRP 2019 support package. I've deleted my "Microsplat" folder in Assets, I've deleted the HDRP support Microsplat folder in "Packages". I've deleted the asset store cache in "Appdata/roaming/unity/assetstore 5.x/jbooth etc....

    After deleting all of that and importing the Microsplat packages I still get that error with the HDRP support package for 2019.

    I have also done this multiple times, once downloading everything through the package manager and once again through the asset store in the editor. Still having the same issue.

    Anything else I could try? really giving it my all to be honest. I understand this is a unity issue but damn there has to be something Im missing or a way to get this working.
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    kill the library folder or try in a fresh project..
     
  22. CaffeinatedCoolaid

    CaffeinatedCoolaid

    Joined:
    May 10, 2021
    Posts:
    47
    So I was randomly searching the internet looking to find some research papers on newer displacement techniques and I came across this and thought it might be an interesting Microsplat feature "Distortion-Free Displacement Mapping", but not as a parallax feature. I think it could serve as an interesting alternative to Tri-Planer mapping where the correction would happen to the terrain uv and the textures would need to be sampled twice instead of three times.
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    samples are already culled, giving a 1.5 to 2.5 sample average depending on the triplanar contrast. With a high contrast value or using triplanar height blending, my technique is faster.
     
  24. mrgrigsad

    mrgrigsad

    Joined:
    May 23, 2017
    Posts:
    1
    Edit: SOLVED!
    I Deleted ALL Microsplat extensions, core, packages etc. Then Restarted unity, installed Microsplat core via packages, installed all extensions anew and then installed the Mesh Workflow.

    upload_2021-8-10_15-39-7.png
    Hello, Jason. I just bought your Mesh Workflow asset, but I can't seem to properly install it. I've been using the Micro Splat core and several extensions that were installed in the old way to the assets folder. Now that your assets are installed as packages I can't get the mesh workflow to work, the component won't even appear on the list of components when I try to add it. I tried removing MicroSplat core and reinstalling it as package. The only error in the console I'm having is
    "Packages\com.jbooth.microsplat.core\Scripts\MicroSplatObject.cs(370,10): error CS0103: The name 'MicroSplatMeshTerrain' does not exist in the current context"
    Hope you can clear things, sorry if I'm just missing something obvious.
    Grigory.
     
    Last edited: Aug 10, 2021
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    as listed in the patch notes, you need to remove the asset versions and update to the new package based versions of all modules.
     
  26. BMayzak

    BMayzak

    Joined:
    Nov 7, 2016
    Posts:
    22
    I'm trying to get Microsplat working in my current project (Unity 2020.3.14f1 using URP) and for whatever reason when I make a build for Android and run it, the terrain is invisible.

    I purchased the URP 2020 package for Microsplat and did the necessary changes to get it to appear in-editor, but something must be conflicting with Microsplat when exporting for mobile.

    Out of curiosity I tried making a brand new project and imported only Microsplat + URP 2020; the example scene worked on Android (terrain no longer invisible), so it's clearly not an inherent issue in Microsplat. That said, there are no errors thrown or any feedback given as to why the terrain would turn invisible on Android, so I'm a little stumped how to solve this short of completely remaking my project and hoping a collision doesn't occur again.

    If you have any hunches or have run into anything like this before I would be super grateful for any tips.

    Thanks for your time!
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    Changes? What changes?

    One thought- try toggling Draw Instanced and see if that has anything to do with it. You could also use the debug mode and set it to albedo to see if it's a lighting/normal issue.
     
  28. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Hey Jason, we have an unusual use case that is generating errors in the editor scripts so I wanted to reach out and see if you had suggestions for how we can implement our use case better or if you think an adjustment to the editor scripts might be in order.

    We have one very large low poly terrain, and at runtime, we are dynamically generating higher resolution terrain tiles around the player so that they can be manipulated with fine detail in game. To do this, we are instantiating the MicroSplatMaterial (using Object.Instantiate()) for each tile and then updating settings so that the tiles load/appear properly. For example, one thing that is different for each tile instance is the _GlobalTintUVScale vector allowing each tile to show the right slice of the global tint map.

    This all works great and we have no problems at runtime. In the editor however, if I select one of the streamed in tiles while playing, we get errors because MicroSplatShaderGUI_PerTex.cs calls AssetDatabase.GetAssetPath() (line 22) on the instanced material which does not exist in the asset database. This means that an empty string is returned, and no propData is loaded which then causes a NullReferenceException exception when propData.GetTexture() (line 41) is called.

    This isn't really causing us any trouble other than the errors appearing when running in the editor and selecting a tile. I just wanted to bring it to your attention in case you have ideas for remediating the errors either on your end or on ours. We tried using AssetDatabase.LoadAssetAtPath() to get a material instance, but unfortunately, the _GlobalTintUVScale data was being written to the original asset when we would change it, affecting all tiles (and the parent terrain).
     
    Last edited: Aug 16, 2021
  29. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,288
    I got this red error when i installed the latest version of the terrain pack with the eleven modules into Unity 2019.4.29f1

    Assets\MicroSplat\Core\Scripts\Editor\TerrainPainter\TerrainPainterWindow.cs(48,90): error CS0619: 'SelectionMode.OnlyUserModifiable' is obsolete: ''OnlyUserModifiable' is obsolete. Use 'Editable' instead. (UnityUpgradeable) -> Editable'


    Can you help?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    clear your package manager cache and update- you have an old version of MicroSplat and unity’s package manager is broken and they are too proud to let out know this so it just keeps installing old versions.
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    Sounds like you wrote your own instancing system instead of just letting the MicroSplatTerrain component do it instead? Why? Managing that kind of stuff is what the MST component is for.
     
  32. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,288
    Ok understand. Can you please tell me how to clear that chache?
    Thank you.

    Edit:
    Just deleted the downloaded asset and then can redownload this asst file and now it is working.
     
    Last edited: Aug 16, 2021
  33. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Unless I am misunderstanding what you are suggesting, we are using the MST component on the terrains. For example, this code is run on every procedurally generated tile:
    Code (CSharp):
    1.         var microSplatTerrain = terrain.gameObject.AddComponent<MicroSplatTerrain>();
    2.         microSplatTerrain.keywordSO = MaterialKeywords;
    3.         Material terrainMaterial = Instantiate(MicroSplatMaterial);
    4.         microSplatTerrain.templateMaterial = terrainMaterial;
    5.         ModifyTintUV(terrainMaterial);
    6.         microSplatTerrain.Sync();
    7.  
    Maybe there is another way that we should be doing this for procedural terrains?
     
  34. BMayzak

    BMayzak

    Joined:
    Nov 7, 2016
    Posts:
    22
    Thanks for the quick reply!

    Regarding 'changes', I just meant switching the MicroSplat material render loop to URP2020 which allows me to see the example terrain in-editor (otherwise it was invisible there as well).

    Also, I figured it out! Apparently I had set Shader Stripping > Instancing Variants to 'Strip All' at one point, and setting it to 'Keep All' fixed it.

    Phew.. was worried I wouldn't be able to use this asset; it seems really cool. Looking forward to playing around with it and seeing what I can do with it + MapMagic 2

    Thanks for your time!
     
  35. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    195
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    You shouldn’t be instancing the material manually- the terrain component will do that for you when sync is called. It will then apply any per terrain overrides or data to that instance for you, so that things like terrain blended objects all get the same data.
     
    gtzpower likes this.
  37. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    Thanks Jason! I took a look through how the MST component instantiates the material and I reworked my script like this:
    Code (CSharp):
    1.         var microSplatTerrain = terrain.gameObject.AddComponent<MicroSplatTerrain>();
    2.         microSplatTerrain.keywordSO = MaterialKeywords;
    3.         microSplatTerrain.templateMaterial = MicroSplatMaterial;
    4.  
    5.         microSplatTerrain.OnMaterialSync += ModifyTintUV;
    6.         microSplatTerrain.Sync();
    7.  
    Hopefully this is more correct. In the editor, when I select one of the tiles, I am no longer getting errors, but all of the tiles seem to lose their individual tint mappings. They look correct before selecting a tile in the editor, but after selecting a tile I get this:


    As with the errors before, this is not a blocker for us as it works fine when I don't select things in the editor. I do appreciate your help here because I want to make sure we are using the tools properly (and so far, in pursuing this, we have discovered that there were issues with how we are using MicroSplat). Thanks again for your support!
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    You should set the tint as an override on the MST component. However, I notice the UVs aren't exposed as an override. I can add that, but a work around is to have your function call sync, then get the terrain's actual material (the instance) and modify it directly (without calling sync afterwards).
     
  39. SubT

    SubT

    Joined:
    Sep 24, 2019
    Posts:
    10
    For anyone not understanding how to do this I solved this by:
    I did a search outside of unity to quickly locate the <Digger> .asmdef files. Next I manually added with the "+" in the inspector the references to Jbooth.Microsplat.Core and Jbooth.Microsplat.Editor to the .asmdef's. Now the scripts with the 2 errors should work and find his namespace. Digger should work and integrate now.

    Thanks Jbooth!!! New to your products I just bought a few.. very nice stuff it will be invaluable. Super stoked to try out the stochastic stuff!
     
  40. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    305
    I think having UVs as an override on the MST component is probably the answer. I tried modifying the terrain's material directly, and it works pretty much the same way. The UVs are correct until I click on a terrain tile in the editor, but in this case, the entire tint map appears on the tile after selecting it (rather than a UV adjusted version).

    My guess is that selecting a tile reapplies the material instance in the MST to the tiles (which I did not modify in this case, so it shows the whole tint map on every tile). And when I do modify the material instance passed through OnMaterialSync(), the last UV modification is what gets applied to all tiles when I select them.
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    Right - but I think if you grab it from the terrain at that moment it would be the instanced material and could be adjusted. But yes, adding it to the overrides is what you really want.
     
    gtzpower likes this.
  42. MasterMax111

    MasterMax111

    Joined:
    Oct 6, 2019
    Posts:
    4
    Hi Jason,
    when I wanted to continue painting my mesh which I started a few days ago I get the error message "Unable to retrieve image reference". When I click the message it points me to the two splat maps I'm using (initially created by Microsplat). Everything seems to be assigned (both splat maps are assigned in MicroSplatMesh script, textures in texture config, other things too).
    Do you know what this could be?

    btw I'm using Unity 2021.1.3f1 with URP, Mesh Painting Workflow.

    MicroSplatError.jpg
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    Looks like the textures aren't set to be readable on the CPU..
     
  44. MasterMax111

    MasterMax111

    Joined:
    Oct 6, 2019
    Posts:
    4
    Hmmm, the textures are set to read/write enabled in Unity and also in the OS there should nothing prevent them from beeing read or written.

    Update:
    I found the problem. I used crunch compression on the splat map control textures. Reverting to no crunch compression solved the problem.
     
    Last edited: Aug 19, 2021
  45. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    Hey I'm getting a black screen in HDRP 10.5.xxx Unity 2020.3LTS with MicroSplat Terrain Pack and 2020HDRP support pack. It happens when I rotate the camera at a higher viewing angle. It looks like it is caused by NaN's? I've tried disabling the objects in the scene one by one and it's the terrain with MicroSplat causing it. When I use the debug tool to show Nan's it shows them on one of the textures of the terrain.

    Any idea on what I'm doing wrong? The normal maps are all set to "Normal" texture type and I've disabled my post processing to see if it was an exposure issue and that did not change anything.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    What features are enabled? It's just on one of the textures? Not sure how a certain texture would product a NaN unless it has something on it that the others don't.
     
  47. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    42
    Hey Jason, thanks for the quick reply as always. I took a look at the Per Texture settings to see if there was anything different than usual. I just updated from 2019 LTS to 2020 LTS so a few things have changed.

    It looks like it was the "Rim Light Color" setting. I turned this one off and it seems to have fixed it. It was set to 0. Is this a Fresnel type effect for the rim lighting of the texture? I only ask because I've had similar results playing with fresnel shaders in shader graph and if the power is off to one extreme I would get a black screen.

    Anyways if it continues to happen I'll send screen shots of the settings to see if there's anything I have incorrect.
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    A power of 0 would be a problem, yes. I’ll add a minimum clamp.
     
  49. iichiversii

    iichiversii

    Joined:
    Nov 23, 2011
    Posts:
    130
    Hi Jason,

    I tried joining the discord channel, however, I haven't purchased any of your assets yet so I cant drop a question in there without a invoice.
    Anyways, I was wondering if you could help me with my query, I am working on Martian terrain which is used in a VR project, is there any concerns in relation to using your terrain assets for VR projects that I should be aware of?
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,070
    nope
     
    iichiversii likes this.
unityunity