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

    terrycheung

    Joined:
    Oct 9, 2014
    Posts:
    9
    Would it be possible to vertex paint hard edges ? I'm a bit confused, as the definition of vertex colors suggests it wouldn't be possible. I guess i could fake it by place extra vertices really close to each other where i want the edge to be.

    However in blender i see that you can vertex color by a selected face, but i'm not sure if i how can map that back to what Microsplat is expecting, and also i cant see the vertex colors painted by Microsplat, if i import the model back into Blender.
     
  2. PatrickLipo

    PatrickLipo

    Joined:
    Mar 14, 2015
    Posts:
    36
    Hey Booth: Been a long time, and I've really enjoyed catching up on your work lately. It just so happens that I have some procgen terrain in my game and just tried using MicroSplat's ProceduralTexture on it... awesome results in very little time, and it definitely beats my previous procgen texturing using CTS. Thanks for this.

    Sooooooo, I'd like to use a cavity map with my terrain, but since the height map is calculated at scene load I have to trigger the cavity map generation in script after that. If I could use MicroSplat's generator that would be great, but I'd have to call something like MicroSplatTerrainEditor.ComputeCavityFlowMap without the UnityEditor stuff. Would that be possible/easy to do?

    Thanks again for the great work.
     
    Last edited: May 25, 2020
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat packs the data in the vertices in a custom format. Basically it backs four weights into each float (so color.r is the first 4 splat weights, color.g the next 4, etc..). So unless you write some kind of custom code for Blender you need to do the painting with the MicroSplat tools.

    Those functions are really not optimized for runtime use. You could move them to runtime yourself if you want to use them, should be straight forward, but if I were to support that then I'd get a bazillion requests to make it basically instant with people complaining about hickups as they try to use them on streaming worlds.
     
    terrycheung likes this.
  4. PatrickLipo

    PatrickLipo

    Joined:
    Mar 14, 2015
    Posts:
    36
    Ah well, just trying to take advantage of its procedural strengths (hey, its in the name :) ) and trying to generate on startup, perf isn't a big deal in this case. Maybe I can feed the material my own splatmap on the fly...

    One more thing: Is there any way I can tell what Config file is attached to which specific terrain? When I create one it names it MicroSplat,1,2,etc which can be hard to wrangle since it starts generating files off that name. The connection between Material and Config is clear but I'd like to keep the configs straight between various scene terrains (and perhaps even use a common setup across multiple terrains if it becomes practical). Any advice?
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    the best way is to give each unique terrain or terrains its own MicroSplatData directory. If the terrain data file for the terrain is in its own folder, MicroSplat will put the directory for that terrain in that folder.
     
  6. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Was doing some displacement tests and really enjoyed these particular shots. Microsplat is always a pleasure to work with.


     
    camta005, andrew210 and Rowlan like this.
  7. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    Is there a good way to "Sync" at runtime. I'm creating a terrain at runtime:

    Code (CSharp):
    1.     public TerrainLayer[] terrainLayers;
    2.     public Material terrainMaterial;
    3.     [ContextMenu("CreateTerrain")]
    4.     private void createTerrain()
    5.     {
    6.         TerrainData tData = new TerrainData();
    7.         tData.size = new Vector3(256, 32, 256);
    8.         tData.heightmapResolution = 256;
    9.         tData.alphamapResolution = 256;
    10.         tData.baseMapResolution = 512;
    11.         tData.SetDetailResolution(512,32);
    12.         tData.size = new Vector3(256, 32, 256);
    13.         tData.terrainLayers = terrainLayers;
    14.         Terrain t = Terrain.CreateTerrainGameObject(tData).GetComponent<Terrain>();
    15.         MicroSplatTerrain mst = t.gameObject.AddMissingComponent<MicroSplatTerrain>();
    16.         mst.templateMaterial = terrainMaterial;
    17.         mst.Sync();
    18.     }
    19.  
    20.     [ContextMenu("Sync Terrain")]
    21.     private void syncTerrain()
    22.     {
    23.         MicroSplatTerrain mst = Terrain.activeTerrain.GetComponent<MicroSplatTerrain>();
    24.         mst.Sync();
    25.     }


    Terrain only seems to be able to be "Sync'd" after I've selected the newly created terrain object in editor. Is there a good way to do this?

    The motivation for doing this is because we have a terrain thats entirely generated by code and don't want to store terrain data in the project (previous to this it was taking up around 1mb of our total 100mb allowed in google play)
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You need to set the rest of the data on the MST component - propData, etc..
     
    andrew210 likes this.
  9. Decordova360

    Decordova360

    Joined:
    Nov 9, 2015
    Posts:
    8
    I purhcased the Amplify Shader stochastic plugin which is nice and thanks for that. I am now in 2019.3 using MicroSplat with Unity URP and trying to find the "Stochastic" feature but having a hard time, am I suppose to purchase another plugin for this like "Texture Cluster Module"?
    Thanks
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It's part of the texture cluster's module, yes. Docs for all modules are included with Core, so if you ever want to see what a module adds before purchase that's the best place to look.
     
  11. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Yes, microsplat is awesome for this but you need the streams module. There's several nice nuanced features:
    - make everything darker below the water line
    - make everything "glisten" (smoothness) around the waterline, but not undewater (ground doesn't glisten / specular underwater, that happens at the interface between air and water)
    - dynamic streams are amazing quality, and you can also make them stop at the waterline (rivers "disappear" when they go into water, they don't keep gong)
    - puddles can accumulate
    - rain drops on puddles
    - if you use enviro, you can have it wet all the ground when it rains, and you can even exclude certain areas so shelter stays dry

    My game takes place around islands and the waterline, and the realism with microsplat is spectacular. I posted a few pics a bit earlier of some terrain tuning around the waterline and you'll see how subtle the wetness features can get. (pics are above above a bit)
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    it’s funny how many features I’ve added to MicroSplat that I’ve just forgotten it has..
     
    f1chris and mmaclaurin like this.
  13. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    ...and the really amazing thing is they all keep working anyway. Probably the only tech I've never swapped out for something better because...there isn't anything ;)
     
    f1chris likes this.
  14. filvec234

    filvec234

    Joined:
    Oct 7, 2018
    Posts:
    2
    Hello, I have encountered a very odd problem after importing the microsplat into my project. The console is showing me multiple errors:
    upload_2020-6-4_21-13-33.png
    I tried looking into documentation. Didn't find anything helpful, but it might just be that I am in my fourth month of working with unity so I must have missed something. Any idea what could be giving me these errors?
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Try in a fresh project..
     
  16. filvec234

    filvec234

    Joined:
    Oct 7, 2018
    Posts:
    2
    Just did, works fine. Thank you! Great job on Micro Splat. Love the low poly mode
     
  17. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    I've been seeing shader warning lately regarding streams. I haven't reintroduced streams yet to my levels after switching to MapMagic 2 but am seeing this even without using them. I do have all the streams features turned on.


    Shader warning in 'MicroSplat/MicroSplat': use of potentially uninitialized variable (DoStream) at line 2914 (on d3d11)

    Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL
    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
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    This warning has been reported before, and I can only think it's a bug in the compiler, since the DoStream method is clearly not a variable, and all variables passed to this method are initialized. It also doesn't seem to cause any issues, since it's just a warning..
     
    mmaclaurin likes this.
  19. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Is there a good way to tame the high-frequency speckle-like noise coming from the wetness module? Looks bad in a still, but it's really seizure-inducing in motion.

    upload_2020-6-6_14-12-57.png
     
  20. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    I've had that in the past, and it has usually been a misinterpretation of one of my texture channels. You should check that a) your channels are in the right slots b) you are using the same packing quality on the texture config and the materials settings and c) you are telling the packer the right channels to look at in your textures (i.e. is smoothness in alpha, etc.?) I usually walk through everything in the texture array config and double-check that settings are consistent. Also check your workflow (metallic v. specular)

    Hope this helps! Wish I remember exactly which config gives me speckles but it was a misconfig.
     
  21. larry2013z

    larry2013z

    Joined:
    Apr 14, 2020
    Posts:
    36
    MicroSplat Mesh Terrains: Pink Mesh Terrain as a prefab/Asset Bundle

    I have just purchased MicroSplat Mesh Terrains. I am trying to create an AssetBundle for a game called Tabletop Simulator. The game cannot use standard Unity Terrains but it can import assetbundes that include standard meshes with materials applied. I created a single terrain in Unity and used Window > Microsplat > Terrain to Mesh. I chunked it into 4x4 or 16 chunks with 25 subdivisions. The resulting mesh in Unity looks perfect and is textured.

    When I drag it down into the project window to create a prefab, the prefab appears pink in the Inspector window in the section to assign AssetBundles as per the attached image. (If I drag the prefab back into the scene window it appears textured)
    PinkTerrain.JPG

    When I create the assetbundle and import into Tabletop Simulator, the mesh comes in pink just like the preview window.

    Can you please help me? I feel like if I can get it to appear textured in the inspector window I should be good to go.

    Thanks,
    Larry
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    if your loading that into an externally compiled app that doesn’t have the MicroSplatMeshTerrain component compiled into it then it’s not going to work, because it needs that code to work correctly.
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The porosity value controls how darkened and shiny the surface of a given texel is, based on the normal/smoothness of the surface. I have considered exposing the maximum smoothness value of a water surface to allow you to dampen this effect, but from a purely technical standpoint porosity of the surface is what you should be adjusting.. If a surface is more porous, it holds more water in the cracks, darkening it more and creating higher reflective values. However, if your not running with something like temporal-AA, you can get specular aliasing from the highlights effectively appearing and disappearing based on the view.
     
  24. larry2013z

    larry2013z

    Joined:
    Apr 14, 2020
    Posts:
    36
    Ah, then I'll have to tackle this another way. Using your Terrain to Mesh functionality, I now have a mesh, the original textures, and your splat maps. Perhaps I can learn to write or otherwise obtain a Shader so that I can create a material for my mesh so it at least looks like my original Unity Terrain. Its my understanding that multiple alpha maps are combined into one texture using the red channel for one map, the blue for another, and so on. However, when I load your splat maps into Photoshop, all of the channels appear empty (transparent). At its simplest all I need to do texture a mesh to duplicate the way Unity's terrains are multi-textured. Can you explain why the splat maps appear transparent and/or give me any tips where to go from here?
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    they appear transparent because the alpha channel in a PNG is premultiplied with the color, and when photoshop loads them it does this and leaves you with a blank texture. There is a photoshop plugin that will load them correctly somewhere on the net. Alternately you can change the code to output TGA files which are available on newer versions of Unity.
     
  26. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Just bought and downloaded the Stochastic Sampling for Amplify Shader Editor and it says the node is not valid in Amplify. What's the problem?

    Amplify Shader editor v1.81
    Stochastic Sampling for Amplify Shader Editor v1.0
    Unity 2019.3.15

    upload_2020-6-8_12-2-4.png
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, maybe they updated the API. I'll take a look.
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Just tested in a fresh project, with latest amplify (1.81) and stochastic, and everything worked. Can you try in a fresh project?
     
    FeastSC2 likes this.
  29. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I try now.
     
  30. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    It works now.

    The reason was that I can't move the Amplify Shader Editor folder in another location anymore. It has to be on the root for your node to work. Let me know if you can reproduce that and if you can allow the package to be placed in different directories
     
    Last edited: Jun 8, 2020
  31. LordHorusNL

    LordHorusNL

    Joined:
    Jun 22, 2017
    Posts:
    12
    I'm having a small problem with the global texture module. It would seem the tint/normal textures don't work across multiple terrains. Am i missing something or it this feature not implemented and if so could you add it in a future release?

    Thanks
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Should work fine- you have to supply the images on the MicroSplatTerrain component, which will have overrides for them. If you assign them directly to the material, they would all have the same ones.
     
  33. LordHorusNL

    LordHorusNL

    Joined:
    Jun 22, 2017
    Posts:
    12
    Thanks for the quick reply. I do actually want all the terrains to use the same image from the material however i thought it would get projected across all the terrains the same way it would on a single terrain.

    So when using multiple terrains i'm going to have to cut up my global tint texture and add them to the terrains components?
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes.. There is a UV Scale/Offset for them I believe, but I'm not sure if that is exposed on the terrain component currently..
     
  35. LordHorusNL

    LordHorusNL

    Joined:
    Jun 22, 2017
    Posts:
    12
    No the UV Scale/Offset isn't exposed on the terrain component currently, though wouldn't it make more sense for the global texture on the material to just project over all the terrains with that specific material just like it would on a single large terrain as the default behavior?

    It would make working with global textures simpler when using multiple terrains and world streaming for example because you wouldn't have to adjust all the terrains by hand, just the base material. Could that be possible in a future update?

    Thanks.
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That would require the shader to have some concept of how many terrains you have in the scene and what their relative location to each other is, which it doesn't. Or for it to be in world space, which means you would have to set some kind of physical bounds for the projection. The later is certainly more feasible, but wouldn't work with origin shifting and such..
     
  37. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    It also would be working against the concept of tiled builds in programs such as world machine which usually spit out texture sets per tile. Which makes sense for when you need to rebuild certain tiles of a large map but not the whole - building only the required ones reduces build time.
     
  38. LordHorusNL

    LordHorusNL

    Joined:
    Jun 22, 2017
    Posts:
    12
    Yeah i did think about the impact it would have on tiled terrains being made with world machine, unfortunately i'm working with a purchased asset terrain so i'll have to cut up my global textures in Photoshop which is a pain for larger terrains or just take the leap and purchase world machine so i can have more control over the entire process.

    Thanks anyway.
     
  39. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,300
    MicroSplat Trax adds just the certain detail I was missing :D

    frozen 1.jpg
    frozen 4.jpg
     
  40. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    @jbooth

    I've done a load of work to allow objects to texture the ground right at the edge where 2 terrain's meet, it's finally working great!

    I've hit a new snag, when I lower the overall texture resolution in the Unity Quality Settings, it creates a very noticeable seam along all the terrains. Does anything come to mind why this might be?

    Image #1 is full resolution textures, no seam whatsoever (the right side of this image looks like a seam but isn't)
    Image #2 is half res textures and has a clear seam.

    Thanks again for the amazing work on this, the whole micosplat is a game-changer.


    seam.JPG seam2.JPG
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unity's quality settings lowers the texture resolution of all textures, regardless of if that's a good idea or not. I don't believe it affects the splat maps or runtime generated textures though, so essentially you must have a texture on disk somewhere that is being lowered that is causing this issue- like a global texture or something. Honestly, the global texture resolution settings is a poorly implemented feature, as without having the ability to prevent certain textures from being down graded in any real project it's almost always going to break some LUT or something.
     
  42. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44

    Okay that's very helpful thanks, I will figure out which texture is the issue, and possibly look into a more targeted solution for quality settings.
    Keep up the great work, we're looking forward to getting the Scatter module
     
  43. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    I've read somewhere you said using UV texture scale per texture property is more expensive then setting
    global UV scale, but I see its now the default in the latest update, does it still hold true ?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, it's still true. It defaults to on when you convert a terrain that has textures with varying UV scales. If they all have the same UV scale, it doesn't turn it on. This is to better match the existing texturing on the terrain, as I get a lot of people not understanding that the UV scales need to be set after conversion and thinking that the textures look "blurry". So I figured making it exact was better than making it more optimized.
     
  45. Jingle_Josh

    Jingle_Josh

    Joined:
    Aug 7, 2017
    Posts:
    2
    just bought it and am having trouble setting up the triplanar projection mapping. It doesn't seem to actually want to project multiple textures. I've adjusted all the settings and looked at the documentation about the tri planar and have found nothing. Hopefully you might have some insights into the issue.
    On top of that, I noticed there are several versions of the HDRP, the URP, and the standard RP. I got both the HDRP first before realizeing that the URP was the one I needed.
    I'm using version # 20129.3.11f1 with the preview terrain editor. I figured these might have something to do with my issue.
     
  46. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    I think you're misunderstanding what triplanar projection is. It doesn't project three different textures, it projects the texture from different angles (axes) so that cliffs don't get smeared. it's a common graphics term you should check it on wikipedia. It makes terrain look a LOT nicer close up.
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    As @mmaclaurin said, yes, you're thinking of triplanar texturing, not mapping. I kind of wish the terms were not so similar. Anyway, the procedural texturing module will let you texture based on slope, though it's a lot more advanced that simple triplanar texturing.
     
  48. Jingle_Josh

    Jingle_Josh

    Joined:
    Aug 7, 2017
    Posts:
    2
    Aaah, my bad. Sorry for the dumb questions.
     
  49. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    138
    Hi Jason,
    I've just installed 2019.4LTS. Does the Terrain Collection package support URP? Or do I need to purchase that asset to make it work?
     
    Last edited: Jun 16, 2020
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    URP support requires the URP module, which is sold separately.
     
    browne11 likes this.
Thread Status:
Not open for further replies.