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

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Ah, interesting. We'll check the compression on each of our computers, but so far it's DXT5 consistently. I don't see where to select that compression type. Is that exposed now, or will be in an update?

    We'll be publishing on PC and Metal,, so could use ASTC....but the docs say that's only for Android and tvOS?
    https://docs.unity3d.com/Manual/class-TextureImporterOverride.html
     
  2. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    OK, thanks for the explanation. But when looking at our _tarray files, the texture format is DXT5 on both ends. And I didn't see any reference to texture format when I checked the GetNewHash function. It would seem to me that simply being on, or targeting, different platforms would trigger a recompression regardless of texture compression.
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Most modern cards support multiple formats, not just DXT, which is pretty crappy quality wise.
     
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    We've all got DXT5 set, so that doesn't seem to be what triggers the dirtying.

    And where would we set that to something different?
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You’d have to wait for the next version that I outlined above. Right now it triggers based on platform; not the form of texture compression that platform uses.
     
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    okay, thanks (wasn't clear to me if that was an existing or upcoming feature).

    But given that everyone on our project is on Mac/Windows and have the same texture compression format....any other ideas why these files are dirtied and have to be reimported with each git push/pull?
     
  7. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    I've started with a large 2K terrain - added MicroSplat Terrain script, clicked convert, tweaked setting and textures. All good.

    In a separate scene I've split that terrain into smaller tiles (for streaming). What's the best way to copy my MicroSplat settings to all the individual tiles?

    I tried just copying the component then 'paste as new' onto the tiles but it's not rendering properly in the editor and I get the following error spamming the console on Play:

    Code (CSharp):
    1. MissingReferenceException: The variable terrain of MicroSplatTerrain doesn't exist anymore.
    2. You probably need to reassign the terrain variable of the 'MicroSplatTerrain' script in the inspector.
    3. MicroSplatTerrain.Cleanup () (at Assets/MicroSplat/Core/Scripts/MicroSplatTerrain.cs:98)
    4. MicroSplatTerrain.OnDisable () (at Assets/MicroSplat/Core/Scripts/MicroSplatTerrain.cs:69)
    Sorry, can't seem to see a terrain variable slot in the component.

    @jbooth Could you explain the process? (ideally non-destructive, so I can keep my original scene intact so I can go back and work on the full terrain if required.)

    Also, if I had more than one terrain in my project, but needed different MicroSplat settings, how would that work? I'm confused by the MicroSplatTerrain component referencing a single 'MicroSplat' material. Can I just duplicate and rename this 'material' as many times as I want, or can I create a differently named one when clicking 'Convert to MicroSplat' on the second terrain?

    Sorry, probably stupid newbie questions! Wonderful asset though. Been using CTS but starting to much prefer this in a lot of ways. Great pricing model too :) those extra modules are addictive, and very well priced!
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, because each time the platform changes from Mac to windows the hash is different and triggers a recompress.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    You can have as many ‘systems’ as you want; if you have multiple terrains you want to share settings between, select them all and do the conversion and they will share one set of shaders/materials/etc. or set them up individually if you want them separate. If you want to add one later, add the MicroSplatTerrain component, set the template material and propdata on them to the one you want and press sync. Think of each MicroSplatData directory as the data for a system.
     
  10. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Thanks @jbooth Did some testing in a dummy project and I get it now.

    So for anyone interested in a step by step guide for multi-terrain...

    Rather than copying and pasting the original component, I selected all the tiles and added a new MicroSplatTerrain.
    Then clicked 'Convert, which created new files, the ones with the '1' suffix in the screenshot below (that answers my question about how microsplat handles different terrains - each time you convert it creates a new set of shaders and asset files):


    So then I just replaced the Template Material. Clicking on the picker isn't ideal as the project displays multiple assets with the same name (they're from the example folders)


    So keep an eye on the asset file path to make sure you pick the right one, or just drag and drop from the Assets/ MicroSplatData folder.

    Works great.
    {EDIT} actually... just found that selecting all terrain tiles and changing the assigned Template Material doesn't actually update each and every terrain. SO you have to do each one manually.
    @jbooth - any chance of a small utility that would assign one material to all selected terrains? It gets a bit laborious in a scene with 256 terrain tiles (split for streaming)
     
    Last edited: Jul 5, 2018
  11. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    So the mere fact that some of us are on Mac and some on Windows means we'll all have to reimport these files each time we push/pull on git? No way to prevent that?
     
  12. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    Unity was able to reproduce the Editor crashing when selecting a material bug. Go vote!
     
  13. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Voted! And so glad you could repro it (I've been unable to, but it happens in our main game project, which is 50gb...).
     
    mons00n likes this.
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Please read the reply to your post where I outline how this is being prevented in a future version, along with the other replies in which I told you this will be fixed in a coming version.
     
  15. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Okay, sorry, don't mean to be an idiot, I guess I just misinterpreted what you said before, again.

    So to make sure I understand this:

    Currently, even if the texture compression is set to DXT5 on all of our computers, some of which are Mac and some are Windows, they'll still be considered to be different, and thus forcing git to reimport them.

    But the upcoming fix will let us choose the texture compression in a way (this is the part I didn't catch) that makes them the same cross-platform. Is that right?
     
  16. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Hi @gecko I noticed an old post by you which didn't seem to get much of an answer. re. using MicroSplat with WorldStreamer and getting 'Can't remove Terrain because MicroSplatTerrain (Script) depends on it' errors.

    Did you ever find a solution or workaround?
     
  17. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Haven't yet -- was hoping somebody else would :/ Maybe you could try posting on the WS forum and see if you get a reply? (I'll like it!)
     
    jeromeWork likes this.
  18. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Saw you'd already tried asking there too :) Back to using CTS I guess... @jbooth support for streaming terrain tiles seems a pretty obvious thing to need. Are we doing something wrong in our set-up?
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No idea, never used World Streamer- Most likely it's trying to remove the components on the terrain, but tries to delete the Terrain component before the MicroSpat one- you could most likely remove [RequireComponent(Terrain)] from the MicroSplatTerrrain.cs file to prevent this particular error from being thrown..
     
  20. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Thanks @jbooth i'lI try that later.

    The thing about World Streamer is that it isn't doing anything particularly clever, just additive async scene loads and unloads. That's why I think it's a MicroSplat issue not WS. I'll try to create a small example project that doesn't use WS but recreates the error when I get the chance.

    Thanks for all your help
     
  21. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    @jbooth any chance of getting Metal/Roughness setup in MicroSplat !?
     
    Last edited: Jul 7, 2018
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It already is and always has been. Switch the TextureArrayConfig to PBR mode to expose the slots for all those textures (internally it generates them in basic mode).
     
  23. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    I am aware of the PBR setup and now am opening a project to double check but i think it was the "Smoothness" workflow and not the Roughness !
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's an invert checkbox if you have roughness textures..
     
    Vagabond_ likes this.
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Version 2.1 being submitted now:

    • Upgrade note: TextureArrayConfig texture settings refactored, so all settings will be reset to default on upgrading. Please adjust your configs..
    • Ability to pack Smoothness/AO separately from normals (for higher quality, but slower speed due to being 3 arrays)
    • Option to size source textures on array compile. This will reduce the source textures to either 256 or 32 pixels in size saving memory in builds.
    • You can now force texture compression formats to DXT, ATSC, PVR, and ETC2
    • You can now override the texture settings on a per-platform basis, allowing for scaled textures or different compression formats on each platform
    • When computing texture array hash, resulting texture compression format is hashed instead of platform choice. This should let people working on mac/pc not recompress the arrays on a regular basis, since those platforms should result in the same compression format.
     
    camta005, gecko and Vagabond_ like this.
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So this morning between flights I had an idea on a rather old issue- the texture derivative issue when using Per-Texture UV scales which causes artifacts on some GPUs. The current workaround is to use the LOD samplers, which selects the mip map in the shader rather than letting the GPU do it. This is actually faster, but unfortunately breaks anisotropic filtering, which can reduce quality.

    So the idea today was to use the gradient samplers and compute, compute the derivatives by hand, then scale them to an average based on the current weights and use those final derivatives in the gradient samplers. I have implemented this and it appears to work, so I'm uploading this to the asset store as part of the 2.1 patch.

    In the next update, I will make gradient or LOD samplers mandatory when using PerTexture UVs, defaulting to the gradient samplers with this new fix. If those of you who are familiar with this issue can test with the gradient sampler once this patch is released and let me know if you notice any difference to your overall shading, I'd appreciate it. In theory, this will change the mip map selection, but average out to something very similar.
     
    camta005 likes this.
  27. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    I do have the issue on a GTX 750 Ti so i could test it !
     
  28. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Thanks @jbooth ! That works just fine (@gecko that does seem to do the trick so you should be good to go too :) )

    I'm still having problems applying MicroSplat to multiple terrain tiles though.

    I have one large terrain on which I've set-up MicroSplat. I then split this terrain into lots of tiles.
    I would like to be able to apply those settings onto all terrain tiles.

    I converted each terrain (as per my post above) and then switched the TemplateMaterial to the instance of the MicroSplat material that exists on my large terrain.
    - but that doesn't have any effect on the terrain tiles.

    Am I doing something wrong? Any help much appreciated!

    Working on single large terrain:

    Broken on terrain tiles:
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you press sync all after you were done assigning the material? Note that you can set them all up at once by selecting them all when you do the setup..
     
  30. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Hi @jbooth Thanks for the prompt response. Yes, I did click sync all. And I've tried again since then just in case it hadn't worked the first time. But no change.

    What would you recommend? Strip out all of the component instances and start again? Is my workflow correct or am I doing something wrong at my end?
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Should just work once you assign the material and press sync. You could try setting them all up as one system from the start, but I do this all the time when I'm testing so I know this works. Do you have any other components on the terrains which might be messing with the materials?
     
  32. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    There are VegetationStudio TerrainSystems on each terrain but same as on the large one piece terrain. They all use the same VegetationStudio Package - which defines no textures (so MicroSplat is left to do its thing)

    I just tried redoing the conversion from scratch and again nothing. For info when you say "Note that you can set them all up at once by selecting them all when you do the setup." - that works for adding the MicroSplatTerrain component and doing the initial conversion, but not the reassignment of the Template Material. that has to be done one by one.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Works fine for me:



    Converts both terrains, sets up one template material for both of them..
     
  34. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Yes, that first part works fine (converting multiple terrains at once and generating a single Template Material).

    The problem I have is when I want to replace that with the settings (template material) from another terrain (the unsplit, whole terrain):


    Does that make sense?
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, why do you have more than one? I think I'm missing your end goal here..
     
  36. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    I have a large 2k terrain on which I've created and set up MicroSplat.

    I've now split this terrain into multiple tiles (for performance reasons).

    I want to copy the original MicroSplat settings (template material) from the large terrain to all of the tiles.
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ah- yeah, setting it on the template material property and pressing SyncAll should do it (and also the propdata). This will re-instantiate the instance materials for each terrain.
     
  38. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Except it doesn't. It's what I've been saying. Firstly you have to manually add the other template material manually to each terrain, I can live with that, but sync all doesn't seem to do anything - or at least the settings don't seem to be applied to the terrain. Have a look at the screen shots I posted:
    https://forum.unity.com/threads/fre...or-unity-terrains.487458/page-29#post-3558711
     
  39. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    @jeromeWork: Are you sure the microsplat material isn't getting assigned to the terrain? What is shown in the terrain settings tab? Is it one of the built-in shaders or microsplat?

    Looking at those two screenshots, what I notice is that the second one has different texture tiling frequency, but that might be expected if you set it up on a huge terrain and are now assigning it to a smaller slice of that terrain. (I've never done that, so not positive.)
     
  40. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    @gecko thank you! You got it:)

    So for anyone hitting the same issue... the problem is that splitting my terrain has altered the terrain's UV scale. All I had to do was to change the Global UV Scale in MicroSplat > Splats:



    Since I've gone from a 2048x2048 terrain to 256x256 ( a factor of 8 ) I had to change the Global UV Scale from 256x256 which the original large terrain used (I'm not sure how this is calculated when you convert to MicroSplat), to 32x32 (256 / 8 = 32)
     
    razzraziel, gecko and blacksun666 like this.
  41. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Jason,

    I am working on a game for iPhone and Android. I have Microsplat plus all the modules. Does this asset works well in mobile? if so, do you have any recommendations on how to use it for the best performance?

    Regards,
    Carlos
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Pay attention to sample count in the debug tab when you turn features on and off, it’s a rough but decent approximation of memory bandwidth usage. You can also have different setups for different devices, as high end mobiles are pretty powerful these days. For real data, use Instruments GPU capture and find a draw call of terrain, and it will show exactly where you are spending time and the balance between ALU cost and memory bandwidth.

    Finally, some optimization’s are not obvious; for instance, if you’re using only 4 terrain textures, then blending mode on Quality may actually be faster than when set to fast if you are on low end devices which tend to be ALU bound. But in all cases, profile.
     
  43. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Hi, I'm seeing brutal frame rate drops (80 -> 20) when enabling triplanar on MacOS.

    Chip (below) seems decent, would you expect such a severe hit from triplanar? Only using 4 textures but I do have about 9 terrains live at a time.

    I've got a Radeon on my MBP:
    Radeon Pro 555:

    PCIe Lane Width: x8
    VRAM (Total): 2 GB
    Revision ID: 0x00c7
    gMux Version: 4.0.29 [3.2.8]
    Metal: Supported, feature set macOS GPUFamily1 v3
     
  44. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Thank you Jason. I appreciate your input on this.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Triplanar is 3x the texture samples, so I’d expect a drop, but not that severe, unless you happen to be particularly bottlenecked on memory bandwidth. You could test this by reducing texture resolution to see if it has a significant effect.
     
  46. RafaBM

    RafaBM

    Joined:
    Dec 7, 2017
    Posts:
    2
    I installed MicroSplat with some modules some time ago. It worked fine until the last update (Version: 2.1 Jul 09, 2018).
    When build gives me this error.

    Assets/MicroSplat/Core/Scripts/TextureArrayConfig.cs(231,19): error CS0246: The type or namespace name `PlatformTextureOverride' could not be found. Are you missing an assembly reference?

    I have tested with a clean project and installing only microsplat.
    Unity 2017.4.3f1
    Can you help me?
     
  47. ruin_spellbook

    ruin_spellbook

    Joined:
    Feb 22, 2016
    Posts:
    4
    Found a small annoyance. When I set the Packing Mode to Quality, the config file allows Diffuse, Normal, and Smooth settings. If I adjust the Texture Size property for any of those settings the config file automatically sets the Packing Mode back to Fastest.
     
  48. ruin_spellbook

    ruin_spellbook

    Joined:
    Feb 22, 2016
    Posts:
    4
    Oh, it seems to only do this until I hit update.
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Strange; I would expect it to compile for no one if that class was missing. I uploaded core earlier today with a small dx11 fix, so the only thing I can think of is if somehow the upload was corrupted. But that seems unlikely..
     
  50. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    @jbooth I'm getting that error too (fresh download tonight into a new project, maybe things got corrupted at the asset store end?) Not using MicroSplat in the scene I'm trying to build. It's just in the project, but makes the build fail.
     
Thread Status:
Not open for further replies.