Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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

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

  1. ubergeekgames

    ubergeekgames

    Joined:
    Oct 1, 2016
    Posts:
    25
    Is there an example for setting shader parameters in code, and/or an example of properly configured vertex data? My use case is procedural terrain generation, ported from a MonoGame library, so I have full control over all of it - just a bit lost on how to set it all up from scratch!
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    The docs describe the vertex format. Editing material parameters works the same as with any other shader, except for the per-texture properties. Shader configuration should be handled in editor, as there’s no way to dynamically generate a shader at runtime in Unity.
     
  3. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    531
    @JasonBooth Hi Jason this is a bit of a heads up but I'm also wondering if there is a quick easy fix. The texture arrays no longer show the textures due to a message about incorrect texture format :
    Code (CSharp):
    1. Invalid texture format: 12
    2. UnityEngine.Graphics:CopyTexture(Texture, Int32, Int32, Texture, Int32, Int32)
    3. JBooth.MegaSplat.MegaSplatUtilities:DrawTextureSelector(Int32, Texture2DArray, Boolean) (at Assets/MegaSplat/Scripts/Editor/MegaSplatUtilities.cs:109)
    4. SplatArrayShaderGUI:DrawTextureEditor(MaterialEditor, MaterialProperty[], Material, FeatureData) (at Assets/MegaSplat/Scripts/Editor/SplatArrayShaderGUI.cs:290)
    5. SplatArrayShaderGUI:OnGUI(MaterialEditor, MaterialProperty[]) (at Assets/MegaSplat/Scripts/Editor/SplatArrayShaderGUI.cs:966)
    6. UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    "

    all the textures that worked before are now showing as a pale yellow sticky note color. Even your demo scenes. I understand if you want to hold off tackling it just yet because this is from a 2018.3.0b9 beta. I was hoping to dive into the multi-threading with VS Pro & MS early but maybe I'll have to wait a while.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Unity broke Graphics.CopyTexture in 2018.3.0b4 and have not fixed it yet.
     
  5. ubergeekgames

    ubergeekgames

    Joined:
    Oct 1, 2016
    Posts:
    25
    What you mean by shader configuration in the editor? :D I am still being dragged kicking and screaming away from my code-only paradise and into this brave new world of Unity.

    I created a new MegaSplat_procedural shader, named it terrainshader, and set up the splatmaps and projection settings using the MegaSplat procedural example scene's as a guide: https://i.imgur.com/0WuRBiN.png

    In code, I'm creating a new object for each chunk of terrain as needed like this:
    Code (CSharp):
    1. UnityGameObject = new UnityEngine.GameObject("TerrainPatch");
    2. UnityEngine.MeshFilter meshFilter = (UnityEngine.MeshFilter)UnityGameObject.AddComponent(typeof(UnityEngine.MeshFilter));
    3. meshFilter.mesh = new UnityEngine.Mesh();
    4. meshFilter.name = "TerrainPatchMesh";
    5.  
    6. //convert to unity data types
    7. List<UnityEngine.Vector4> mtangents = new List<UnityEngine.Vector4>();
    8. List<UnityEngine.Vector3> mverts = new List<UnityEngine.Vector3>();
    9. List<UnityEngine.Vector2> muvs = new List<UnityEngine.Vector2>();
    10. List<UnityEngine.Vector3> mnormals = new List<UnityEngine.Vector3>();
    11. List<int> mtriangles = new List<int>();
    12. foreach (var v in this.verts)
    13. {
    14.     mverts.Add(new UnityEngine.Vector3(v.position.X, v.position.Y, v.position.Z));
    15.     muvs.Add(new UnityEngine.Vector2(v.texCoord.X, v.texCoord.Y));
    16.     mtangents.Add(new UnityEngine.Vector4(v.tangent.X, v.tangent.Y, v.tangent.Z, -1f));
    17.     mnormals.Add(new UnityEngine.Vector3(v.normal.X, v.normal.Y, v.normal.Z));
    18. }
    19. foreach (var v in m_indices)
    20. {
    21.     mtriangles.Add((int)v);
    22. }
    23.  
    24. meshFilter.mesh.Clear();
    25. meshFilter.mesh.vertices = mverts.ToArray();
    26. meshFilter.mesh.triangles = mtriangles.ToArray();
    27. meshFilter.mesh.uv = muvs.ToArray();
    28. meshFilter.mesh.tangents = mtangents.ToArray();
    29. meshFilter.mesh.normals = mnormals.ToArray();
    30.  
    31. UnityEngine.MeshRenderer renderer = UnityGameObject.AddComponent(typeof(UnityEngine.MeshRenderer)) as UnityEngine.MeshRenderer;
    32. renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
    33. renderer.receiveShadows = true;
    34. renderer.material.shader = UnityEngine.Shader.Find("MegaSplat/terrainshader");
    35.  
    36. UnityEngine.MeshCollider meshCollider = UnityGameObject.AddComponent<UnityEngine.MeshCollider>();
    In game, the shader seems to be getting assigned properly, but it's missing all of the settings when inspected: https://i.imgur.com/KDpDrPz.png
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114

    You'd be better off assigning a material than assigning the shader directly, as then you'll have to assign the texture arrays and such as well. You'll also need to process your vertices to have the filtering information on the vertex color channels of the mesh- this is described in the docs, but basically every face needs exactly one red, one blue, and one green vertex on it. The mesh converter does this to existing meshes, but if you're generating meshes on the fly you'll need to do that yourself. (Note that you can do this in the shader with the preprocess mesh option, but it's going to invoke the geometry shader which is much slower than doing it at mesh generation time - though certainly easier).
     
  7. dlstilts

    dlstilts

    Joined:
    Sep 29, 2017
    Posts:
    30
    New
    @JasonBooth Hi I have a question. It says in the unity store that there are dynamic effects that can be changed at runtime. "streams form, entirely repaint your landscape.. at runtime..." However, I can not find any documentation on this? What I want to do is have the terrain textures change over time, possibly even randomizing the textures and fx so it is never the same configuration as the character moves around. I was thinking there would be a clean way of accessing the terrain, texture, FX values with code to randomize or change there values at runtime. How do I do this? Is there an API? Or another way of doing this? Sorry if I am missing something in the documentation.

    Thanks.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Are you talking MegaSplat or MicroSplat? MicroSplat's streams/lava tech has a dynamic flow system, which allows it to propagate water from emitters across a terrain. MegaSplat has no such system, although there is a runtime painting example which will show you how to efficiently paint the landscape with whatever textures or effect you want.
     
  9. dlstilts

    dlstilts

    Joined:
    Sep 29, 2017
    Posts:
    30
    Ok this is the image where I got the info on the dynamic effects for Megasplat in the asset store. It is very misleading.
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    How so? The runtime example shows you how to do all of this; the snow is entirely dynamic and animatable, and you can raise and lower the water level on the streams as well as paint them at runtime. There are also several weather systems, like Enviro, for instance, which integrate with MegaSplat to use many of these effects with theirs.
     
  11. dlstilts

    dlstilts

    Joined:
    Sep 29, 2017
    Posts:
    30
    Ok I see. Thanks I will look into that.
     
  12. LoboMontana

    LoboMontana

    Joined:
    Dec 19, 2017
    Posts:
    5
    I want to buy this but I am also looking for a 3rd party plugin that will create real height map on meshes based on real height map. So far the only 3rd party plugin that I have found are only made for 3D modeling application software where the brush uses real height maps then when painted on 3d meshes, the height map shows up, then the next step is simply texturing. In the realm of 3d modeling, it gives super realism especially when using Meganscans Quixel makes it even more real.

    I love this software because of the ability to blend anything you want and if it had the power to create real height map when painting, I would buy it even it was $100 because NO ONE in Unity has that power Brush - a simple Displacement Brush. If I was a coder, that would have been the first thing I would have created and wondering why UNITY doesn't have that brush.

    If you add that to your already amazing plugin here, it's a done deal for me.
     
  13. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    36
    Hi, it was actually to fade in and out LOD levels in a custom lod system I will be using as part of my terrain generation system. The only way I know how to do that is by using the alpha on the material. Any suggestions?
    Thanks
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    There's techniques like stippled alpha, but you'd have to add support for something like that yourself..
     
  15. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    170
    anytime soon that microsplat or megasplat would be able to be compatible with HD render pipeline?
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    When they stop breaking them every other month.

    For instance, right now they changed LWRP around again, and I'd like to update MicroSplat's LWRP module to work with, but basically can't. And the new package + unity version thing is a nightmare for support, because now we have version difference to worry about with Unity versions and version differences with packages. So if I update the LWRP package to work with the latest LWRP package, I'll break it for anyone using an older LWRP package, and the new one requires 2018.3 beta, which currently has a bug in Graphics.CopyTexture breaking everything, and would force users who upgrade to have to use a beta.

    So, eventually I'll likely add support for MicroSplat, but not until these things stabilize a lot more. Even out of beta I expect these to be support nightmares.
     
    Kirsche, Aubrey-Falconer and iddqd like this.
  17. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    86
    I would like to report a bug:
    Per-tex detail noise is broken.
    To reproduce: open terrain example scene. Enable detail noise and per-tex detail noise. Open Texture Graph. Create two texture nodes, attach one to top, another to bottom layer. Attach height node to blend input. Change per-tex strength for both texture. One slider is doing nothing, another one is changing strength of both textures.
     
    jbooth likes this.
  18. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    338
    heh id like a fix to that copytexture too. Havn't been hounding ya because I know its just something to wait for unity to fix. But man your batch import has me so spoiled. I have the other 2 big terrain shading tools and its just not the same.
     
  19. totrider

    totrider

    Joined:
    Jul 25, 2014
    Posts:
    12
    I am facing some issues in using megasplat for my project, and I would like to hear your take on it and whether it can be solved.

    First off, context: I started using Megasplat because i ran into the texture limit of Unity's default terrain plate shader, and i was worried that it wont be enough in the long run, so I would rather try and resolve this limitation early rather than later. I needed a shader that could do triplanar projection, handle many textures and be seamless between meshes and terrain plate. For the project I am working on, I am using a mesh for steep cliifs in order to achieve a better look. I know it isn't the most performance friendly approach, but I am confident it will be ok as long as i optimize it down the line.

    Fortunately, Megasplat provide exactly what I need in terms of functionality. My main problem right now though is actually applying the textures to the meshes in question. It seems that the larger or more complex the mesh is, the more it lags when trying to paint textures. When using it on my intended meshes, it feels like I am only getting a few FPS, making it extremely annoying to work with, not to mention time consuming. Seeing as I need to paint a large surface area for each level, this will take waaaay to long time to do.

    Below is an example on how big the mesh for a level is going to be


    Below is a visualization of what I am working with. As you can see, the mesh blends in perfectly with the terrain plate due to triplanar projection and how I go about making my mesh.


    I also ran into some significant color mismatch with the standard Unity shader, as well as the UVfree triplanar shader I was using before megasplat. I cant seem to figure out how to adjust Megasplat to render correctly, so what am I missing? Because if there is no fix for the lag I am experiencing, my backup plan is to just use UVfree for the cliff edges, even though it is more limiting. If the shaders look too differently though, it will create nasty seams, something I should be able to avoid. (red area is standard shader on a plate with specular removed, blue is UVfree, rest is Megasplat on a terrain plate.


    EDIT: forgot to mention I am using Unity 2017.4.3f1
     
  20. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    154
    Hi,

    I picked up your terrain blending package and I can't get it work correctly. It's stretching the terrain texture on vertical sides. Any ideas?

    Thanks
     

    Attached Files:

  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    The vertex painter was written before 32 bit indicted were introduced. As such, it didn’t need to do spacial partitioning of the mesh because there was a 64,000 vertex limit, and brute force was fine. I suggest either breaking up the mesh or turning off 32bit indices. Batching could effectively recombine the meshes later, and you might get better culling with it broken up as well.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Use triplanar texturing at set normal blend to 0. The module runs the terrain shader on the mesh, effectively, and without triplanar the mesh is textured via a top down projection - so it stretches the same as the Unity terrain would if it could go straight up.
     
  23. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    154
    ok I didn't have the triplanar UV module, but I guess I'll pick it up
     
  24. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    154
    So that works! Thanks.

    I do have a suggestion for the blend.
    Do you think it would be possible to add edge scattering via procedural noise or a noise texture to the seam?
     
  25. totrider

    totrider

    Joined:
    Jul 25, 2014
    Posts:
    12
    First off, I assume you mean "turn on 32-bit indices", as I can read that Unity used to be limited to 16-bit which is 65535 vertices, compared to the 4 billion with 32-bit. You make it sound like it is a simple thing to do. By 32bit indices, I assume it references to the vertex indices? I have only an understanding from how mesh vertices are handled in Unity from a small project during my studies, so I am not exactly sure what it is you suggest me to do. In other words, how would I go about turning on 32bit indices? Is it a Unity setting "somewhere" or do I have to edit your scripts in some way? as I am mainly an artist, I definitely need a bit more help in getting this to work.

    So far, it sounds like I need to use a newer version of Unity, 2018.1 at least, in order to even use 32-bit indices in the first place. Is this something you can confirm?

    The main reason why I import them as entire meshes is due to how normals are treated, something I already combated in earlier iterations of my approach to terrain. The only solution I found back then, would have been to bake down all the vertex normal data somehow, and then apply that in Unity post import. Something that sounds way too messy and unnecessary for my taste.

    My late-game plan is to get my programmer to make a script that creates a virtual "grid" that separates the level into "chunks", and then use these chunks to split the mesh into smaller ones that only contain the geometry within that chunk. Naturally, I could just wait with painting the terrain until we get something like that working as I would then be working with smaller meshes, but due to the current circumstances, I cant really rely on him having the time due to his studies, and waiting for an uncertain amount of time also wont really work for me.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    I'm not sure what version they introduced it in- but it's an option on the FBX/Blender/Mesh import options. You want to turn off 32-bit indices and force it to break up the mesh. Keep in mind that having it all in one mesh will be significantly slower for other operations as well, as the whole thing will need to be sent to the GPU and processed even if a single triangle is drawn.
     
  27. totrider

    totrider

    Joined:
    Jul 25, 2014
    Posts:
    12
    Oh, ok, that way. So, I don't think that will be a working solution unfortunately, last time Unity broke up an earlier test mesh that was way higher poly, it split it into 6 separate meshes (I think), but the faces for each mesh was selected seemingly at random. This meant that each mesh had fragmented faces all over the place. Guess I gotta talk to my programmer and see if I can get him to work on it :/.
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Just break it up in your modeling program.
     
  29. zefirozh

    zefirozh

    Joined:
    Jun 18, 2018
    Posts:
    9
    Hello, before I decide to make a purchase of this Asset I would like to know this gonna fullfill my purpose. I'm working on Mobile platform and I want to make my model look more realistic. For exsample if I would like to add some stain or blood shed on my house model to make it look old and creeppy can I use your asset to do this kind of stuffs. It like the same idea of adding a decal on model. If it can fit my need I'm sure to purchase this Asset ASAP ( For Cyber Week Mega Sale Why not!!! )

    Thank you for your answer.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    It's a splat map shader, not a decal system- so it depends on what you want. With a decal system you can rotate and place textures onto a mesh or object- a splat map system is more like continuous blending between textures- but they all have the same alignment, etc..
     
  31. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    11
    Probably some bugs or I am doing something wrong.

    Vertex painter:
    Show wireframe does not toggle wireframe, but orange selection outline. Shortcut CTRL+W does not work for me, only ESC key for activating, and CTRL+V.
    Other things in screenshot.

    Unity 2018.2.16f1

    EDIT1: "L" key is switching only between auto and top layer
     

    Attached Files:

    Last edited: Dec 2, 2018
  32. firefly9000

    firefly9000

    Joined:
    Dec 7, 2016
    Posts:
    7
    Quick question: We generate a Unity terrain on startup from a height map. All of our terrain is built procedurally from maps (there is no painting on the surface). Is Megasplat able to create that terrain and place the grass, rocks etc... based on maps alone, no painting on the surface?

    I guess our basic question is can we use its features to generate terrain programmatically? From what I've read it seems to but we just want to be sure. Thank you!
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    It has runtime procedural mode that works on mesh terrains (not unity terrains) to automatically texture the terrain based on projections. There's also a shader graph like system which is designed for edit time, but you could likely adapt it's output (it writes out shaders) to do the work at runtime. You can also write your own procedural texturing system to output it's splat map format (which is different than Unity's).

    MegaSplat does not place vegetation, for something like that I'd recommend Vegetation Studio, which places things based on rules assigned to each terrain texture.
     
  34. zefirozh

    zefirozh

    Joined:
    Jun 18, 2018
    Posts:
    9
    Already bought it, but I only have 32 PBR textures Where are the rest?

    Edit : It's my misunderstanding, I look at cluster that already mix all of 64 textures.
     
    Last edited: Dec 11, 2018
  35. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    531
    @JasonBooth Unity stated that they have fixed the CopyTexture for compressed textures (1094698) in V2018.30f0 and testing it the textures now seem to show but my landscape is all faded looking, does something need to be updated or the texture array recreated? upload_2018-12-12_0-15-26.png
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Try pressing update on the config?
     
  37. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    531
    Just tried that, everything turns Grey and I noticed the error:
    Unable to parse file Assets/Voxeland_5_With_MegaSplat/MegaSplat_Voxeland_Plus_Models_Standard_Tex_settings test_normSAO_tarray.asset: [Control characters are not allowed] at line 4
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr) So is this error about the characters I used to name the array? I've never had that with any previous Unity version.
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,114
    Seems like it- some funky characters in there?
     
  39. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    531
    It seems like the error was a matter of empty characters in the name so I just added an underscore and the message was gone but even after trying to update the config, it still looks faded and when trying to load your scenes I received similar error:
    Unable to parse file
    Code (CSharp):
    1. Assets/MegaSplat/Examples/Textures/Arrays/MegaSplat_Example_normSAO_tarray.asset: [Control characters are not allowed] at line 4
    2. UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    Well this is all on the first Release Candidate, I hope Unity can address this before getting out of Beta if the error is on their end.

    Edit: Ok found the issue. It was in the shader - the "Emission/metallic array" Not sure why it's not working, perhaps it needs to be compatible with the new Unity Release? I've updated project to the new release, my settings worked with 2018.2 so the Emission/metallic array config may need a look over.
     
    Last edited: Dec 14, 2018 at 1:47 AM
  40. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    184
    I just upgraded my project to 2018.3 and tried checking the new Draw Instanced box on my terrain, but it caused my terrain to essentially disappear, with a bunch of random bugged out triangles flying around.

    Tried recompiling the shader by turning a checkbox on/off and just Updated the texture list, but no luck.

    Not getting any console errors either.
     
  41. Mercat

    Mercat

    Joined:
    Jun 4, 2018
    Posts:
    1
    Hi, quick question, why is it that when I paint the same texture into both top and bottom layers, smoothness varies depending on blend factor?
    Capture.JPG
    Left side has blend target set to 0 (bottom), right to 1 (top), looking at smoothness in the Scene View.
    Add second UV is disabled in the Shader Compiler.
     
  42. Kris392001

    Kris392001

    Joined:
    May 8, 2018
    Posts:
    70
    I had the same thing. Megasplat has not been updated yet unlike Microsplat. Jason said on Discord General discussion that it should be this week when I mentioned the same problem.
     
    Exbleative likes this.