Search Unity

[Released] MegaSplat, a 256 texture splat mapping system..

Discussion in 'Assets and Asset Store' started by jbooth, Nov 16, 2016.

  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    It will actually do this already, since prefixing with a number will mean alphabetically they are in order as well. And only the trailing number actually matters for clustering..
    Is your control texture super high resolution? There's kind of this magic ratio between control texture size, cluster size, and visible size where things look best, and too far outside of that range you start to see various artifacts (changing textures too often, or not often enough, etc).
     
  2. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    For a 2k terrain 2k control texture. Not super high, that what Unity allows. Theoretically 4k would be possible on hardware, but I would like to have 8k-16k. On 2k terrain 2k control texture is pretty inaccurate, e.g cannot make a dirt road I have to use a road mesh due to the inaccuracies. The visible range is quite limited, should be an RTS game. I can just change the size of the cluster/texture, thanks for explaining the reason!

    Edit: One of my sand textures in the sand cluster had have a very large UV Scale: 1. I lowered it a bit and the grids are now gone. That was easy.
     
    Last edited: Oct 10, 2017
  3. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Painted for testing Microsplat, no addons. Images with different interpolation contrast. Not bad, nice texture blending.

    bandicam 2017-10-10 13-20-39-731.jpg
     

    Attached Files:

    trilobyteme likes this.
  4. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    I would love this! I'm having a heck of a time converting everything to one naming format.

    Multiple folders to search would be a home run!
     
  5. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Jason,

    I don't know how hard this would be, but if you could allow Batch Import to work for adding textures to the system without deleting the ones that are already there, then we could just import, change the naming conventions, and import other folders, one by one. This way we will stay organized and not have one texture folder with thousands of texture files. The hours this would cut out of our work would make us eternally grateful.

    I love the concept, but due to the renaming of all files and reorganizing I have to do, I'm still a long way from getting to use MegaSplat on my project. I've had it now for over a week and have only been able to try some demo scenes. :(
    I'm looking forward to getting into MegaSplat on my next project and I love the capabilities it has.

    Keep up the great work!

    David
     
  6. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Comment out in TextureArrayConfigEditor.cs at line ~545 the line " cfg.sourceTextures.Clear();". It seems to be that the next import could be added without trouble. Test it before you apply this in your main project!
     
    Last edited: Oct 10, 2017
    dsilverthorn likes this.
  7. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    I'll give it a try on a sample scene. That will be great if it works!

    Thanks for the tip!
     
  8. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Or use "Total Commander" or similar file editor to "Mark" (by pattern matching), then "batch rename" in file menu to rename parts of filenames.
     
  9. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    I'm not sure that will work.

    So .. are you saying if I have textures as:
    001 : cliff_01
    002 : cliff_02
    003 : grass_01
    004 : grass_02
    ...
    060 : sand_03

    I then add a new texture as 061 : cliff_03

    And regenerate clusters, that it'll cluster these together ?
    001 : cliff_01
    002 : cliff_02
    061 : cliff_03


    If so, then that's surely a workable solution (I think), and needs to be documented as such to help users. Many are battling with this. Simply rename the default textures and tell users to use numeric prefixes to force the added textures to the end of the array.
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, it name matches the first part, so 001 and 002 will be in separate clusters. But 001 would be i the first texture array entry and 061 in the last..
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
  12. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I guess the hype for mobile games is not that high anymore. Also, a game for mobile purposes must be simple, like a card game. You don't want to play Fallout 4 on phone.

    I also built a mobile game for phone, were the biggest issues were the texture sizes and shader. Targeted for EGL 2, top down view, no shadow, no fency thing, got 20 fps on samsung note 1. On Android is a game size limitation, if you are over 100 GB, then the user will be warned.

    There are a lot of mobile games on the market, the only chance to make your own game is advertising with at least 25k $.

    However, interesting idea pushing high quality mobile games.
     
  13. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Hello I am interested in your shader but i have a problem. It keeps setting my basemap distance to 0 and i can't find how to disable that. I need that because my lighting will not hit the terrain with basemap distance set to 0. How do i prevent your script from changing basemap distance?
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It doesn't use Unity's basemap system, but rather uses it as a LOD on it's own shaders, so this is all managed to be 0 when that isn't needed (basically, when you enable tessellation or other expensive/close to camera effects, it will disable them in the distance using the basemap optimization, but it doesn't actually use the basemap Unity generates, because it wouldn't match the MicroSplat shader since it doesn't have most of the features MicroSplat does).

    What about your lighting requires basemap distance? Unity's internal lighting system doesn't use this for anything like that..
     
  15. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    I am using Azure sky precomputed GI sky system, I am also using RealTime GI. The lighting is only viewable within the basemap distance. When it is set to 0 no lights on terrain are visible, and when increased the lighting on terrain is only visible within the basemap distance. I am not sure why, I assumed that is a default part of unity engine.The only thing that could effect the lighting in my scene is azure sky.
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I suspect that they are doing something custom with the basemap distance as part of their own LOD system. Unity's lighting system does not do this. You could disable the basemap optimization in the MicroSplatTerrain.cs file.
     
  17. YHS

    YHS

    Joined:
    Aug 10, 2014
    Posts:
    31
    Hi just want let you know that MicroSplat works pretty good for our project with terrain. Texture array saves a lot of drawcalls and MicroSplat it's very easy to use than MegaSplat. Thanks
     
  18. gregop2

    gregop2

    Joined:
    Nov 21, 2015
    Posts:
    4
    Is it normal or expected that I went from 93 fps down to 65 fps when I changed my current set up using standard unity shaders-with 4 textures on my terrain, to Mega Splat?
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MegaSplat is about high texture counts - Unity's shader is going to be much faster on a 4 texture terrain, but get's slower and slower as you add more textures, where as MegaSplat has the same shader cost regardless of how many textures you use, and accesses the same number of textures per pixel regardless of how many are used across the entire terrain. (In contrast, Unity's shader redraws the entire terrain once for every 4 textures you use, which is why it gets slower as you add more textures and is limited to 16 textures max).
     
    ftejada likes this.
  20. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Is there a limit to how many textures can be in a single array? Or a best amount of textures to use per array?

    I want to be sure I build my custom arrays properly for best performance.

    Thanks!
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I believe the hardware limit is 1024, but Megasplat’s indexing system uses 8bit data, so it’s 256 max.

    Size of the array does not affect FPS, only load times and memory use.
     
  22. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Thanks!

    I have some textures that could be 10 or more within the grass category, but didn't want to overload the array, but want to have great variety.
     
  23. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    So I've only recently managed to pick up this project again and your above advice seems to be missing some detail - My terrain material is a Unity Terrain megasplat material set to triplanar world. So far so good. However the mesh patch megasplat material, when set to Terrain shader type, doesn't look right:
    upload_2017-10-15_13-35-47.png

    I assume this is because it shouldn't be Terrain shader type at all and some mesh data Unity Terrains provide isn't there? If I set it to Mesh shader type, I don't know how to set the Control/Params textures used by the Unity Terrain-based megasplat material.

    Thoughts?
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It should be set to mesh for the mesh, since it isn't terrain. Then you use the vertex painter to give it the same texture, and make sure the UV scales are setup the same. After that, you can use the normal blend brush to try to get the normals/tangents to line up. If your doing it on a cube like that, though, it's unlikely that you'll have enough vertex resolution to match the terrain, and the normals will be different in areas where you don't have the resolution..
     
  25. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    The mesh is just the Unity plane primitive for testing. The high resolution patches will be setup and placed at runtime via code, snapped correctly and exposed with the Alpha Hole feature. Given that I have all the data I need in the control texture, it would seem best to me to be able to use the "Terrain" shader type even though it is not really a Unity Terrain, no? Otherwise I'd need to read the control map on to the UVs for the mesh patch, which would be relatively slow.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, if you just need mesh patches that look like the terrain, then you might be able to assign them the terrain material and just fix up the normals/tangents to match.
     
  27. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    Actually I've just realised something - The control texture isn't in world space? This is what you meant by making sure the UVs are scaled correctly? I suppose if I am placing these meshes at runtime I can work that out once as I place them.
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Right, the UVs sampling the control texture will need to line up with the terrain if you are going to use the terrain's material. If you are using a mesh material, then the projected triplanar UVs are fine because the vertices are only used to store the control data..
     
  29. zmaxz

    zmaxz

    Joined:
    Sep 26, 2012
    Posts:
    143
    I use mesh terrain with "Distance Resampling" ,
    but i think this is really weird (low resolution and sharp edges) on the "Resample End".
    how do i fix it ?

    Unity 5.6.3p3 , Megasplat 1.53

    MS4.jpg
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, is it affected by your interpolation contrast? Perhaps distance resampling needs a way to adjust the interpolation contrast used at a distance so you can get softer transitions in the resampling that you'd want up close..
     
  31. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Quick follow up on this:
    Can MicroSplat and MegaSplat be in the same scene or is it one or the other?

    I have MegaSplat but some features of MicroSplat (like the streams) is very appealing. Just wondering if they play well together?
    Thanks!
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, they both work fine in the same project..
     
  33. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Cool!
    I thought so, but wanted to be sure.

    • Getting my hands dirty with MegaSplat now and liking it. I am getting very dark images of the arrays though, I know you've been working on it, so just letting you know. I'm using 5.6 on Windows desktop. I can't tell what the textures are so I am just using the names to assign them. :(

    • I'm also trying out TerrainComposer 2 with 4 terrains and when I converted to MegaSplat only 3 converted and the second one did not, I had to convert the single terrain and could not get the shaders to match. I propably did something wrong or missed a step, I'll have to review your devlogs again for multiple terrains, unless you know what I did from this description.

    • I am also getting strong stitch lines after the conversion that weren't there before. Could this be because they all didn't convert together?

    I was having so much trouble with it that I reverted to the save before I added MegaSplat. I will try again and let you know if I get repeat actions.

    • Is this a glitch or did I do something wrong?

    • Also, if this happens again, is there a way to revert the terrain back to original textures, in case I forget to save before add MegaSplat?

    Thanks!

    David
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MegaSplat doesn't remove the original splat mapping data from the terrain, so if you remove the MegaSplatTerrainManager component and set the material back to Unity's shader, it should all still be there. The dark images in the UI is a known issue with Unity in linear lighting mode on windows- I've attempted more than a few workarounds, but none have really worked. It's pretty annoying. I'm not sure why the 4th terrain would not convert with the others- did you have it selected? everything is based on selection. That said, you can convert the other terrain, then change it's material template on the TerrainManager component to point to the other one and they'll all use the same shader/material. You'd have to show me the stitch lines your talking about - most likely it's a UV scale issue. For instance, if you have your UVs set to scale 33.333 times across the terrain, then they won't line up when the next terrain goes back to a UV of 0,0. You can fix this my making the scale a multiple, or using world space UVs instead of the ones provided by the mesh.
     
  35. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    841
    Thanks!

    I am in linear mode, the weird thing is everything was fine, and then when I started a new scene, they went dark again.

    I appreciate the additional info. I must have unselected one of the terrains and didn't realize it.

    I'll give it a try again tonight. If it happens again, I'll verify the UV settings.
     
  36. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    So far so cool - MicroSplat really does make terrain look good with almost justa click.

    I added a stream spawner but when i run the game it just expands in a perfect circle across the terrain, even uphill - you can see this with the dark circle in the attached image. I tried changing settings like resistance etc but that just slowed things down - eventually the circle just expands.

    Is there a way to make it flow only downhill? Im using unity 5.6.3 patch 4.

    What i want to do is see where rivers would naturally occur so then i can lay down my river meshes on top of that. BTW if anyone know, im also looking for software for Mac that could take a height map and generate where rivers would flow on this.

    Thank you:)




    EDIT: i dont know if this helps troubleshoot but theres a square in the inspector that holds buffer data and its blank when i run the stream - should there be some kind of heightmap etc data there?

     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, the buffer should show the dynamic region where water or lava is present. By chance, is your emitter set to water and you have streams turned off but wetness turned on on your material? Because it looks like wetness spreading over the scene without water, not the lava (though it could be the burn of the lava, I suppose). Do the demo scenes work fine? And is the lava texture assigned to the material (it should assign it by default).

    It certainly shouldn't go uphill with the default parameters - you can adjust the properties to get it to spread like wildfire, but the defaults should just work. Anyway, if you can't figure it out, I'm happy to take a look at the scene and debug it- I tried to get everything in MicroSplat to be very easy to use, so maybe there's some improvements there to be made..
     
    protopop likes this.
  38. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    Thank you:)

    I have Steams and Dynamic flow selected in the shader (screenshot attached if that helps). I tried a new scene and lava but same thing. (in screenshot) But if you say there should be something in the buffer, you mean an image? where my sidebar screenshot shows a blank square is that incorrect? If yes then it must be a conflict with my project maybe. Ill try a brand new project and see if it works.

    I did NOT import the Examples folder from the asset if that makes a difference? I dont really know programming so im just throwing out everything i can think of:)

    Also theres a bug in Unity 5.6.3 patch 4 that prevents some shaders from compiling properly on IOS - there's a patch coming but maybe this is related?

    https://forum.unity.com/threads/iphone-8-8plus-x-support.498078/

    My project is 20gb so i cant share unfortunately.

    But I have to say the sight of lava, even as a circle, spreading aross the terrain is hypnotic:)

    And i tried my new Micro splatted terrain on iPhone 6 and I am super impressed. Just even the core framework made my terrain look a ton better and most importantly is running with great performance. Im kind of re-exploring my terrain and marvelling out how my old faded blends are now these intricate, organic looking blends, and i can see the possibilities with this. I want to pick up more modules now:) Its kind of like Hearthstone - you get this free really fun core, and then its like choosing more candy to pick up the expansions. I think you have made a good business model choice here.

    Ill post again after i test it in a fresh scene



     
  39. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    I tried it in a new project - just terrain and microsplat and it works amazing.

    This is exactly what i was hoping it would do and watching the flow is beautiful.

    It MUST be some conflict ior something in my project file. I know how many things can conflict so its something ill need to track down on my end. Ill try using a fresh terrain in my project file instead of justa new scene and the old terrain - maybe theres something with my terrain?

    Ill post more if i find out anything. in the meantime i can actually make rivers on this terrain, which is the same heightmap, and take an orthograohic photo from the top, and use that as a guide to lay down my rivers. A bit of a work around but ive been looking for something that could do this for a while and even though its a bit buggy inside my project, when it does work like this its really amazing:)

     
  40. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    I found the issue, kind of. It works when im working for a PC build, but if i switch to IOS then i get that circle spreding effect instead. I switched back and forth a few times to make sure.

    I can still use my backup plan for the flows though:) And the core microsplat works in editor in IOS mode no problem. Ill try a few more of the modules - despite this issue overall im super impressed by micro splat.
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Interesting- I'll switch to iOS and see if I can repro tomorrow night. The streams feature relies on a RGBHalf texture, and perhaps that isn't supported on iOS and I have to use a different variant (I have to do this on the switch already). If it isn't supported, I'd bet the terrain would look flat to it, and it would spread across in a circle like you describe, so it's a good bet that's the case.
     
  42. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    @jbooth finally got around to using this on my buildings - dude it's absolutely bananas great job!
     
    WildStyle69 likes this.
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey, so I repro'd this tonight- it seems that when Unity is running in iOS, it imports the terrain descriptor as an 8 bit texture even though it is correctly set to RGBAHalf in the meta file. I filed a ticket about this to see if there's a workaround or bug fix coming, but this will break terrain blending and dynamic stream flows.

    I could add an option to generate this texture at runtime, but it would take a bit of time to generate it at startup (add a few seconds to load). I'll look into adding this for the next patch..
     
    protopop likes this.
  44. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    Nice work:)

    Could i just find the terrain description and change it manually to 16 bits (or whichever) in the inspector panel?

    BTW i used microsplat to find natural river paths, then i used a snapshot of them to lay my own custom rivers in natural grooves found by the microsplat simulation - thank you because that functionality as a seperate software is something i wanted for a long time. Im using Unity 5.2 still and do the other work in 5.6 but when i upgrade i will probably use microsplat streams too because they look really nice flowing over the terrain. Im also still stuck with unity terrain textures for now, so no mircrospat in these river pics, but ive tested the terrain in 5.6 with microsplat and wow it looks good. Ill be upgrading to use it in my main project too soon.


     
    Last edited: Oct 19, 2017
    Akshara and punk like this.
  45. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    How difficult was it to do that, using MegaSplat on your buildings? Did you see a good improvement in performance?
     
  46. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    It wasn't difficult, it took me a few hours to figure out my workflow, but I'm guessing it would be different depending on how your models are set up, I just checked out the example scene and then made up the rest myself.

    Performance depends on what you're doing I'm using this instead of atlasing, the advantages for me is that I don't have to combine all my textures, which for my workflow and given that I'm using tons of tiling textures is much better. Also it's like having the ability to atlas 256 hires textures, so for me it will probably outperform atlasing as much as 2 times probably more and of course look much better.
     
    Last edited: Oct 19, 2017
    WildStyle69 likes this.
  47. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Thanks @punk -- makes sense your comments and sounds good too! Think I'll look into this as well at some point. :)
     
    punk likes this.
  48. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    @jbooth I've got a request if possible and I realize this is not what its intended for
    I'm using the snow effect for moss instead, with a bit of ice as well - it would be really useful if you could put 0,0,0 in for the direction and it would use the surface normal instead, that way I could push the moss through the height map if you get what I mean

    moss.png

    getting some really nice wear effects with this, considering these are all just tiled textures you can create some awesome variation and this is without any painting

    moss2.png
     
    WildStyle69 likes this.
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Can you not just use the second layer and hit fill with a really low brush value to get the desired result? Or do you want to basically use the snow as another layer? You could easily hack out the normalization in the editor script to see if this works.

    Also, there's an option to disable the bottom layers blending- if you turn this on, the bottom layer will only sample a single texture instead of 3, saving you some performance on your buildings..
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unfortunately not= they don't list a 16bpp format in the drop down list, even though it is supported by the platform. I set it in code, but it still turns it into a 8bpp image. I'll try the runtime generation idea soon to verify that the hardware is actually fine with the format and that the big is actually in the importer. Also, it might function perfectly fine on the hardware itself and just be broken in the editor, so I'll see about that as well.
     
    protopop likes this.