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
    1. Press the “Save” button in the painting tool
    2. You have to press update on the config. Note they the terrain itself only stores indexes and doesn’t know anything about clusters, so you may find painted textures change if the array changes.
    3. Can you post the error? I’ll test when I get back home tomorrow.
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    1. MicroSplat has the easiest blending to use. RTP is the only other pack I know of that had a mesh->terrain blending tool; harder to use that MicroSplat, but has some advantages too.

    2. The MegaSplat technique stores a texture index on each vertex. The textures assigned to each vertex are sampled and height blended together. But this means you can’t have soft blends that you paint, because at each vertex only a single texture index is stored. So to make a soft blend, a second texture index can be stored on each vertex along with a blend amount. So both layers are computed, and then height blended together based on the blend weight.
    In terms of brushing, you can usually put it on auto and not think about the layers at all. Auto will paint on which ever later had the least weight..
     
  3. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    1. Yes, we clicked save. Figured it out though - it takes a while after opening the scene for the Megasplat changes to load in. Whew!
    2. Yes, we clicked update. Any clusters added/removed/renamed after the first time of clicking update seem to be ignored by the terrain paint window. Repro steps: Select an existing texture array config file. Rename any cluster. Click update. When complete, open terrain painter. Select the texture array config file. Check for renamed cluster - it is the old name.
    3. This one isn't really a big deal as there is a workaround by adding any texture back and then removing it from the broken cluster first. Repro steps: Open a texture array config file. Select none for a texture entry that exists in a cluster. Open that cluster. Console throws an error and the UI is no longer rendered past where the removed texture would have been.

    Here is the error:
    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.EditorGUI.DrawPreviewTextureInternal (Rect position, UnityEngine.Texture image, UnityEngine.Material mat, ScaleMode scaleMode, Single imageAspect) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:5479)
    UnityEditor.EditorGUI.DrawPreviewTexture (Rect position, UnityEngine.Texture image, UnityEngine.Material mat, ScaleMode scaleMode, Single imageAspect) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIBindings.gen.cs:910)
    UnityEditor.EditorGUI.DrawPreviewTexture (Rect position, UnityEngine.Texture image) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIBindings.gen.cs:905)
    JBooth.MegaSplat.TextureClusterExtensions.DrawLayer (JBooth.MegaSplat.TextureCluster cluster, System.String label, JBooth.MegaSplat.TextureArrayConfig config, Boolean drawRollup) (at Assets/Plugins/MegaSplat/Scripts/Editor/TextureClusterExtensions.cs:78)
    JBooth.MegaSplat.TextureArrayConfig.DrawLibraryGUI () (at Assets/Plugins/MegaSplat/Scripts/Editor/TextureArrayConfig.cs:356)
    JBooth.MegaSplat.TextureArrayConfigEditor.OnInspectorGUI () (at Assets/Plugins/MegaSplat/Scripts/Editor/TextureArrayConfigEditor.cs:550)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1253)
    UnityEngine.GUIUtilityProcessEvent(Int32, IntPtr)
     
    jbooth likes this.
  4. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Is microsplat blending module compatible with megasplat? Because I need something to work with megasplat and terrain (native terrain, not mesh terrain). Also is megasplat suppose to blend mesh-terrain pairs? If not, what's "blend w/ Terrain" option for?
     
    Last edited: May 6, 2018
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSlat modules do not work with MegaSplat. You can do terrain/mesh blending in MegaSplat, but it’s not a simple process- you can find one of the 50 posts in this thread where I’ve covered why I can’t use the MicroSplat technique in MegaSplat, etc.
     
  6. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    OK, so how do I blend mesh with terrain, manual does not cover this process (for terrains). I can't do (3) as painting normals on the mesh with just terrain set in options gives null reference exceptions .

    EDIT:
    Also: upon browsing the thread, I came across this post of yours [Released] MegaSplat, a 256 texture splat mapping system..
    The default height channel is green and all of your height maps are sRGB (in opposite to AO and smoothness maps, they are non sRGB). Shouldn't the height maps be switch to non-sRGB as well?
     
    Last edited: May 6, 2018
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I'll check the project when I get home, but they should all be linear..
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Use the world space projection option instead of the local space projection.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    This is covered in this thread more than a few times, and an object example is included (Which is mesh->mesh, but the basic issue is the same). To make an object look like it's blended you have to get the data near the seems to:

    - Have the same UV space
    - The same texturing
    - Have the same normals and tangents

    The easiest way to do this is to use a triplanar projection on both objects, and make sure all material settings are the same between the terrain and mesh shader, such that UVs will line up between both objects. Then paint the same texture along the seem, and finally use the normal brush to average the normals towards the terrain normals so that the lighting is similar between both surfaces. Note that this is not perfect, because it's unlikely your vertex topology matches the terrain, but you can usually get it very close. This is obviously a lot more finicky than the MicroSplat technique, where you basically add a component to an object and your done, but that technique cannot work for the range of stuff MegaSplat supports..
     
  10. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Once again, this part is not working. Screenshot
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Pushed this to the UAS tonight- should be out in a day or two..

    1.64
    - Support for 32 bit index counts in Unity 2017.3+ allowing for meshes over 65535 vertices
    - Fix to null reference error when texture in a cluster is null
    - Fix to NormalBlendBursh when working on terrains
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I just tested this, and it seems to work fine- what issue are you seeing?
     
  13. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Tessellation off, ramp lighting works:


    Tessellation on, smooth lighting is being used instead. Ramp texture is ignored:
     
  14. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Meanwhile I came across another bug:
    changing the name of the cluster causes the given cluster to paint with some random textures(s) i.e. if I change name of the cobblestone cluster to "changed", name of the brush won't be updated in texture painter window and the brush will now paint with cliff texture. Texture graph seems to be working fine though. texlist.asset entries looks fine also.
     
  15. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    I have had MegaSplat and 2018.1.0f2 working fine. But earlier, I got the small turning wheel icon in the lower right of the interface, where messages post about what's updating with lighting, etc., and clicking on it, could see it was this file, which was also generating this warning, but not an error, as such:

    Assets/MegaSplat/Scripts/Editor/TextureGraph/Utilities/EditorLoadingControl.cs(45,22): warning CS0618: `UnityEditor.EditorApplication.hierarchyWindowChanged' is obsolete: `Use EditorApplication.hierarchyChanged'

    I have not been able to stop this apparent refreshing processing, and at an interval of a few seconds, the icon stops turning and Unity locks up, again for a few seconds, then round again, and again, and so on.

    Any idea where I can look to fix this please? I have reimported MegaSplat, but it's the same.
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's a warning about a depreciated interface, which will need to be #if'd around to prevent unity from throwing those warnings, but it shouldn't have any affect on anything, since the old interface still works..
     
  17. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Thanks. I didn't think it should causing such a hassle, and probably it's something else. Oh well. I have returned to 2017.3 for now, with this project. No idea what was throwing 2018.1, but it seemed like a cascade of grief from first one thing, then another. The refresh update was reporting updating reflection probes, but it kept doing it, then this with MegaSplat. Life's too short, so I backtracked :D
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Most likely deleting your library folder before/after upgrading was required- they get corrupted often, regardless of what assets you have installed..
     
    JBT27 likes this.
  19. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Another bug, not critical one tough:

    Top Layer/Bottom Layer labels in texture graph are switched.


     
  20. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Ah, I didn't know that - thank you. I'm going to try that now, rather than walk away without an answer. 2018.1 has some goodies I wanted to try with my work, so am keen to resolve this.
     
  21. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Many thanks for adding 32bit indexing. Unfortunately the Mesh Converter seems to be wreaking havoc on my meshes.



    On the left is the original mesh, with 199,378 vertices On the right is what it looks like after going through the converter.
    I wondered if the hole might be throwing it, so did another:



    The right is the original, at 145,711 vertices, and on the left is the converted _splat mesh.

    I tried a couple of much smaller meshes, around 3,000 to 5,000 vertices, but they converted fine, as usual.
     
  22. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Hello again, can we change a texture tint color or setting how dark it is, tint color (Like standard material) or something like that inside the kit without modifying from third party program?
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's no per-texture tint in MegaSplat right now..
     
  24. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    Hi Jason!

    Love your emails.

    Are your products Virtual Reality (VR) rendering compatible? In other words, with Stereoscopic depth perception, will there be any 'sparkles' or tearing between the two different POV's?

    Also, I read up and I noticed that MicroSplat won't do runtime procedurals. I have a situation where someone sprays some water on a lawn, and the grass will turn greener (and longer). The grass itself is one thing, but I'd like the underlying texture of the terrain go from brown to greed. I would need MegaSplat for that?

    Thanks for the great products,

    == John ==
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat is fully VR compatible- it's a surface shader, so it inherits all the lighting and VR semantics Unity supports. Not sure what you mean by not doing runtime procedurals- it's a terrain shader, so if you change the texture choices at runtime, it will respond the same as any terrain shader would.
     
  26. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    Ah, in Microsplat vs. Megasplat it mentions:

    I should use MegaSplat if:
    ... snip
    - I need runtime procedural texturing

    Maybe I got confused. I hear you about the texture choices - so basically there would be a map later, that would expose the 'green' as you water the lawn; I'd do a hit check with the water and if the terrain is hit, write to the bitmap, and the shader would then automatically texture it, right? (Thinking at a high level, haven't started coding yet).

    Thanks for the confirmation on VR!

    == John ==
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Essentially, yes- either system supports dynamic changing of the texture data.. Runtime Procedural Texturing is more about choosing textures based on height/slope at runtime, for dynamic terrains, etc..
     
  28. jgwinner

    jgwinner

    Joined:
    Dec 21, 2016
    Posts:
    19
    Got it - thanks.

    I'd suggest adding (Dynamic terrains) after the "I need runtime procedural texturing" then for clarity.

    == John ==
     
  29. NightcoreLV

    NightcoreLV

    Joined:
    Feb 26, 2014
    Posts:
    34
    hi,is there any plan to add playmaker integration?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, but what would you even need that for?
     
  31. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    I'll ask again just to be sure. Height maps should not have sRGB correction like the other ones and I should uncheck them manually?
     
    Last edited: May 12, 2018
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, the only thing which should have sRGB checked is diffuse/albedo/color textures. Anything which is not a color should be linear.
     
  33. Hurtful-Toad

    Hurtful-Toad

    Joined:
    Feb 18, 2016
    Posts:
    20
    I think this is a simple question. I've got megasplat working very well on a vast procedural generated voxel terrain using the triplanar material. But I'm unsure where to assign the wall, floor, texture and strength settings. Also, at the borders where it switches textures, there is a band that iterates through a bunch of textures in very fine bands. It looks like it's trying to do a nice border blend but using the wrong textures. Thanks for the awesome assets!

    upload_2018-5-12_9-19-32.png
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Read the documentation in vertex format; you need to stamp some data on the mesh to fix the bands. For runtime procedural texturing, you can switch the layers texturing from painted to procedural.
     
  35. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    What does "UV offset" do? I hoped maybe it changes texture center, but it just smears it.

     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It moves the UVs, in triplanar mode there's a value for each axis.
     
  37. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    It's bugged then, texture is getting blurred instead of moving (see 2nd picture). Steps to reproduce:

    1. open mesh scene
    2. select the boulder
    3. change mode to triplanal local
    4. fill the bottom layer with first texture
    5. change triplanar uv scale to 0.0004
    6. change texture scale and 2nd texture scale to 100
    7. select per tex scale tickbox
    8. set scale range to 100
    9. move uv scale slider to 1
    10. set uv offset X to 100
     
  38. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Hi Jason,

    I have bought MegaSplat, I was just wondering, does MegaSplat have every effect that Micro Splat has as extensions?
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No.. They are different product lines, with different feature sets/advantages/disadvantages..

    I'll take a look; perhaps the combination of various scaling options is skewing it somehow?
     
  40. NightcoreLV

    NightcoreLV

    Joined:
    Feb 26, 2014
    Posts:
    34
    i`m not that good with coding,playmaker is a good solution for me and if playmaker can handle the texture and dynamic changes at runtime, it will be awesome
     
  41. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Bumping this post just in case it was missed.
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not missed, just haven't had time to look at it yet..
     
    pixlweaver likes this.
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    What was your previous version? The format of the texture arrays was changed with the 1.5 version, so if it was before then, you'll have to recreate the texture arrays with the new system. You'll also want to change an option on the shaders you've generated to force them to be recompiled with the latest code..
     
  44. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Hi,
    I've a performance question this time: does it make sense to pack N textures of N different objects into a texture array and use a few of megasplat shader materials instead of N standard shaders? Objects with additional vertex streams can't be batched.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It depends- I've seen people do this with entire levels to reduce draw call counts, but it's only a savings if that's your bottleneck. Always profile first and know what your issue is.

    You can batch stuff that's vertex painted, you just have to bake our the stream to a mesh first. There's a utility for doing this, or a batch one you can insert into your build pipeline which will output everything you have painted into a single asset file.
     
  46. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Actually I have already done some testing, but the results were not to my likings, so I thought maybe theory will shine a light on this.
    Scene was simple: about 100 objects, each with 1-2 materials, directional light with shadows, terrain, global illumination, deferred mode camera. All of the objects were static. Megasplat version had mesh data baked. What's odd, megasplat actually increased draw calls instead of decreasing it, but mostly reduced set passes and total batches. Still, a total fps according to stat window was about 10% greater when using MS.
    Unfortunately, in the real scene, megasplat have not helped much if at all: fps increased by about 1, where 40-50 was the total amount. Which made me wonder whether converting the rest of the materials to MS makes sense. Or maybe there's something I'm not aware of.

    I know of the stream baking tool, and I've obviously used it. Yet profiler claims that "objects with additional vertex streams cannot be dynamically batched" on certain meshes processed by the said utility.

    Also I'm wondering: baking tool creates a different new mesh for every object. If all object with the same geometry are painted the same, should I manually set the same mesh to all of them?
     
  47. jebediahh

    jebediahh

    Joined:
    Feb 20, 2017
    Posts:
    26
    Hello - I'm wondering if it's possible to retrieve the name or index the texture cluster that exists at a given position (coordinates) on a terrain.
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There don't need a vertex instance stream on those objects if you baked them out and replaced the mesh, because the data is in the actual mesh now. That's likely why your draw count increased, because having the stream on there caused them to be not batched.

    If several instances have the same paintjob, just use one mesh for all of them and save some memory.

    Modern PC's with modern drivers (vulcan, dx12, metal) are able to handle quite a few draw calls. One of the major things those APIs did was to allow engines to get closer to the metal and reduce the cost of draw calls, so it's becoming less of an issue each day. The thing with optimizing anything is that it's always relative to the data you are working with, so the common rhetoric about "reduce poly count", "reduce texture size", "draw calls", etc, is really dependent on your scene, and often a gross simplification of the problem that often end of wasting a lot of dev time and makes games look worse.
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, there is a system for that described in the documentation, which will give you the texture name of whatever texture is the most dominant on the pixel.
     
  50. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Eh, and here goes my hopes for the hidden magical "make my game faster" button.
    Just kidding; my problem is that I try to pack too many goodies, so now I try to save every single frame I can. And since I'm not really found of atlases, MS seemed like a good alternative.

    Let's forget about those vertex streams. Yesterday I could swear there was tons of them in the frame debuger; today there is none. There is something very wrong with either profiler or me.
    The higher draw calls issues is however still there. But I have to specify one thing: by "draw calls amount" I meant the number displayed in Profiler > rendering section, not the number of entries in frame debuger . Maybe that is my mistake: the profiler > rendering amount is not only few times higher than frame debuger, but also changes on every play (the test scene is motionless of course). Unfortunately, I can find no information why those two values differs.