Search Unity

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

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

  1. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    I'm getting visible borders across multiple Terrains: http://imgur.com/xsM7tSp

    Most of the time it looks ok, only occasionaly there are areas like that.
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do your UV coordinates tile across the boundaries correctly? IE: If you have your uv scale set to 15.028102, then the chance that two edges line up is going to be very slim. So what you can do is either ensure that your UVs tile across multiple terrains correctly, or change the UV coordinates to be based on a top down projection instead of the vertex UVs..
     
  3. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Do you have a tutorial on how to make normal seo textures with substance designer?
    I do not find the right one maybe becouse of the wrong search words in google.

    Also i want to know if the "Per Tex Scale" should work cases because i have some textures and when i try to change one tex scale of them the others change by the same amount?
     
    Last edited: Jul 10, 2017
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I believe, somewhere long ago in this thread, someone created a substance output node for NormalSAO format. I'm not super familiar with substance, but used it to produce some of the textures in MegaSplat. In my case, I just packed the texture data in photoshop.

    So, the way this works is that you set the range of the scale values at the top of the interface, then each texture gets a slider to scale between those values. So if you set the scale to 1 and 10, then when the slider is at 0 the texture scale is at 1, and when the slider is at 1, the texture scale will be 10.

    The reason for this is that the per-texture properties are stored in a texture, and a regular texture can only store a 0-1 value. So what it does is:

    Code (CSharp):
    1. scale = lerp(minScale, maxScale, texScale);
    So in essence the scale range is the maximum and minimum scale for all textures, and the slider controls the position between minimum and maximum values for each texture.
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    trilobyteme and Grendelbiter like this.
  6. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    StevenP94, Goodgulf and trilobyteme like this.
  7. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    This forum ist great!
    Thank you @jbooth and Grendelbiter

    Besides that i am not sure if i understand the scale thing.
    Why is it that way that when i change the size numbers on one material it also changes the numbers on the others ?
     
    Grendelbiter likes this.
  8. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I didn't tried with meshes, for that I have my own shader, which blends up the most comon texture on the terrain. Maybe I will change this later. For me it is enough just for the terrain, but I'm sure there are another opinions about this. This is a small change with a big texture blending quality impact, that I was missed when I moved from RTP to MegaSplat. I belive this also helps us to get rid of or minimize the annoying pattern, when we trying to blend 2 cluster with the 2 layers.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The range is shared between all textures on the material, but each texture has an individual value below it..

    Scale Range sets the min/max scale for all textures on your material:



    Then choose a texture using the index slider, and adjust the UV scale slider to scale the texture from the minimum to maximum scale value.

    In this example, the minimum scale (for all textures) is 1 and the maximum is 20. Since UV scale is set all the way left, the texture in index 0 has a scale of 1. If I slide it all the way to the right, it would have a scale of 20. Keep in mind that if you have clusters, you'll likely want to adjust all the textures in the cluster to have similar scales.
     
  10. Fabbs

    Fabbs

    Joined:
    Dec 2, 2013
    Posts:
    43
    Hi, do you know if there is any easy way to get Megascans textures to work with megasplat? or do i need to fix them in some software? thanks!
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Just pack them into one of the available packed formats (see docs) and they'll work great..
     
  12. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    This might sound kind of blasphemous...But would it be to much effort to make a option to compile the shader to use splatmaps to display clusters?

    The reason I ask this is because Megasplat doesn't play nice with GPU terrain generators like TC2 and trying to convert the terrains can be somewhat tedious to get the texture conversion to somewhat match the texturing made in the generator or hieght blends to look correct. It might be a easy work around to allow splats to be used for instant visual results for one layer then later convert the shader to regular Megasplat format for fine tuning and second layers. Ideally compute shaders would be better, then the node graph would be easier to work with and more terrain generators would be likely to make compatibility. But I get this is alot of work that's why I suggest a traditional splatmap as a workaround ( temporary hopefully..I loves me compute shaders. lol).

    Also Is POM on the road-map? I prefer it to tessellation because you can get the small details that get missed on tessellation (Within reasonable FPS amounts).
     
  13. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    If I understand correctly, if I use whole numbers I should be good, right? Well I am and it's still not blending correctly.

    Pic: http://imgur.com/BUlSJpP
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I'm not sure if I follow; the internal megasplat format is just 2 texture indexes and a blend between them per pixel. It doesn't use a traditional splat map "Weights" texture.

    No, it's too slow to use with this technique, since you have to POM through 6 textures for a two layer shader, and at any reasonable sample count that works out to be a lot of samples. I looked at doing Octree Occlusion Mapping instead, since this can reduce the number of samples you need to do, but this requires the height texture mips to be processed and would likely need a second set of textures just for this use.

    Does this still happen if you change your UV mode to projected and use a top down projection? Does this happen if you paint over the edge, or only if your using the terrain converter? It might be that the terrain converter gets slightly different results on each edge for some reason.
     
  15. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    This is what happens if I change projection to top down: http://imgur.com/9YgDPNi
    Every Terrain chunk is completely covered in one texture only.
    This is what happens if I paint over a border: http://imgur.com/eFz2IHu
    The gravel is painted, everything else is converted. The upper portion of the gravel is how it looks if I attempt to paint directly on the border. It only paints on one Terrain at a time. If I paint a little over the border it blends as expected, but there still is a border visible.
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have both terrains selected? It should paint over both if you do. That said, if you can send me a repro project I can take a look.
     
  17. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    I do have both Terrains selected. I'll put together a small repro project.
     
    jbooth likes this.
  18. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    @jbooth I've run into an odd problem recently. It's happened two or three times. All my terrain suddenly turns white. I think it only happens after doing a standalone build. (Most builds are fine.) It's white when I run the build and white when I run the game in the editor. It's also white in the scene view. Terrains remain white until I use git to discard all my changes in my scene.

    The last time this happened, I wasn't even doing anything related to terrains or shaders. I've checked all the MegaSplat material settings, and they look fine. This problem happens with all five MegaSplat materials I use for different quality settings. Any idea what's causing it? What can I check? I don't want to discard my work again.

    CastleKingdoms-201707111203372876.png
     
  19. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Recommended that we use TGA "compressed" or "uncompressed" with MegaSplat ?
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Haven't heard of this one before- is this only in the builds, or editor as well? What does git show as modified? Perhaps if you can narrow down which thing is causing the issue it'll become more clear..

    Unity converts textures into GPU formats and compresses them, so it doesn't really care which format you use, though I would recommend always using uncompressed formats on disk so that you don't reduce quality before the conversion. Also, some formats have some issues with alpha, such as PNG, which will strip the alpha channel and treat the image as RGB instead of ARGB if the alpha channel is all white.
     
    wood333 and Dwight_Everhart like this.
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Also, are you referencing those material variations such that they get included in the build correctly? Note that white is the default color of a material if you have no textures assigned, so perhaps your texture arrays aren't being included in the build?
     
  22. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    All of the materials are referenced by a script that is attached to an object in the scene. That script sets MapMagic's terrain material based on the current quality setting. The materials all reference the textures arrays (through MegaSplat's inspector). The white terrain appears in all quality levels.

    The white terrain appears in the builds, in the game running in the editor, and in the scene view.

    The modified files include the scene (my game only has one scene), in addition to several scripts I've modified. I tried examining the diff of the scene asset, but the diff is thousands of lines long, and it's hard to tell what anything belongs to.

    I also inspected all the objects related to the terrain and the materials while the game is running in the editor, and everything looks fine. Something is changing in the scene that is breaking the material, shader, terrain, or something, but I haven't been able to figure out what it is.
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, Unity Scene saving is non-deterministic, so it's impossible to easily diff, and it's a ton of GUIDs anyway. So, in this case, is it true that your materials and texture arrays show no modifications?

    When you build, are you building from the editor or via a command line/jenkins style job? The only thing MegaSplat does to texture arrays automatically is update them when the platform changes (because that may change the texture format to ETC2, etc). So if you were building via a command line, and passing a build target, I could see that cause your texture arrays to be regenerated. That said, I wouldn't expect them to be filled with white.
     
  24. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    I didn't see any changes, and, as I said, I wasn't working with textures or terrains. I was working on audio.

    I build from the editor, using Command-B.

    I went ahead and reset my scene. I didn't have much work to redo, fortunately. Most of my work was in scripts. I'll try to figure out what is triggering this behavior, if it happens again. Thanks for your suggestions.
     
  25. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I'm seeing some weird artifacts when I enable Tesselation (both Distance and Edge) -- there are a lot of white noise specs onscreen, and they seem to dance around when I rotate the camera. See screenshot. They disappear when I switch Tesselation off. I'm on a MacBook Pro with GT750M GPU. Is there a way to eliminate those?

    thx
    Dave

    white specs.jpg
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Haven't seen that before- could you try disabling/enabling various features of the shader to see if one of them in particular causes it? Is it only on certain textures, and does it happen when you try the included examples?
     
  27. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    FYI - At the top of your online documentation is a link named "YouTube." It connects to this forum, and not YouTube.
     
    jbooth likes this.
  28. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Well, as I said, it's Tesselation -- the speckles disappear if I turn that off, and reappear if I set it to Distance or Edge. I've toggled everything else off, and the speckles are still ther. The number of speckles increases if I set Tesselation Max Distance to 50 and decrease with a smaller number, disappearing if I set it to 5 or less. So I think it's pretty clearly caused by Tesselation.

    I don't have your demo scenes in this project (trying to keep it from bloating), but I do not see this issue when I import MS into a new project. So maybe it is somehow caused by our textures....how do we investigate that?
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The only thing I can think of is that somehow your getting specular aliasing where you wouldn't normally due to the changing topology in the tessellated areas. IE: At some angle, with some tessellation, a smooth area is effectively pointed directly at the light and creating a white sparkle. Some things that could help diagnose this:

    - Do the areas change when you reduce mip-bias on the displacement settings? (This causes the displacement to use a lower mip level, which makes for smoother displacement).
    - Do you have small areas of high smoothness in the textures? Do other textures not exhibit this effect?
     
  30. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I created a diffuse texture array, first packed the diffuse map and the height map with Channel Packer in its standard mode. All seemed well, the textures look fine. I then created a Megasplat Array using those textures, with the linear NOT checked because these textures contain color, and all seemed well, except the preview spheres for the clusters in the inspector are dark, even with a cluster consisting of only two textures where both texture images are bright and colorful.

    I saw the note in your FAQs section. My player color space is gamma. While the individual textures in the array look excellent in the array inspector, the preview spheres are dark in the array inspector. Also, it doesn't seem to matter if I set the Preview Rendering Info or not. Does this matter? Where have I likely erred?

    Upon looking at an example scene, I see that an example diffuse array with a two texture cluster consisting of two bright sand textures also has a dark cluster preview sphere. Have I caused this or this common to see in the diffuse texture array?
     
    Last edited: Jul 13, 2017
  31. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Mip Bias doesn't have any effect. We'll look into smoothness, but I'm dubious -- the effect isn't like small glittery spots on the ground. It's more like screen static. With a completely static (non-moving) camera, the speckles don't move, but if I rotate the camera, then the speckles move across the screen, completely independent of what's on the ground. Here's a video: http://www.eduweb-labs.net/speckles.mp4
     
  32. dzlucas

    dzlucas

    Joined:
    Nov 2, 2016
    Posts:
    12
    Note sure if this is a problem on my end, but it seems to me that enabling "per tex flow" breaks tri-planar shading? I get massively stretched textures with it enabled (see before/after pics)

    The flow is only active on the lava tex

    upload_2017-7-13_20-49-59.png upload_2017-7-13_20-50-23.png
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Something changed in the more recent unity versions that has caused these spheres to render dark on some systems/settings - I'm planning on looking into this after I deal with a 5.6+ lightmapping issue, so hopefully I'll have a fix soon.
    If you can send me an example project I'll take a look. Does this only happen on your mac or on other machines as well? (I dev on a mac, btw).

    Flow requires a UV to flow against. It's been a while since I played with the combinatorics here, but I believe if you turn on the 'second UV' option it will use the second UV for flow mapped surfaces. By default, the second UV will use the model UVs, but you can change it to use a projected uv instead. I believe the same holds true for the paintable lava and water systems when using triplanar.

    The paintable lava looks way better than flowmapping a lava texture, btw..
     
    wood333 likes this.
  34. dzlucas

    dzlucas

    Joined:
    Nov 2, 2016
    Posts:
    12
    Gotcha. Enabling second uvs and setting to projected didn't seem to make a difference, but I'll play around with it a bit more to see if I can make anything happen.

    As for the paintable lava thing, I'm generating all my terrain at runtime (along with the alpha values for each vertice), so I was under the impression I can't use 'paintable lava'. If there is a way to do that at runtime, though, I'd love to hear about it..
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You certainly can- if you are already generating the splat data per vertex, you can write the amount of wetness and puddles for each vertex as well, along with the flow direction. Puddles can be set to lava, and there you go..
     
  36. jimburn

    jimburn

    Joined:
    Apr 1, 2017
    Posts:
    64
    Hi Josh, here is my suggestion list.

    1. Simplifying the texture array management. Having a drag and drop normal map and diffuse map, then you are doing all the hard job of generating the ao, bumpmap, and changing the picture formats behind the scene. That would be a great thing for designers.
    2. Having another rendering mode where you are using a different splat mixing (CTS basic mode).
    3. Using the Unity's terrain splats directly. Or have a variable storage in Megasplat that can match the Unity\s terrain size. 1024x1024 terrain would be stored in Megasplat 1024x1024, thus maintain the same precision and enhance the quality of the Unity-> Megasplat conversion for terrain that are detailed.
    4. Simplify the preview system and select the one to use by default. Insure that the previews are working in any case. That's a bit related with 1), in the sense that Adding textures should be as simple as doing it for Unity (or CTS). 256 textures is great, but it has to be very simple for the designers.
    That's it. But 1) is I think very important.
     
  37. dzlucas

    dzlucas

    Joined:
    Nov 2, 2016
    Posts:
    12
    Awesome...last question then, what sort of values do I need to use / where for puddles and flow direction? I see in your docs that the UV3.y is used for puddles but not sure what range it expects, as the values I tried didn't do anything

    EDIT: Okay I guess they do something now (0 - 1 seems to be the range? would makes sense..). So my questions become how is flow direction painted into the vertice, and how do I get the lava to be not a yellowy glob (the lava shader also gives me just a lot of yellow, I'm sure this is just a setting or something)?

    EDIT2: Oh, the puddles tab. Didn't even see it pop up. Makes sense..it is less yellowy glob now :)

    This is gonna be awesome though, love versatility of this program..
     
    Last edited: Jul 14, 2017
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Flow direction is in UV space as a 0-1 value (pretty sure, might be -1 to 1, but since it's stored in a texture on Unity terrains, might be 0-1 which is unpacked into -1 to 1). There's an included texture set for the lava effect, but changing it can have pretty huge effects on the look. Check out the example scene "Hot Lava"..
     
  39. Lijianjian

    Lijianjian

    Joined:
    Feb 26, 2017
    Posts:
    16
    Hi I need some help !

    I try to install MegaSplat 1.14 in Unity2017.1.0f3 . But i failed to open it in 2017.1.0f3 .
    Unity console give this error
    "
    Assets/MegaSplat/Scripts/Editor/SplatArrayShaderGUI.cs(473,14): error CS1501: No overload for method `BeginAnimatedCheck' takes `1' arguments

    "
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, Unity's script updater has a bug - I'll have this fixed in the next patch, but for now, just remove the BeginAnimatedCheck and EndAnimatedCheck calls from that file..
     
  41. Lijianjian

    Lijianjian

    Joined:
    Feb 26, 2017
    Posts:
    16
    Get it ! Thanks!
     
  42. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    Ahhhh. You know I think I was thinking that the texture cluster indices where stored instead of the texture indices themselves. They way you do it makes way more sense than what I was thinking.. haha. The idea was since the textures seem to blend differently and height blending is so much different to work with than standard unity terrain shader, that using a splatmap would allow TC2 to work with the height based blending with one layer and make changes on the fly. Then after I get that layer set later I could convert it to the normal Megasplat shader and add in the second layer blending manually or with the node editor.

    That sounds interesting, is this on the roadmap or a R&D idea?
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I experimented with it a long time ago and abandoned it because it has a lot of tools/memory implications that didn't seem to be worth it.
     
  44. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Cubiquity is my go to voxel engine to make my terrains but it has a very simple Shader. So MegaSplat....

    Your demo video blew me away with all the features included it seems it can blend between two static models for example: A boat blending with the sand. Both the ground and the boat are simple static meshes.

    MegaSplat can do this correct-if so would you upload a video demonstrating this?

    P.S. When you choose Smooth AO on the shader style in your videos does the AO stand for per vertex Ambient Occlusion?
     
    Last edited: Jul 16, 2017
    Dwight_Everhart likes this.
  45. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @jbooth Hi Jason, just getting back with you on the baking of splat textures.. is it now possible to bake both layers into one? I thought I read something like that a little while back but never sought clarity if that was indeed the feature added.

    There is a couple ways to export an entire scene via FBX or have everything live linked using the asset Besync but I was concerned that the two layers as you had informed me in the past would have to be baked out separately (wont merge in the debug output)
     
  46. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Can you please give more info about this?
    What issue is it and when do you plan to deal with it? o_O
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's an example scene included which does something like this. There's a brush included which will blend the normals of two objects or an object with a Unity terrain, but you have to also get the UVs to line up as well (usually by using a projected UV mode). It's not as simple as clicking a "Blend with terrain" checkbox..
    What do you mean by baking both layers into one? If you bake out the splat data, it has both layers and the blend weight in the RGB channels of the image. If you are talking about the albedo/normal/etc, then the two layers are combined already..

    So, Unity seems to believe that their graphic coders are exempt from writing documentation, so they drop a new lighting system with absolutely zero documentation on how the shaders are supposed to work, change nearly everything, and then people like myself have to sit in Beyond Compare diffing hundreds of files to see what they changed and make things work again. If you ask them about it, even through paid support contracts, they'll tell you to look at the code and figure it out yourself. It's completely silly, really.

    So basically I've already sunk around 20 hours into figuring out what they changed- and then once I get a model working, I'll have the fun of figuring out how to have both lighting systems in a single shader (for Unity 5.4/5.5 and Unity 5.6->until Unity changes it all again). This doesn't affect all lighting modes (because there are about 20 different lighting pathways in Unity), but basically if you try to use the progressive light mapper on a tessellated mesh right now, it will show as in shadow all the time.
     
  48. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Oh so that normal brush that blends edges only works on Unity Terrains because I don't want to go near Unity Terrains.
    Does it still work on normal meshes like a ground plane and an object on top of it?
     
  49. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    A while back I was talking with you about exporting all the textures so I can export my terrain and use it in Maya.

    Right now I'm talking with another developer that has created an FBX exporter (Unity FBX Exporter) it searches for the Unity Renderers (Mesh Renderer, Skinned Mesh Renderer and Terrain) and adds those to the Fbx file. It reads Unity's internal pbr buffers to export diffuse, normal and specular textures from any Unity lighting compatible shader..
    So ultimately I'm investigating if the FBX Exporter will work to get all the textures with the FBX export.

    The author had also said as far as being able to export the depth map/height map "the depth 0 = black that will produce artifacts... but as long as height stays in the 1-255 range it should work fine".. I had told him that the height map is packed into the alpha channel and he thinks it will work as long as the height stays in the 1-255 range -but I really don't know what he means there. Does this make sense to you?
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    not really sure why he'd need it in a 1-255 range, you'll certainly end up with heights at 0 at some point. Anyway, if you flip the shader's debug modes, you can see the exact data it's going to output for each render. All the render baker really does is change your shader to one of these debug modes, then render a plane with the shader on it (but using your geometry's data for various lookups).