Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. Casanuda

    Casanuda

    Joined:
    Dec 29, 2014
    Posts:
    53
    Hi,

    I'm not sure where I am going wrong, but I can't seem to get terrain painting working. I am following the instructions as I understand them:

    1. Create terrain.
    2. The manual says "right click in your project view and select Create->MegaSplat->MegaSplat Mesh Shader or MegaSplat Terrain Shader" which doesn't exist, so I am doing create>MegaSplat>Megasplat Shader
    3. Create material
    4. Assing shader to material - set to terrain type
    5. Assign splats (I use the supplied arrays)
    6. I assign the material to the terrain via the custom type and a texture appears on the terrain.
    7. Switching over to the terrain paint, it asks me to "Please select a terrain to begin" - The video and manual suggests that the terrain painer should have a “Create it for me” button to create a storage texture - this does not happen.
    8. I manually assign a splat control in the material (a duplicate of the one from the demo, just filled in white) and the the terrain painter is available for use.
    9. Set the brushes and paint.
    10. And painting looks terrible...there is a single tiled texture across the whole terrain (verified by using fill).

    Could you please assist in where I am going wrong.

    Unity 5.5, the latest version of MegaSplat, empty project.
    P.S. The demo scene works fine.

    Thanks
    Cas
     
  2. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    I am happy to report that current version of MegaSplat works great in the latest Unity 5.6 beta editor on macOS 10.12. (I had to make a couple of minor script changes).

    However, when I build the player for macOS, all of the terrain is rendered blue, indicating that the shaders aren't working right in the standalone player.

    I've looked over all the build, graphics, and player settings I can understand, and haven't been able to find anything magic that will make the shaders work.

    Is this because there's a fundamental problem with macOS right now in terms of OpenGL and Metal? (I know that Terrain Composer 2 still doesn't work in 5.6 beta).

    Or are there some player settings I just haven't gotten right?

    Sorry if this is addressed in the docs and I just don't know where to find it.

    Do I need to go back to 5.5 for now?
     
  3. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I find that when I have the brush at its smallest size that it will not paint. When the brush is near its smallest size it will paint sometimes. Finally, there seems to be a minimum splat size, from which I am wondering if I can somehow get a finer splat resolution.
     
  4. Casanuda

    Casanuda

    Joined:
    Dec 29, 2014
    Posts:
    53
    Hi,

    Quick update. Managed to find the tiling.

    Ta
    Cas
     
  5. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @jbooth thanks for getting me to focus a little more on the renaming shaders part for multiple tessellation. I had done this previously (named the shader itself then dragged and dropped the shader on the material but realized later that it doesn't add the shader name through drag and drop onto the material so I typed it in the material manually and it now works.

    However :) It seems no matter what I do there is a tessellation deformation limitation when you set up a large mesh.. no matter what mode, settings etc the amount of deformation is almost not noticable (see orange highlighted boarder edge on the rock surface)
    The bridge I was working on is shown for size comparison. I examined your boulders in the tessellated mesh terrain scene as well and it seems that it mainly has surface detail but doesn't seem to change the overall shape or surface.

    upload_2017-2-5_13-7-6.png
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I have not tested on 5.6, but the colors are assigned based on shader compatability. I'll look tonight and see what blue maps to. For now, you could try forcing the build API to use OpenGL instead of metal.
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If you are using a mesh, subdivide the mesh. On a terrain, this is based on the size of the splat control texture..
     
  8. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I'm using a terrain. I understand from an old Unity forum thread, that if I increase the splat control texture it will give me finer resolution, but it will also erase the existing splatmap. Does this mean I will have to recreate my terrain texturing from scratch?

    (Also, the forum thread advises that to avoid a slow-down I should be careful to keep my texture count to 4 and not go up to 8. I got a chuckle from that.)
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If you upsample it in photoshop using point nearest neighbor sampling you can preserve your paint job..
     
  10. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks. I definitely need help on this. I am only passingly familiar with shader language and writing shaders so I'm a bit lost in this code. But I'll keep trying on my own as well. If I figure anything out I'll let you know.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So blue is the last else case, which basically means the define for the current API isn't know. Most likely, they've added some OSX_METAL define or something in 5.6 that I need to add. I'll download 5.6 tonight and see what the new defines are, and will add them in for the next version. I can also send you info on the change (should be one or two lines of code at most) so you can make the modification yourself.
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    What I'll do is make a small test shader for you that has all of these macros in them. Then we can easily figure out what's going on without needing to dig through a massive shader system like MegaSplat..
     
    magique likes this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have a height map in your textures? Also, there's a slider for the amount of displacement; maybe the value just needs to be allowed to go higher than 3 game units for your case? How big is this mesh?

    For reference, hardware limits the maximum number of times a triangle can be divided (64 times), and I believe it *might* limits the max displacement as well, though I haven't run into that in a while.
     
  14. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Excellent. I'm ready when you are.
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    If you open up megasplat_shared.txt in the fragments folder and add:

    || defined(UNITY_COMPILER_HLSLCC)

    at the end of line 461 I think that will work. Looks like they added a new define, which I expect covers metal and vulkan. If for some reason that doesn't work, I think you could o

    || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN)

    to define them directly.
     
  16. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Interesting to note that I can get it to compile with tex2DArray(tex,coord), which is one of the options you showed. But the result is garbled texturing. As soon as I add back in the dx,dy parameters then it fails to compile. I assume the dx,dy params are essential, but none of the defines above have those as an option.
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Just sent you an email with a stripped down shader and some things to try.

    If it compiles with tex2DArray, then I suspect it's going to work.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Note that unity defines the following macros for defining and using texture arrays:

    UNITY_DECLARE_TEX2DARRAY(tex)

    UNITY_SAMPLE_TEX2DARRAY(tex, uv)

    which usually compile down to:

    Code (CSharp):
    1. Texture2DArray myTex;
    2. myTex.Sample(uv);
    MegaSplat needs a gradient version as well, which Unity does not define. It would compile down to:

    Code (CSharp):
    1. Texture2DArray myTex;
    2. myTex.SampleGrad(uv, dx, dy);

    The most likely case is that my macro:

    MSPLAT_SAMPLE_TEX2DARRAY_GRAD(tex, coord, dx, dy) needs a

    || UNITY_PLATFORM_WIIU

    added to one of the cases.
     
  19. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    Thanks! I'll look forward to a fix.
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Look up about 3 posts and let me know if that works.. (I'd test myself, but I'm running an old OS which doesn't have metal support)
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Four new quick tutorials posted on the website:

    http://megasplat.com/tutorials.html

    Hopefully these help make the steps clear for newer users (most are shot with 0.98, which should show up this week).

    Also added an integrations area, showing off some of the packages that are already integrating directly with MegaSplat. More on the way as well!
     
    Akshara and mk1978 like this.
  22. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    I tried adding both of the variations you suggested (one at a time). That DID get rid of the blue terrain. But it only renders the first splat in the array over the entire terrain instead of the splats in the array according to the color map I have created. And that texture is rendered without tessellation.

    That is without "Experimental Metal for Editor" enabled in the player settings. When that is turned on, then the landscape does not render at all in either the editor or the player, with or without the changes to the shader compiler.

    Are there other player settings I should be aware of? I added my compiled shaders to the "Always include" list in the player settings already.
     
  23. Deleted User

    Deleted User

    Guest

    Hi, I have a problem with tessellation.
    When I use deferred rendering, it looks like this: 22.jpg
    It works well on forward rendering or if I turn off the shadow from the light source.
     
  24. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I have the same problem using deferred rendering, not tested yet in forward rendering.
     
  25. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I'm writing an utility to pack textures for Megasplat use (MSEO etc.) anyone interested ?
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Turn on "Tessellate Shadow Pass". Not tessellating the shadow pass seems to cause the issue, I'll look into why..
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, of course. So yeah, you can't really use this optimization option in Deferred. I'm not sure if there's a great way for me to handle this other than putting some kind of warning on it, since the deferred rendering path can be set per camera.
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, I'll have to do a 5.6 pass at some point as they get closer to release before it's released and see what all they've changed. Are you running the beta for any reason in particular, or just curious?
     
  29. Deleted User

    Deleted User

    Guest

    How it looks with the turn off "Tessellate Shadow Pass". 23.jpg

    And turn on: 24.jpg
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, I see your running the 5.6beta - this is not yet supported as Unity tends to break things during betas.
     
  31. Deleted User

    Deleted User

    Guest

    Thank you! I try version 5.5.
     
  32. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    What is MSEO?
     
  33. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. I am looking at doing som integration with MegaSplat. Is there an API or easy way to get previews of textures in the current texture array?
     
  34. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi, I have been back and forth looking at this and cant work out if it could work for my needs.

    I am looking for a solution to be able to tile maybe 8 or 16 images over a single terrain?

    Each tile would be a either a 512x512 or 1024x1024?

    The other requirement is...can this be done at run-time (by loading images in which I can do already)

    Thanks
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It depends on if you need them at runtime or not. If you're writing an editor tool, you can access the original textures from the TextueArrayConfig's properties. If you need them at runtime, then you can render them to a buffer using a shader that just writes out the index you want.

    If your looking to transition between them, than that's what this package does, but with up to 256 textures.

    Yes, you can build the texture array at runtime. The only unfortunate side effect of this is that you'll have to keep both copies of textures in memory, and I suspect that updating a large array won't be particularly fast. Most of the code you need is already in the TextureArrayConfig scripts, so it's mostly a manner of moving that process to runtime.
     
  36. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Quoting from docs:
    MegaSplat’s shaders support several different packing methods for normal and specular
    texture data, designed to get the optimal quality for the least performance cost. You will need to
    determine the texture packing your going to use before converting your textures into Texture
    Arrays. The four options are:
    Standard:
    This packing closely matches Unity’s standard shader, with the exception of storing a
    height map in the alpha channel of the diffuse texture instead of in a separate texture. Normal,
    Specular (Metal/Smoothness), and Emission are all available.
    MSEO:
    This option uses the same diffuse and normal layouts as the standard mode, but expects
    the metal, smoothness, emission mask, and ambient occlusion in each channel of a single
    texture. The emission mask is multiplied by the diffuse color to produce an emission color value.
    With this mode, you can attain a full PBR metallic workflow with ambient occlusion and emission
    with only 3 textures.
    Normal Smoot AO:
    This mode uses the same diffuse layout as the options above, but expects the
    smoothness and ambient occlusion term to be packed into the blue and alpha channels of the
    normal map. No per pixel metallic value is available, however, a global metallic value can be set
    or a per-texture metallic value can be used if per-texture properties are on. Emission is only
    available via a separate, full RGB texture. The main point of this mode is to get a full PBR
    workflow with only 2 texture samples. Please note that the normal + smoothness + AO texture
    should NOT be set to normal map, but rather to ‘advanced’ with bypass SRGB sampler and
    linear mip maps on.
    Normal Smooth Metal:
    This is the same layout as above, but with a per-pixel metallic value instead of ambient
    occlusion.
    You can find more details on the Megasplat documentation.
     
    magique likes this.
  37. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Definitely. I spent some time recently manually converting a dozen Quixel textures and another batch of textures from GameTextures.com via Photoshop to the Normal Smooth AO format. It didn't take *all* that long, but a utility would be nice. Ideally there'd be an invert option too, as the Quixel ones all come with roughness maps.

    There is a channel packing utility on the asset store:
    https://www.assetstore.unity3d.com/en/#!/content/61911

    But something with batch processing would be pretty cool.
     
  38. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    That channel packing utility has only one review, and it is a one-star complaining that it doesn't work. :(
     
  39. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Oops, didn't see that.
     
  40. Akshara

    Akshara

    Joined:
    Apr 9, 2014
    Posts:
    100
    Not the original poster, yet my reasons are for HDR and MSAA in Forward Rendering combined with the new Linear Rendering on mobile from 5.5. This allows for a visual consistency between Vive and Daydream when targeting both platforms, while also improving the workflow when switching frequently between the two.

    Potential issues with 5.6 are the new Lighting System and Directional Specular being deprecated.

    Yeah, too many issues in the beta for now, going back to 5.5.
     
    Last edited: Feb 9, 2017
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Nice, looks like they posted 0.98 already!
     
    sstrong and magique like this.
  42. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Awesome. Now if I can just get an answer from Nintendo support about texture arrays then maybe I can use this awesome terrain tool.
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The joys of closed platforms..
     
  44. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,229
    yep, it means as asset devs we can't test on those which makes them pretty difficult to support :-(
     
  45. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    Well it was definitely an error on my part, I changed the up Bias to 0 and it corrected everything with Triplanar mode. I've updated to the latest version which may of helped as well. I couldn't get tessellation to appear across the entire surface some modes would only let either top or the bottom to work on some areas but everything is working fine now.

     
  46. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Ok first preview of texture packer:

    Snap 2017-02-07 at 20.03.28.png

    And the MSEO tab:
    Snap 2017-02-07 at 20.33.38.png

    Now I'm working on the other texture packing (that will be added to the upper tabs), and thinking on how to arrange the interface to easily convert multiple textures a time. Actual interface was inspired from another asset, I hope this will not be a problem.
    Any ideas or suggestions ?
     
    mk1978 likes this.
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Some suggestions:
    - Allow for "from this channel" in case textures are already packed in some other format
    - Batch processing is likely all that matters, since doing this in a tool one at a time will likely be about the same speed as doing it in an image editing program
    - Support batch processing via naming conventions ("from *_norm.*)
    - If this is meant as a general asset for the asset store, consider making the packing definitions into scriptable objects, so that you can create new ones for packages other than MegaSplat. Features like "packed size" likely become optional at that point.
     
    Akshara and hopeful like this.
  48. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    My suggestions:

    - Everything @jbooth said. The scriptable object idea could be interesting, since there are other products (like Alloy) that have several of their own packed formats. Alloy actually includes a texture packer, but it's a one at a time deal.
    - An "invert" option for each texture. You sometimes get roughness maps with some textures that you need to convert to smoothness maps, for instance.
    - Probably already something planned, but different output formats like Normal Smooth AO
    - A way to save shareable preset files. For instance, Quixel and GameTextures.com each have specific naming conventions, so it'd be nice to define the rules just once. And being able to share preset files might be handy.
    - An option for solid white, black, 50% gray, and user-defined solid colors. Sometimes textures don't come with an AO map, for instance, so it's handy to select a color rather than create a solid colored texture. The texture packer that comes with Alloy has that, and it's very helpful.
     
    StevenP94, Akshara and hopeful like this.
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hi, I'm starting work on the PerTexture Property refactor. What properties do you want to be able to control per-texture that are currently not available? Right now we have:

    UV Scale
    Metallic (when none is provided per pixel)
    Smoothness (when non is provided per pixel)
    Contrast (blending between textures)

    // for tessellation
    DisplacementAmount
    UpBias

    I was considering adding:

    Porosity (controls how dark a material becomes when it gets wet)
    Normal Strength (I consider this not needed, but people have asked for it, and with the new system it will have no cost when unused)
    Detail Noise Strength

    Others?
     
    Last edited: Feb 8, 2017
    sstrong likes this.
  50. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,229
    This packer would nicely complement our own Landscape Builder Texture Generator which includes combining different channels from one or more textures and includes a host of other algorithms (normal, height, occlusion, emission, shadow removal etc.).
     
    StevenP94 likes this.