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
    There's an optimization guide in Core/Documentation which has a lot of information on this topic, along with a few YouTube videos on it. The main bottleneck in a terrain shader is the number of texture samples you have to take, so reducing those numbers is usually the best thing. MicroSplat displays the number of potential samples taken in the debug section of the shader, and has debug display modes to show exactly how many samples are actually taken on a given pixel. The most expensive features are ones which multiply you sample count, like triplanar and stochastic, which both triple the sample count (or 9x when used together), but the branch samples optimizations can reduce the cost of these considerably.



     
    protopop, Rowlan and Barritico like this.
  2. unity_9rBp5m5c2_ph5g

    unity_9rBp5m5c2_ph5g

    Joined:
    Apr 28, 2020
    Posts:
    12
    Hi, First off Great Tool. I'm having a bit of trouble though and I'm relatively new to Unity so I'm probably just missing something obvious, lol. When I apply the Splatmap all of the textures on my terrain turn Grey? Any idea what could cause this?

    upload_2020-5-6_12-5-42.png
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Going to need a lot more info than that. Are you in a Scriptable Render Pipeline, screenshot of the texture array config, what do you mean by apply the splatmap - is this coming from an external program?
     
  4. unity_9rBp5m5c2_ph5g

    unity_9rBp5m5c2_ph5g

    Joined:
    Apr 28, 2020
    Posts:
    12
    Hello,

    Ok, I'll do the best I can.

    Running Unity 2019.3.12

    I created a brand new scene and imported the MicroSplat from the Unity Store.
    I receive some errors in the Console upon import. (Maybe this is part of the problem.)
    upload_2020-5-6_17-1-53.png

    I create my terrain and assign 2 textures. So my terrain currently looks like this.
    upload_2020-5-6_17-5-19.png

    I then Add Component - Micro Splat Terrain
    Select a Template and Convert to Microsplat (Sorry in my previous message I accidentally typed splatmap, when I ment microsplat)

    upload_2020-5-6_17-7-42.png

    And then my terrain turns grey. I can apply the roughness, ao maps, etc. but nothing changes the color.

    upload_2020-5-6_17-8-31.png

    upload_2020-5-6_17-12-1.png
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Your height map is red, but you're pulling the data from the green channel. Otherwise, make sure the arrays are assigned to the material - should have happened automatically, but it's possible the diffuse/height array isn't assigned..
     
  6. unity_9rBp5m5c2_ph5g

    unity_9rBp5m5c2_ph5g

    Joined:
    Apr 28, 2020
    Posts:
    12
    I can change the height map to the red channel, but it doesn't change anything with the color unfortunately.

    I think I found the problem in the shader. By default the max texture count is 4, as soon as I changed that value the textures loaded. I could change it back to 4 and it stays working, very odd, but at least now it works. :)

    Thank you for the help and pointing me in the right direction.
     
  7. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Hi,
    I own MegaSplat and all the MiroSplat modules.
    Is it safe to assume MicroSplat needs to be installed for the modules to work?
    When I import MicroSplat 3.401 into Unity 2019.3.13f1, I get these two errors:

    Assets\MicroSplat\Core\Scripts\MicroSplatObject.cs(50,11): error CS0246: The type or namespace name 'MicroSplatProceduralTextureConfig' could not be found (are you missing a using directive or an assembly reference?)

    ssets\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?)

    I've not used MicroSplat in other versions.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It looks like you project once had procedural texturing and substances plugin installed, and when removed the defines left in the build settings were not removed, so the code is attempting to link to those assets. So either install them again, or remove the defines from the build settings and it will compile.
     
  9. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    ok, I'll check it out.
    Thank you
     
  10. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    My project terrain (2k x 2k ) is using all Microslat assets and things work great but I would like to by Path Finder. Seems a good tool to paint paths on terrain but was wondering if someone here knows if it works fine microsplats.

    Anybody tried both together ?

    thx
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    https://github.com/Roland09/PathPaintTool
     
  12. firefly9000

    firefly9000

    Joined:
    Dec 7, 2016
    Posts:
    13
    Apologies if this is not the right place to ask this but I just purchased Megasplat and would like to review docs on how it works with ASE. I cannot seem to find the documentation (or tuts on this). * or even the regular Megasplat docs.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Honestly it's been so long I have no idea if it even does anymore. ASE has gone through a ton of versions, and the nodes were not used by many people as far as I know. But basically there were nodes to decode the texture indexes and weights, and sample the textures from the texture array. And another node to read the per texture property data..
     
  14. firefly9000

    firefly9000

    Joined:
    Dec 7, 2016
    Posts:
    13
    I understand. We have a terrain shaded with a custom ASE shader. I saw intro video for Megasplat and saw there's a conversion from a regular terrain to Megasplat.

    Is there any way to salvage the work done with the ASE shader or do we have to redo it from scratch in Megasplat? Thanks
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MegaSplat uses a fundamentally different technique that Unity terrain uses, so it's a really different beast, with its own data format at tools workflow. MicroSplat works with the standard Unity formats. But neither is meant as something you can insert into an existing shader somehow..
     
  16. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
  17. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Loving MicroSplat!

    Just thought I'd try out the wind and glitter module on our sand areas. Doesn't seem to behave like I'd expect. Across the terrain that is lit, it works find, but in shadow these areas become dark splotches that doesn't look like drifting sand at all.

    upload_2020-5-9_13-49-25.png
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have shadows turned on the wind feature? I suspect they are what's producing the darkening effect.
     
  19. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    I thought so too, but no... same with shadows on or off.

    upload_2020-5-9_18-11-38.png
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The effect itself doesn't know about its lighting condition, rather it adjusts the inputs to the lighting. A mask is calculated, the albedo is interpolated towards the wind color based on that mask. Then the other components are ramped down according to the mask (normal gets weaker, AO increases, less smoothness, etc). What I suspect is happening in your case is that the ambient occlusion being reduces is creating a darkening effect. I will add a parameter so you can control how much the ambient intensity is modified.
     
  21. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Why would my case be any different than anyone elses?
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not saying it is- just that no one has ever brought up the issue before. Anyway, in the next version an AO slider is exposed so you can say how much of the AO gets dampened by the wind..
     
  23. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    I use screen space AO. So I'm not really following what you mean by AO being affected by this.
     
  24. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    In the feature request bucket, it'd be nice to be able to attenuate the wind/dust effect by the various wet maps (wetness/puddles/streams) as it doesn't look quite right for sand to blow "over" these areas.
     
  25. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Hi.

    Regarding TRAX.

    Imagine a car that leaves some marks (with TRAX) for the places where it circulates.

    Is there any way, or can you give me any idea, if I could "burn" those marks (or the terrain WITH those marks) so that, in the next load of the scene, they would appear already created?

    Thank you.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    textures have AO maps; these are affected by wind. It has nothing to do with screen space ao.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    you can serialize and restore the Trax buffers if you want them persistently; but remember they are relative to the trax managers location, so that would need to be positioned the same on load.
     
    Barritico likes this.
  28. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    Hi. I'm experiencing a small issue with URP 7.3.1 and the Base Map Dist. terrain setting. It's not doing anything. There's a clear line in my terrain where the texture resolution drops after a certain distance from the camera (see image). I must be missing something, but I though this was what the Base Map Dist. slider was for but it's not working. Is there another setting somewhere I have to change? I'm not even sure if this is a Microsplat related issue or a Unity terrain w/ URP issue, but any help would be greatly appreciated.
     

    Attached Files:

  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The basemap is not used like it is in the Unity shader. Most likely the line you see is the mip map changing levels because the array is set to bilinear instead of trilinear shading. You can change it on the Texture Array Config.
     
  30. Createman

    Createman

    Joined:
    Apr 14, 2013
    Posts:
    16
    I'm using the terrain blending module (and triplanar module). Is there a way to get more precision/resolution for the placement of the terrain blending material? I mean the terrain descriptor. I'm trying to create a very narrow blending but it's located a bit off when the terrain has more shape.
     

    Attached Files:

  31. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Okay, some confusion here...

    What is the difference between the Terrain Painter and the VFX Painter? I'm having an issue where there is a Terrain_stream_data.tga and Terrain_steram_data.png. One updates the former and the other updates the latter. Both seem to show on the terrain (streams, water, etc.), but when I restart unity the tga settings are lost, so it must be using the png? Confused what's going on.
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Use float precision on the terrain descriptor instead of half, which is the default...
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The FXPainter is no more- unfortunately the asset store won't delete files, so while it's not included in the package anymore, there's no way for me to delete it off your system.. Either install the module fresh, or just delete the old FX painter from the Streams/Scripts/Editor folder.
     
  34. Createman

    Createman

    Joined:
    Apr 14, 2013
    Posts:
    16
    Yea tried it but didn't help much. Is there a way to make the texture 4k for example? I could edit some code if you could point to right direction.
     
  35. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Okay, but the problem is that when I use the new one it changes the tga file, and everything paints as I expect live. But when I restart Unity, all the work is gone. It seems to be loading the png version of the splat map for streams even though it saves the tga version.

    Super confusing.
     
  36. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    BTW, even though you cannot delete files, you can change the file so that it no longer does anything... kind of a dummy C# class. That'll remove it from the Window menu and avoid confusion.
     
  37. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    I can confirm that the MicroSplatObject's streamTexture is referencing the .png file and not the .tga file. Still trying to understand what's going on... it clearly has to do with the attempt in the code to move from .png to .tga, but haven't figured out why it's not working for me. It does save the stream splat as TGA but it doesn't use the TGA file, but instead insists on using the .PNG file.
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You have the PNG file assigned in the terrain component, and I bet it's grabbing it from that.
     
  39. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    Thanks for the response! The problem did have to do with the Aniso of the textures, which apparently weren't being applied to my terrain textures at all. Even when I set trilinear filtering and my ground texture's Aniso level to 16 it did nothing. For some reason I had to set Anisotropic Textures in Quality Settings to "Forced On" in order to get Aniso levels to work at all with my terrain. "Per Texture" doesn't turn on Aniso of terrain textures even though my texture's Aniso Levels are set high. Not sure why that is, but it feels like a bug maybe with Unity's terrain and URP. For my needs though I'm all set so thanks! I want it set to Forced On anyways since it greatly improves my overall quality for what seems to be little performance cost.
     
  40. LordSwaggelore

    LordSwaggelore

    Joined:
    Mar 14, 2019
    Posts:
    5
    Hello, I saw dynamic terrain deformation in your MicroSplat Features Video at 2:30 (a projectile hit the ground and left a hole). How is this done and which module from MicroSplat is used for this?
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The hole is created with Digger Pro and my Digger integration module.
     
    LordSwaggelore likes this.
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You have to set the aniso level on the Texture Array Config, since it is going to repackage your source textures into texture arrays..
     
    RPowers likes this.
  43. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Where do I find the place to change this in the blizzard of UIs? (not complaining, it's a complicated thing you are doing)
     
  44. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    Ahh ok that makes a lot of sense. Thanks again!
     
  45. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Spent a lot of time looking, I still cannot find where I can change what texture is used for the stream splatmap. I get the impression I'm going to be pretty embarrassed when it was right in front of me the whole time... but just don't see it anywhere.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    On the MicroSplatTerrain component, it has a link to the stream data for that terrain, since in a multi-terrain setup each would have it's own painting data.
     
  47. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Okay, I give up. Here is the MicroSplatTerrain component in all it's glory. Where is the Stream Splat map referenced in this UI?

    upload_2020-5-11_19-10-8.png
     
    camta005 likes this.
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Awe crap, you're right - the code in the editor got removed for it.

    In MicroSplatTerrainEditor.cs add the following around line 172:

    Code (CSharp):
    1. #if __MICROSPLAT_STREAMS__
    2.       MicroSplatUtilities.DrawTextureField (t, new GUIContent("Streams"), ref t.streamTexture, "_WETNESS", "_PUDDLES", "_STREAMS", "_LAVA", false);
    3. #endif
    That'll be in the next patch too. You can also use the debug inspector to replace it if you're not used to editing code (there's a gearbox at the top of the inspector window).
     
  49. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Cool... I’ll add that in thanks!
     
  50. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Hello, with Microsplat 3.4 (at least it says "shader generator 3.4") it appears that specular fade (used to fade out specular highlights underwater) is broken: it fades the specular term properly, but it also appears to fade the darkening of the materials caused by wetness. I.e. sand below the water height and below the specular fade should not be shiny but should be dark, and what I'm seeing is that it is neither shiny nor dark. It didn't used to do this; the behavior seems to have changed in the last 3-4 builds (they've been coming fast lately.)

    It's a little inconsistent in that some textures seem to get dark and others not, but oeverall something seems wrong. (btw I'm not varying porosity per texture or at all, it's left in default state.)

    Anything else I should check?
     
Thread Status:
Not open for further replies.