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
    Not sure if you're talking MegaSplat or MicroSplat, but the alpha hole feature in both is designed to be efficient by discarding pixels which are cut out- not using alpha. MegaSplat has ways to create alpha shaders, but that's generally not what you want for terrains, since it means drawing the entire terrain as alpha, which is slow, leads to sorting areas, means no shadows, etc..
     
  2. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    hi @jbooth

    A question that I do not know if this can be done.

    You can have, for example, a texture that only contains small sautéed stones, that the background is transparent (that is to say that in the texture only stones without soil can be seen).
    Add this texture (only stones with transparent background) to the MegaSplat array and when we paint with a grass texture for example, change the cluster and paint with the texture of stones with transparent background, so that the two textures can be seen the time (the texture of grass and stones) ????

    I do not know if I managed to explain ... If you can not, it could be a great feature to include in MegaSplat

    Other thing
    Can the tessellation be made by texture instead of global to all?
    Thus each texture could carry its own tessellation data without influencing the others.

    I do not know if this for performance would be better ... that is, that in the scene there are only some textures that have the tessellation activated instead of all.

    regards
     
  3. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Cool, thanks, this is for Microsplat. Am I able to add an alpha channel texture to paint on that would give me the soft blended edge effect or would this result in the same performance problems you mentioned?
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    All the resolves in MegaSplat are done via height resolve, so if the stones are higher than the grass in the height map and you're using a two layer shader, you can paint the stone texture on another layer at an opacity that causes the stones to come up from the grass. The cluster brushes are a nice way to do this as well, as you can blend two clusters together to get the effect that you want at a specific weight.

    It's possible, but would not help performance and in some cases even hurt it. The cost of tessellation is a) turning on the extra stages for the shader that do tessellation (regardless of if you generate more vertices or not) and b) micro shading issues that happen when tessellation is too great, and small triangles hurt the shading performance. Contrary to popular belief, GPU's chew through vertices like you wouldn't believe; the average vertex takes far less to process than a pixel on the screen, and on a 1080p screen you are processing at least 2 million pixels (more likely many times this number). The best way to reduce tessellation cost is to switch to a non-tessellated shader in the distance. In MicroSplat, I am able to do this automatically for the user such that at the end of the tessellation distance a different shader is used, and it makes a sizable difference.
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat doesn't have the ability to use alpha textures- and it really shouldn't, because it's not just performance problems you'll run into when using alpha on terrain, but sorting issues (why does the hill in the distance draw over the hill in front of me?), shadows not working (alpha materials do not cast shadows), etc, etc. There's really no good use case for using alpha on a Unity Terrain.
     
  6. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @jbooth - Does this address the issue on TriPlanar with Meshes though, not just the Terrain mode? Because as I have tried to illustrate over my posts, normal does not look correct in triplanar and Mesh mode - tangents or not. Looking at the updated file list it looks like the issue was addressed for Terrain but not Mesh variants.
     
    Last edited: Dec 18, 2017
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    My understanding of your issue was that the voxel software you were using was not generating tangents for the mesh at all- that is not something I'm going to attempt to fix in the shader, because tangents are baked into a mesh for a reason. Or am I missing something in your posts?
     
  8. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @jbooth - It isn't my package, as I was trying to show you a few posts ago, look at your own example. It doesn't look right if you run a comparison. Simply go into your terrain with the Procedural shader example. Set it to Mesh and TriPlanar with your array. Look at it - while looking at it switch it to UV Project Axis. The difference in Normal is apparent and if it isn't spin it and look at it at different angles - the same thing happens that the other users was pointing out (I just didnt make a video of it). In my project, I can stand in between two hills, on the right side I have normal's, on the left sides its almost like I have none. I am generating Tangents in the voxel engine, but I can also do it at the shader level. Tangents or not, it doesn't look right compared to your other shader modes like Project UV Axis set to world. The textures line up the same, the PBR is the same, the Normal is incorrect. Also, if Parallax isn't going to work for TriPlanar you should remove it for that variant IMO - wasted time trying to get that to work when its a broken feature and not listed as such. Since Parallax works fine in two of my other TriPlanar shader packages, it had never occurred to me that it was simply disabled in Triplanar for MegaSplat because it wasn't implemented on that variant.
     
    Last edited: Dec 18, 2017
  9. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Ok I have example Screenies now. So I used the MegaSplat procedural example. I have the Project Tangent option added to the shader so that both TriPlanar and UV Project Axis work correctly and also project tangents. Material options are captured in the right side - identical settings besides TriPlanar or UV Project Axis, yet the TriPlanar Normal is almost nonexistent at certain angles, and subdued in best case scenarios. Take a look - its even more apparent on textures that are real rocky or bumpy with lots of detail.

    TriPlanar - normal barely there


    UV Project Axis - normal looking normal


    TriPlanar (moved light) - subdued normal


    UV Project Axis (moved light) Awesome normals


    If you do decide to fix this issue, can you please add the Project Tangents option to TriPlanar? I just added it to ProjectUV's at the bottom so that PRojectUV's still works but so does TriPlanar. I only ask because I update the shader regularly as you do stuff and I will have to keep adding the custom code back in (and it will benefit others).

    BTW, Megasplat is live in Astral Terra now as of last week (on Steam). We want to do new screenshots this week for the store, would be great to have this looking its best.
     
    Last edited: Dec 18, 2017
    ftejada likes this.
  10. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Thanks for the tips.

    When you say tesselation in the MicroSplat distance, I guess it's the same as putting the tessellation feature with "Distance" in MegaSplat, right?

    Is it something exclusive to MicroSplat?

    regards
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, I just spent 20min fooling around in the Procedural example w/ triplanar on and the normals appear to be fine for me. But I don't discount missing some nuance, sometimes normal errors can be kind of hard to see, or one of the projections is incorrect int some way. I do notice that if you have the interpolation contrast low enough the normals tend to wash out from the averaging of the three projections, but that is to be expected unless you go to height based blending.

    When I have a few moments, I'll setup a test scene on some test geometry to double check the projections again..
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, in MicroSplat I only used distance based tessellation. It tends to look more stable than edge based. Since MicroSplat only works on Unity Terrains, and is written entirely in a surface shader, I'm able to use the base map feature of Unity's terrain as a LOD on the main shader and do this automatically.
     
    ftejada likes this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Interesting. I'll send you a PM, I have an idea I'd like to test..
     
  14. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Do you plan to include that automatic feature based on Lods for MegaSplat, even if it only applies to the terrains???

    Regards
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I actually tried to port it back at once point- however, since I'm forced to use vertex/fragment shaders for the MegaSplat technique (surface shaders have some limitations), switching to surface shaders in the distance created a very slight difference in lighting so it wasn't seamless.
     
  16. zibas

    zibas

    Joined:
    Sep 15, 2010
    Posts:
    31
    Sorry if you're already aware of this, or I've missed something obvious. Tested the 2017.3 release today and I'm getting a rainbow hex grid.
     

    Attached Files:

  17. zibas

    zibas

    Joined:
    Sep 15, 2010
    Posts:
    31
    I probed a little farther. Just changing any setting on the material rebuilt the shader and brought it back to life.
     
  18. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    I can't seem to get the emission layer working to project light, it does appear to glow a bit but is not a light source;
    scenario, lava in a dark cave. Is this something that should work?
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Should; it would be highly dependent of your lighting setup supporting that..
     
  20. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Yeah as far as i can tell it should. This may point to some mistake i've made. megasplat-emission.jpg
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    What color is the metal texture? It kind of looks like the texture has a metallic value of 1.
     
  22. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    I didn't actually add a metal texture. Is that a problem? :)
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, it shouldn't be- but you could try adding a pure black texture and see if that makes a difference- there's a chance I didn't default it to 0 correctly..
     
  24. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    That looks to have helped somewhat. Still not projecting light for some reason. Terrain objects are in chunks and set to static so i should not need light probes as far as i know. I'll have to experiment /read up a bit more.
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If the idea is that they emit light onto the surrounding area, then a GI solution of some kind is needed. Emissive just adds unlit color into the shader result, or emissive color into the gBuffer when running in deferred- nothing propagates that to nearby surfaces without some kind of GI solution, be that enlighten/progressive lightmapper/etc..
     
  26. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Ahh, thanks. I read up on this and it looks like it doesn't work for procedural mesh anyway. I need to roll my own system and color tint megasplat. I cant see any tint options built in though. i'd need to re purpose some of the other values i'm not using (UV1.W, UV3.Y, UV3.Z) as RGB if thats possible.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There are fully runtime systems like SEGI which will work with procedurals, but they aren't cheap. Have you considered just using lots of well placed lights? If your running deferred, it can be a reasonable way to create this type of lighting..
     
  28. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Hi @jbooth -- I've been using MegaSplat for a while now and really loving it.. such a cool asset. :) I've been on the pre new packer format version still, as last time I tried upgrading to the new version I had problems with texture quality and some other anomalies.

    This week I've come back to try again, as I'd love to take advantage of the new features and performance improvements you've made with v1.61, unfortunately I'm still hitting some problems with the latest version after upgrading. I'll try to explain the issues I'm seeing below.

    Note: I deleted the whole MegaSplat folder and installed the new asset. Then rebuilt the texture arrays with the same images in the new format, all same array indexes of course. After that was done changed the setting on the materials to update / rebuild the shaders.

    1) I'm using tessellation and with 'Tessellate Shadow Pass' enabled am now getting herring-bone styles lines across the terrain, which looks pretty bad in-game (see screenshot below).

    IMG-MegaSplat-Shadow-Issue-21-Dec-2017-1.png

    2) The blend between textures is very different. As per my previous post on this topic ( https://forum.unity.com/threads/rel...at-mapping-system.441329/page-60#post-3238529 ) .. the textures on blends no longer line up with level geometry (see screenshot below).

    IMG-MegaSplat-Texture-Blend-Issue-21-Dec-2017-1.png

    3) The tessellation is now different. Grass on hidden meshes that used to align with the terrain no longer aligns (see screenshot below).

    IMG-MegaSplat-Tesselation-Issue-21-Dec-2017-1.png
     
  29. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Yeah, not my preferred option at this point. I may come back to them if all else fails. I take it that vert tinting is not an option with megasplat? I was hoping to try it via megasplat_custom.cginc and had a play with coloring there but i'm not sure the various UVs/data are accessible in CustomMegaSplatFunction_Final to allow matching verts to colors.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Right now the raw app data is not exposed (mostly because it's different between some of the shaders). You could modify the source fragment files, but the biggest issue is that there's no great place to put 3 values- you could pack them into a single float in a UV I suppose, but there is no support for some kind of packed float as color format in the vertex painter (though it could be added via a custom brush).
     
  31. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    Ahh ok. I'm doing everything at runtime so i'm not sure about brushes. i can pack the data into the uv at runtime, i just need the shader to interpret it.
     
  32. ronaldomoon

    ronaldomoon

    Joined:
    Jan 24, 2014
    Posts:
    87
    Can the water/lava flow in either MegaSplat or MicroSplat be used to fill up caves and whatnot like Minecraft? I know if would probably require some extra work on my part but it'd be worth it. I just want to know how feasible it is. Since it always flows down and forward I'm thinking maybe some code could be generated to spawn water blocks below the flow and fill up the spaces below while always pushing the flow to the top of the water blocks. I REALLY wanna use MapMagic + Voxel land to generate my terrain but I haven't come up with a sure fire solution to the water/lava issue so I'm kinda hesitant in regard to Voxelland.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, it's actually rendered as part of the terrain, and doesn't modify the terrain geometry at all - so there's no way to 'fill things' with it.
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The only thing I can think of is that somehow the height data is coming out different between the versions as the actual blending code hasn't changed in a long time, do your height textures have sRGB on by chance? Otherwise, the packing is the same for the diffuse+height map array in both versions, only the arrangement of the normal/smooth/ao data was changed. One thing you could try is copying the actual texture arrays (not the configs) from the old version and see if they render the same as they always did or differently - this would tell us if the difference is coming from the texture data or the shader code.

    If you can build a small example scene I'm happy to take a look as well. One thought on the first issue is that these lines are coming from a shadow bias issue- do they persist if you turn off shadows?
     
  35. magic9cube

    magic9cube

    Joined:
    Jan 30, 2014
    Posts:
    58
    If possible, could you give me a pointer or some direction as to how i'd go about exposing any of those extra values via the fragments? If i can get it into the SplatInput struct used with CustomMegaSplatFunction_Final i think i'd be set. I also understand this is not exactly a supported feature.
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It kind of depends on which pathways your using (Unity Terrain vs. Mesh, tessellated or un-tessellated). If your doing it in an untessellated shader, you'd read the data from the vertex in the vert function - most likely unpacking a RGB from one UV channel, and add it to the Input structure, which will take it into the pixel shader for you. Once in the pixel shader, you could add it to the SplatInput structure so it gets passed around everywhere else too, and modify the resulting Albedo value at the end.
     
  37. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Thanks man!

    I'm pretty sure the old texture arrays work just fine, so it seems to be image packing / format related I guess, will double-check again tonight.

    The weird lines is definitely shadow related, so I'll look further into that. Weird that it only happens when I turn on 'Tessellate Shadow Pass'.
     
  38. ronaldomoon

    ronaldomoon

    Joined:
    Jan 24, 2014
    Posts:
    87
    Bummer. Oh, well. Thanks for the quick response!
     
  39. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    So sRGB is on for the height textures, I disabled it and the blend is working. I'm confused though as your example textures for height all have sRGB ticked?

    The lines issue is shadow related for sure. I loaded the old texture arrays and the problem was still there. Turning off shadows the problem goes away, also disabling 'Tessellate Shadow Pass'. Also tried playing with bias settings but that doesn't affect it. Increasing shadow resolution the lines get closer together with the resolution.
     
  40. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Something else that looks different if the clarity of textures, as they get further away looks all blurry. Then when I get closer they come into focus. Never noticed that with previous versions, always seems crisp / clean in this regard.
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, textures are sRGB by default in Unity- an sRGB texture has a gamma curve applied to it's color channels, but alpha channels are always treated as linear. So if you happen to have your height data in the alpha channel (which I think my examples might?) then it would be linear, but if you have your height data in a color channel, it would be gamma corrected by default, which is incorrect.

    Disabling 'tessellate shadow pass' fixes the issue because then the shadow pass is using the original geometry, which is way below the tessellated surface in most cases. So that makes sense. Most likely, adjusting your shadow bias or cascade distances will fix this issue. The reason I expose an option to tessellate the shadow pass is not only because it makes the shader faster to not do this, but because if you have a low res shadow map, then it can be difficult for it to properly represent shadows as small as tessellated rocks can be - you just run out of resolution. So it really is a combination of how big an area your shadows are covering, how much resolution your giving them, and what biases your using..
     
    WildStyle69 likes this.
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Is per-texture UV scale on? (I'm guessing yes). In the current versions, this forces selection of the Mip Map level in the shader, which tends to choose a blurrier mip than letting the driver do it. In the old version, it used the gradient samplers instead, which works better, but is massively slower than using the current method (stress test scene in MegaSplat goes from 45fps -> 33 fps on my laptop when going back to the old method - which is a huge difference). Note that this only happens if per-texture UV scale is on- with it off, it lets the hardware do it (fast and perfect).

    In MicroSplat, I recently added this as a choice, so you can choose to have perfect mip selection for the extra cost. I should consider adding the same to MegaSplat.
     
    ftejada and WildStyle69 like this.
  43. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Thanks man, helpful answers indeed!
    • sRGB - seems this one is solved then, thanks.
    • Shadow issue - cascade affects it, but I cannot get rid of it. I'll keep trying to tweaks things.
    • Per-texture UV scale on - yes it is, so that would explain the blurriness.
     
  44. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Using hard shadows the problem goes away immediately, but with soft I cannot get rid of it. Gaaar! :)
     
  45. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Thanks for your support @jbooth.

    So I'm running Unity 5.6.4p4 -- I just created a new empty project, imported MegaSplat and opened the 'UnityTerrainTessellation' demo. I'm seeing exactly the same thing in your demo scene, and I'm unable to remove it there either? This issue was not present in the previous version of MegaSplat, so have you changed something that would introduce?

    IMG-MegaSplat-Shadow-Issue-22-Dec-2017-1.png
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    None of that code was changed between the versions your going between- the major changes were around the texture packing and sampling modes for textures- but fundamentally the basic shader code is the same. I suspect what is happening is that, when using soft shadows, you are getting aliasing between the shadowed and unshadowed areas, which are leaking between the ridges of the tessellated terrain. Why you don't see this in the old version is beyond me- if the settings are the same, then the result *should* be as well. Are there any other changes to the lighting or unity version between the two versions you are comparing? Perhaps the scale of the cascades or quality settings?

    Honestly, the screenshots look like class Shadow Acne to me- which is a common problem with shadowing systems that use a texture, like Unity's cascaded shadow maps. When you increase the geometric resolution, these types of problems tend to increase (though they can easily happen on low-res geometry as well0.
     
  47. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Agree it's pretty strange, based on what you're saying -- like I said, I'm seeing this in your demo scenes too in a clean Unity project.

    On my project if I go back to master branch (previous MegaSplat), everything looks great. Switch to my branch that has the new version of MegaSplat and new arrays the problem is there, as per my screenshots. No other project files are changed on the branch, only MegaSplat and texture related.

    Edit: what version of Unity do you develop in, then I can test it there as well?
     
  48. Cgflux

    Cgflux

    Joined:
    Jan 28, 2016
    Posts:
    7
    Hi @jbooth I have a question. If use Megasplat can i paint on the terrain trees and grass? Or maybe thereis diferent way to do this?
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    5.6.1.p2 - but I highly doubt this is unity version related- it looks like classic shadow acne. You might want to try diffing your project settings to make sure nothing was changed without you realizing - we had a case in the 5.3 days where the screen space shadow flag would turn it self off on a regular basis and had to put some script in our build setup to force it to be on. Perhaps something was changed on the re-import of the project, etc..
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, at least not the way I think you are suggesting- you could make a tree model, give it a MegaSplat shader, and paint on it- but I'm pretty sure you mean paint across tree's and grass painted with Unity's vegetation system.