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
    The terrain shader type expects to have control maps, but they are not in the Unity terrain format (format is described in the docs). It *should* work on a mesh just fine, since all that the Unity terrain ends up being in the end is a bunch of meshes anyway.

    What MegaSplat does on a Unity Terrain (which is also CLOD) is construct virtual triangles in the shader in which to perform the splat mapping on. This is because the triangle topology is always changing when you have a CLOD terrain, so if you had it on vertex data, like the mesh mode, textures would pop and change with the LOD.
     
  2. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    83
    Hi there,
    I just updated MegaSplat as well as switched to 2018.1.3f1 and now when i am trying to update a texture array i get these errors which leads to my texture clusters are not showing on the painted terrain but only the ones comming with the tool.
    upload_2018-6-10_20-37-18.png
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, I submitted a patch for this on thursday but it hasn't been approved yet. I'll send you replacement shaders in a PM.
     
  4. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    83
    Thank you! It worked! It is so nice when turns out i did not f***ed up something :)! It happens so rarely!
     
  5. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    83
    Slight issue,

    I am using MegaSplat with MapMagic, which is now acting up. It paints the terrain as it did before but upon hitting play the texture clusters of my textures are replaced by the cliff texture at 0 index which is the first default texture that is coming with MegaSplat. The whole thing works fine in the editor as before the issue starts only upon starting the scene.
    :(

    Edit:
    Looks like some of my texture clusters not exactly replaced with the very same first cliff cluster of MegaSplats default textures but some has got the Grass of yours. So not all of them defaults back to the one at index 0.

    Never Mind it is fine now, although i am not sure which one of my actions fixed it.
     
    Last edited: Jun 11, 2018
  6. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    Yep I got it working - My procedural mesh had F***ed UVs. A derp on my end.

    One further question: Is it possible/easy to enable GPU instancing on the Megasplat shader? I have a bunch of terrain tiles that can be instanced.
     
    ftejada likes this.
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, I'd have to add code to support that- MegaSplat was written before instancing and I've never been asked for it..
     
  8. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    Do you think it is something that could be easily added to certain modes? AFAIK there is no unique data per material instance so should be just a couple of lines?
     
  9. DrInternet

    DrInternet

    Joined:
    Apr 6, 2014
    Posts:
    106
    Actually you have been asked before, about a year and half ago.
    https://forum.unity.com/threads/rel...at-mapping-system.441329/page-12#post-2927816

    But that's not why I'm here. About week and half ago I sent you a project to reproduce texture bug in 2018. No reply so far. Any progress on that?
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I have not had time to look at it yet; a lot of stuff going on in my personal life and I’m about to head on a 9 week trip, but will have a few days at home in early July to catch up on everything.
     
  11. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Hi @jbooth !!!
    One question ... do you know if MegaSplat shaders works for ps4?

    regards
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The non-tessellated ones do (yay surface shader abstraction)- but apparently the tessellated ones do not, but without a ps4 dev kit or sdk I don't really have any way to know what the issue is.
     
    ftejada likes this.
  13. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    Oh that reminds me - I'm displacing the verts using your prevertex custom function and if I don't have tesselation enabled the shadows aren't offset correctly. Turning on tesselation fixes that. However I don't really want tesselation. Is this something that can be required?
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, I think there's a surface shader directive that forces it to generate a shadow pass. I might have to add that..
     
  15. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    I was using MegaSplat and it was working just fine, then something weird happened. My terrain textures suddenly look very washed out. Very low contrast and no noticeable normal mapping. Also, when I try to paint, it only paints a tiny little blob instead of full coverage. I was literally in the middle of a project and had no issues then all of a sudden it happened. I tried saving and reloading, but when it comes back the textures still look washed out and I can barely paint anything. Any idea what happened?
     
  16. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    Figured out my brush flow was causing the painting to get screwed up, so now the only issue is the very washed out looking textures
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Check the shaders in the InternalShaders directory and make sure they are compiling- I submitted (and the UAS published) a fix for this recently, but maybe something is still off?
     
  18. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    For some reason they look correct now. Not sure what happened.

    I do have a question about the procedural shader. Under my Texture Projection Editor, I have orange boxes for each texture, and the farthest left boxes are the only ones that are working. It lets me go through each texture, but the preview image never updates. None of the other boxes will let me move the sliders (only the far left texture slider works).

    I'm assuming I missed a step somewhere. I selected my mesh, selected "MegaSplat_procedural" as the shader, set "Bottom Layer Texturing" to "Project 3 Way" - and I set up my Albedo/Normal under "Splats", and then I added the MegaSplat_Example (TextureArrayConfig) to the Vertex Painter.
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    All sounds fine- what Unity version? Sometimes the slider doesn't work if the window is too small (Unity bug).
     
  20. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    In Unity 2017.4.3f1
     
  21. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    Hi,
    Is Vulkan supported? Because CTS doesn't support the graphics API.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    As far as I know it should be..
     
  23. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I had a challenge to buy this asset after solving by hand the barycentric blending, even though I don't need it now (character investment is first), but how the hell does that works? lol
    - I'm assuming that you need to reconstruct the index, in pixel shader, using the blending weight (that is the colors ratio), simplifying the problem to 2d yield infinite solution (clamp to 0-255 obviously) and i need slope as a tie breaker but don't know the specific of derivative in shader yet :( (met them once in skin shader to get the curvature, just copy pasted though). That's assuming there is no geometry shader used as the only shader 3 features announced was texture array.
    - I'm must say I'm tipping my hats off, because that's ingenious, the moment I learn about indexing 255 texture I had my mind blown, but then learning about the color coding had me floored, I knew it was about the barycenter, I thought I could try it lol.

    Well I guess I need to buy it to get the solution lol
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It's so subtle, you'll be lucky if you can even find it in the code. I suggest stepping through the code with some example data if you want to figure it out.

    Yes, the basic idea is that you need to know the blend amounts and indexes of the three textures used on a given triangle, so that you can sample them and blend them. And by default, the indexes will get interpolated, so that is the main thing to solve.
     
    neoshaman likes this.
  25. lamwz

    lamwz

    Joined:
    Dec 28, 2013
    Posts:
    4
    Hello, can you tell me how MegaSplat supports VR.After using Mesh, FPS has dropped a lot. Is it wrong with my operation? Or other reasons.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not enough specifics to tell- but MegaSplat is going to be heavier than something like the standard shader, especially as you turn on more options.
     
  27. lamwz

    lamwz

    Joined:
    Dec 28, 2013
    Posts:
    4
    What options should I pay attention to?
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's a texture sample counter in the debug section of the material properties which will tell you how many samples the shader takes, which you can check as you adjust features. This is a pretty good measure of texture bandwidth. There's not an easy way to tell ALU complexity, but MegaSplat was designed more for high end stuff than VR, which tends to want low complexity shaders.
     
  29. lamwz

    lamwz

    Joined:
    Dec 28, 2013
    Posts:
    4
    Thank you, I'll try
     
  30. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    Thank you!
     
  31. NightElfik

    NightElfik

    Joined:
    Oct 27, 2014
    Posts:
    27
    Hey, I had some troubles making the packed NSAO textures work. After some debugging and reading the MegaSplat.shader it turns out that the order in RGBA texture should be [S, Nx, AO, Ny], not [Nx, Ny, S, AO] as described in the documentation.

    Can you please confirm this? If true, can you also update the documentation? I am using the latest MegaSplat version.

    Thanks!
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That is correct - but why are you making them by hand now? The Texture Array Config manages it all internally now, and I thought I had removed references to NSAO format in the docs, but maybe I missed a spot.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, and it's:

    S, Ny, AO, Nx to closer match the Unity format.
     
  34. NightElfik

    NightElfik

    Joined:
    Oct 27, 2014
    Posts:
    27
    Thanks, but are you sure? For example in NormalSAOFromNormal.shader you do:

    Code (HLSL):
    1. half3 un = UnpackNormal(norm);
    2. un.xy = un.xy * 0.5 + 0.5;
    3. half4 nsao = 0;
    4. nsao.xy = un.xy;
    5. nsao.w = un.b * un.b;
    6. nsao.z = un.b * 0.07;
    7. return nsao.brag;
    The code above packs the values in [S, Nx, AO, Ny] order, right? Is that a bug? It would help to not mix .xyzw with .rgba.

    Also, please do not remove details like these from docs. Add more! :) Power users like me often need/use these details to our advantage. We are building the arrays maps manually because our game loads everything dynamically during run time (and it is way faster to iterate without rebuilding large arrays, and we do not need to check-in >100MB arrays to our versioning system, etc).

    I was also able to build dynamic tillable terrain mesh that has the RGB vertices correct for MegaSplat. Your documentation had enough info to make that possible. :)
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    No, it’s correct; notice the swizzle on the return.
     
  36. NightElfik

    NightElfik

    Joined:
    Oct 27, 2014
    Posts:
    27
    I might be missing something, but the nsao.xyzw variable holds [Nx, Ny, S, AO] which gets swizzled using .brag which is the same as .zxwy which gives me [S, Nx, AO, Ny], right? Not the [X, Ny, AO, Nx] as you suggested.

    One tiny note: The generated shader says "Compiled with MegaSplat 1.6" even though I think I have the 1.68 version. I was just not sure if the upgrade I did was correct or I got some older version.
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yup - your right- Unity uses YX in their encoding, so I thought I had followed suit. When sampled, it gets swizzled back into NSAO format again, so the majority of the shader code is unaware of the formulas. Yes, the version number is still 1.6- I don't always update it for small point releases..
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yup - your right- Unity uses YX in their encoding, so I thought I had followed suit. When sampled, it gets swizzled back into NSAO format again, so the majority of the shader code is unaware of the convertsion. Yes, the version number is still 1.6- I don't always update it for small point releases..
     
  39. k3D-Junkie

    k3D-Junkie

    Joined:
    Jun 14, 2011
    Posts:
    236
    Quick question-

    I just downloaded MicroSplat and purchased the Alpha Hole module for it. Works great!

    But, although I was able to paint regular Unity Terrain trees on it, I haven't been able to paint grasses or other Details. The description says it supports Vegetation Studio for grasses. Does this mean it doesn't support Unity Details (grass,meshes)? I'm using 2018.2.0b4 beta
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, MicroSpat has no interaction with the Unity grass system, so it should have no effect..
     
  41. Tinder-Red

    Tinder-Red

    Joined:
    Dec 2, 2017
    Posts:
    19
    Hello everybody. i have a problem when i draw cluster texture. i've got different scaling .
    What i do wrong?. And how can i reduce the scale of my sand texture
    Thx.
    Texture Scale.jpg
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There’s an option for per-texture UV scaling.
     
  43. Tinder-Red

    Tinder-Red

    Joined:
    Dec 2, 2017
    Posts:
    19
    Where can i find this?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    In the top section of the material there's an option for it- once you turn it on, you'll have a control that lets you select the texture you want to edit and scale it's UVs between a minimum and maximum scaling value.
     
  45. Tinder-Red

    Tinder-Red

    Joined:
    Dec 2, 2017
    Posts:
    19
    Thx I found it.
     
  46. NightElfik

    NightElfik

    Joined:
    Oct 27, 2014
    Posts:
    27
    Hey, I would like to have per-vertex normal map intensity scaling (scale down normal map intensity on flat parts of the terrain to make them look more flat). How hard would that be and where would be the best place to add it in the shader? I was thinking to use uv (or alpha) for this scalar. We do use projected UVs so uv is currently unused.

    Is there any way to edit the shader generator to produce custom code in the shader?

    Thanks!
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You can edit the fragment files directly, or use one of the custom extension functions so you don't have to keep modifying the files when updates are made.
     
  48. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    This is a stupid question, as I did read the documentation but have not fully understood last part. So when your textureing is finished, and when you build, Megasplat bakes the final texture of the objects. Is this correct? There is no manual export of texture required?
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, it runs the shader in the game by default. If you were to bake out textures, then they would be very low resolution for things like terrains and such. There are some tools for baking textures out included though (which require a continuous 0-1 UV space and no overlapping UVs to work), if you want to do something like that.
     
  50. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    157
    Exactly that is what I meant, like one image for UV Mapping the entire terain but you said it would be low res. So ithandles textures seperately as they are. Let us say I add 200 Textures worth 400 MB, how much VRAM is used for this? What if I only ise 40 textures (say, 80 MB) then?

    And thanks for the support, your support is 24 hour continuos. Well done.