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
    MicroSplat uses the Unity Terrain systems splat map data; so if you want to use a splat map from an external source you will need to apply it to the terrain however you’d do that normally.
     
  2. Harjawalda

    Harjawalda

    Joined:
    Sep 1, 2018
    Posts:
    15
    Thanks for the reply, I do use a script provided by WM for the import of the splatmap. Now the issue I have is, when I convert the Terrain to microsplat, the general distribution of the textures seems to be taken into account but I loose all the details (errosion, waterflow). I hope the screenshot comparison helps, is there a way to preserve the detail? I'd love to use your tools but when I loose all the detail I worked to get from WM, I'm basicly starting from scratch. I'm new to world design so I dont know if that workflow Im proposing is feasible or not. TIA.

    Mount-Test-V2.jpg

    Nevermind, Height Based Blending needs adjustment all works fine!
     
    Last edited: Oct 22, 2018
  3. bodzi0x95

    bodzi0x95

    Joined:
    May 16, 2018
    Posts:
    12
    Hi,
    I have a little problem with microsplat. I added microsplat to one terrain and it works ok but next I added it to second terrain and it looks like some of textures have correct brightness and contrast and some of them have washed out colours. The same textures work well on first terrain.
    I'm using linear color space and on first terrain all textures looks great but on second terrain some of them look like linear color space and other look like gamma color space. All textures are imported in correct way. Unfortunatelly I can't post any screenshots because I can't spread this kind of data.
     
  4. Amenophis-Memnon

    Amenophis-Memnon

    Joined:
    Sep 22, 2016
    Posts:
    5
    Hi! Thanks for your work! I'ts incredible and so easy to use.
    I have a cave entrance model that uses same rock texture as my terrain. How to give him the same look as MicroSplat shader? It's possible with standard shader? If not, can you create a shader for meshes without textures array? I just want the same look, not a paintable mesh (i know you make a new module thats make that but i not need that)
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You likely want to select both terrains and convert them together, otherwise you'll have two sets of textures/shaders/materials for each instead of one. Why one would look different than the other, I'm not sure- I would expect them to work the same, unless you added the additional maps (smoothness, etc) only to one of the texture array configs you generated.
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The easiest way would be to use the terrain blending module and blend them.
     
  7. bodzi0x95

    bodzi0x95

    Joined:
    May 16, 2018
    Posts:
    12
    It's a specific case to have 2 terrains which must have different settings for textures etc.
    I don't have any other additional maps beside height and normal. It isn't look like some textures have additional maps or not, it rather looks like some of them use gamma color space and other uses linear :/
     
  8. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'm finally using the mesh tool, and it's working very nicely! But is there a way to save the generated meshes in the scene as meshes or prefabs or assets or something, so I can copy-paste them into another scene?
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It doesn't generate new meshes, so you should be able to prefab them just fine.
     
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Sorry, that's what I was trying to say -- there is no mesh if I make a prefab -- the Mesh Filter component is empty.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You mean like it goes away? It should just reference whatever mesh you were using, which I assume is an FBX or something on disk, right?
     
  12. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    sorry, i mean when I use the Terrain to Mesh converter -- those generated meshes.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Pretty sure they get written to disk. I'll test and see if the reference clears for me, maybe something isn't being dirtied that should.
     
  14. diego_ger

    diego_ger

    Joined:
    Dec 17, 2017
    Posts:
    8
    Hello. Is there a limit in the size of the splatmap for the terrain? Is it posible to make it bigger than 2048x2048?
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The splat maps come from the Unity Terrain system, so it’s limited to whatever they generate (the shader will work for any size)
     
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I select a folder in the project for the converted files to be saved to, and the splat/control maps are generated there, but no meshes -- at least not in several attempts I've made.
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    fixed
     
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    thank you!
     
  19. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
  21. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    @jbooth I've been getting endless copytexture errors in the latest few 2018.3 betas and Microsplat appears broken. I think you said Unity had broken something? Any guess when that might be fixed? Cheers.

    Code (CSharp):
    1. Image invalid format!
    2. UnityEngine.Graphics:CopyTexture(Texture, Int32, Int32, Texture, Int32, Int32)
    3. JBooth.MicroSplat.TextureArrayConfigEditor:CompileConfig(TextureArrayConfig, List`1, String, Boolean) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1379)
    4. JBooth.MicroSplat.TextureArrayConfigEditor:CompileConfig(TextureArrayConfig) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1538)
    5. JBooth.MicroSplat.TextureArrayPreProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayPreprocessor.cs:48)
    6. UnityEditor.AssetDatabase:CreateAsset(Object, String)
    7. JBooth.MicroSplat.TextureArrayConfigEditor:CreateConfig(Terrain) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:359)
    8. MicroSplatTerrainEditor:OnInspectorGUI() (at Assets/MicroSplat/Core/Scripts/Editor/MicroSplatTerrainEditor.cs:67)
    9. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    10.  
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I submitted a bug to them about it- so no, I have no idea when they are going to fix it.
     
  23. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    I have a couple of questions. I'm running on Mac, latest 2018.3 beta 7, but the problem has existed for a very long time and in much earlier versions.

    MicroSplat works very well, except for one thing: when I save the project, no matter whether there are changes or not, all terrains go from this:

    Screenshot 2018-10-27 at 12.45.55.png

    to this:

    Screenshot 2018-10-27 at 12.47.59.png

    That is, MicroSplat is disabled and all terrains (there are several) revert to the standard shader. I have no idea why, and there's no special code that I know of in the project which could cause it. I'm also wondering about that warning.

    Running the project fixes this, but there's no way to revert back to MicroSplat in the editor unless you do it manually.

    The second question has to do with the new instanced terrains. Enabling "Draw Instanced" disables drawing of the terrain entirely. It's just not visible.

    Is this particular to Metal on Mac, is it due to the beta status of 2018.3, or is Draw Instanced terrain mode not supported by MicroSplat yet?

    Thanks in advance.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I think there's code in OnDisable that reverts the terrain, this is so people can switch off MicroSplat and compare vs. regular terrain. Is this causing an issue?

    Instance Terrain Mode is supported, but written for 2017.3. I personally cannot get MicroSplat to work on the latest 2018.3 betas because of a CopyTexture bug Unity introduced in Beta 5, so I'm surprised it's working at all for you in 2018.3.7
     
  25. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Cool. Is there somewhere we can upvote your bug report?
     
  26. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    (post deleted) ups wrong thread! xD
     
    Last edited: Oct 28, 2018
  27. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    Well, if the OnDisable code is triggered in connection with a save and thereby disables MicroSplat, then yes. Why would I want to see my terrains in regular render mode after a Save? Especially if there's no way of switching them back except by running the app again? But I'm perhaps misunderstanding something.

    It works just as it always has in the latest betas. Perhaps the bug doesn't manifest on Mac?
     
  28. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Well, then something in your code base is disabling it and not re-enabling it after the save. A save doesn't trigger the disabling of components.

    I dev on a Mac..
     
  30. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    I'll PM you about this, as there are no non-standard components in the code base.
     
  31. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Hi,

    it is somehow possible reduce terrain SplatAlpha0, SplatAlpha1, .. files which are compressed as ARGB 32bit (21.3MB each)?
    My scene consist from 16 terrains, each 2k size and for now I am using 6 textures, so size of the build is around 1GB.
    If it is possible force unity to compress SplatAlphas with DXT5 it will be significant reduction in build size. I dont need super quality in texture blending, so DXT5 should be OK.

    I tried Source Texture Size set to K32, but I am not sure if this option is affecting SplatAlpha terrain files.
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Funny, I just added a feature that might make this possible. Source texture size does not affect the Splat maps; those are generated by Unity and passed to the shader automatically.

    In the latest version, I added a feature so you can use external splat maps instead of Unity's. What you can do is export the splat map data (no tool for that included, but easy to write) and compress it however you like. Then set MicroSplat to use the external splat maps and assign the output splat maps. Finally, you can set the terrain's alpha map size to 16 or something so that Unity's ones are tiny. This would be a destructive operation, but if you do it at build time and don't rely on the alpha map data for anything, it should work fine and allow you to compress those textures.
     
  33. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    I was already using custom splatmaps, but this part of workflow I overlooked in terrain options. Now the build size is reduced. Thanks for help.
     
  34. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I'm on a Mac as well and getting the same issues as @jbooth in 2018.3b7 (since about 2018.3b4 I think).
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unity broke CopyTexture in 2018.3b4, so until they fix that I wouldn't expect the beta to work.
     
  36. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
  37. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Hi,

    if I enable tessellation with Use custom Splatmaps, my terrain turns white from camera position to max tessellation distance and unity throws shader error: "undeclared identifier '_Control1' at line 725 (on d3d11)".

    In MicroSplatConfig I am using 6 textures , packing mode fastest, PBR.
    MicroSplat material: packing mode fastest, max texture count 8.

    Both tessellation and custom splat maps options ON are working only if I set max texture count 4. All other options 8 - 32 throws error and white terrain. Parallax + custom splat maps are working OK.
    tessellationCusomSplatMaps.jpg
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ah, I’ll check it out and upload a patch; I think I know what I missed.
     
    mmaclaurin likes this.
  39. erenaydin

    erenaydin

    Joined:
    Mar 1, 2011
    Posts:
    384
    Anyone figured out to fix the texture array bug until the official release come?

    This is my only error with Unity BETA 2018.3.0b7
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Nope, waiting on Unity as it's in their code..
     
    erenaydin likes this.
  41. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Hi

    few questions:
    Is is possible to implement mipmaps streaming for texture arrays, or we need to waint first for unity implementation?
    Crunched DXT compression(in texture arrays) - is there some performance drop compared to the default DXT?
    How far is development of Microsplat for mesh module? :)
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unity would have to implement that- not sure if texture arrays even support that kind of a thing anyway. I haven't experimented with crunch much, but my understanding is that it's entirely a loading optimization and completely uncompressed to DXT by the time it gets to the GPU.

    Mesh module has been done for ages- I just haven't made the marketing images and such..
     
    Bzuco likes this.
  43. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    764
    Hi, Early this year i used to have some artifacts on textures using Microsplat (on my old 660 ti):oops: i did a test in U2018.2.13 with the last update of your asset !! and now everything seems fine!:):)

    Glad i bought the anti tile module a long time ago! I'm gonna dive into MicroS now! It performs real fast considering my needs!

    I have a general question, considering my low end GPU, do you think using U2018 instead of U5.6 is gonna make me lose Some fps in my project? (wich seems to be the case but not much)or maybe improve? (which i doubt a lot).
    I'm thinking of MicroS to balance this general fps lose.

    Edit: And BTW is there any issue with VS Pro version? The author says it was rewritten so maybe things are different now...??

    thanks
     
    Last edited: Nov 7, 2018
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I wouldn't know about unity versions and speed- you'd have to test. As far as I know everything is fine with VSPro- if there are issues, Leonart and I would fix them.
     
    eaque likes this.
  45. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    764
    Many thanks for your prompt answer! Great news!
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It's hard to say without examining each device under a profiler- android devices are really wacky and have a ton of inconsistencies in terms of how they are actually built, though I would expect a pixel and S8 to both have fairly decent hardware. Some things to check:

    - Make sure the texture arrays are being compressed into the correct texture format (ETC2); if for some reason they aren't, then they'd end up being uncompressed, which will destroy memory bandwidth.
    - Try reducing texture res to see if it helps- this will only help if your memory bound, which is usually not the case.
    - Can you post your material settings so I can see which options you have on?
    - Using LOD sampler mode can speed things up a bit, but will cause some blurriness in some cases.
    - Make sure blend mode is set to Quality when using max 4 textures. If it's not set to quality, then it still has to sort the samples, which can be expensive on mobiles.
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have a shader profiler for android? Because that would be the best way to track it down. I normally do mobile optimizations on Instruments, because it can show you how long you are spending on each section of the shader code, which is incredibly useful, but I'm not sure if something like that exists for Android because the architecture is so varied. Likely it would come from the GPU manufacturer for that particular device. However, if your getting other artifacts it might not be MicroSplat at all, because it doesn't really mess with rendering order and such, it's just a surface shader.
     
  48. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Actually, after some more testing, I think your suggestions on the material settings helped quite a bit. It turns out that I also had some accidental high aniso settings for the texture arrays that I think were also affecting performance. I think the MicroSplat material still performs better on iOS than Android, but now the performance is much closer, and usable on Android. Also, I was completely mistaken about the aforementioned artifact: It was purely due some bugs in my app code.

    Really sorry about the misleading posts, I have now deleted them.
     
  49. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Do you have documentation on how to do this?
    I managed to adjust the base shader to accept my Rendertexture and integrate it into the streams code.
    Looks great btw :)
    But how can i make this a module that integrates into your system?
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's not really docs on it- but if you choose one of the simpler modules it should be pretty easy to follow along. Basically every module derives from an interface which has functions to add properties and source code to the shader. Features get added/removed via shader keywords, and theres a step to pack and unpack these from the material. In most cases, the calling code ("DoSnow()") is put into the core module while the actual function is stored in the fragment files in the module, though the advanced details module (which isn't written by me) uses a search/replace style method to add it's code so he can change the calling code without me having to update core.
     
Thread Status:
Not open for further replies.