Search Unity

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

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

  1. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I'll wait the new year, no problem, enjoy your holydays ;)
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Feel free to send the mesh now- never know, I might have some downtime while I'm there and feel inspired..
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh, missed this the first time. Yeah, right now it's setup for macro texturing- however, it would be trivial to add more options there. What would you like?
     
  4. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I'm using Uber Standard (specular setting) at the moment, but I think that the options in the standard unity shader can be a starting point:
    Diffuse with a color multiplier.
    Specular with a color multiplier and smoothness control.
    Normal with intensity.
    Maybe when selecting alpha layer the labels of the 'macro texture' could change to 'Base texture' or something similar..

    Btw I'm sending an email to you with a mesh and some description about problems I had with that.
     
  5. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I'm seeing this when trying to use the tessellation versions (mesh or landscape):
    I ended up fully deleting the package and importing again hoping it might fix some things and it did actually. For example the tess material will now stay applied to the mesh where it would always reset back to the previous material before.

    Shader error in 'MegaSplat/MegaSplat_TessMesh': invalid subscript 'vec' at line 3330 (on d3d11)

    Compiling Vertex program with SHADOWS_CUBE LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP
     
  6. zmaxz

    zmaxz

    Joined:
    Sep 26, 2012
    Posts:
    143
    Hi~~
    Any idea for this situation ?
    If i use tessellation then Mesh collider is wrong.
    displacementError.jpg
     
    Last edited: Dec 30, 2016
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, I have a plan for this; I'm basically going to keep a low res version of the height maps around, and then let you get the offset point from that, much like you can get the name of the texture you are colliding with. This won't automatically solve these types of issues, but rather give you the data required to solve them for your specific use case.

    The only "just works" solution would be to do subdivision of the mesh as some type of paint post process, and spit out a massive highly tessellated version to use for collision. But that won't be practical for most use case because it will quickly consume tons of memory.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Can you send me a copy of the material and shader files for this?
     
  9. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    126
    Thanks for a great asset. I am planning on making a lot of use of MegaSplats in my project.

    Just one question. Is it possible to run MegaSplats off a texture instead of the vertex colors?

    The reason I ask in that the terrain I have is large and the number of vertices has a performance hit.
    I would really like to convert the terrain into an optimised mesh which would have much less vertices. How could I transfer the MegaSplats to that mesh, possibly encoding the data in a texture?

    Thanks!!

    Ronan
     
    StevenP94 likes this.
  10. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Exactly what I'm thinking.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's actually what the terrain shader does- but it's considerably slower than using the vertices because it creates a dependent texture read, where the GPU has to finish looking up one texture before it can start looking up the next set of textures. You might be able to use the terrain shader on a mesh; but there's no painting tooling to support working that way.

    In most cases on a modern GPU, vertex count is not the bottleneck. You should make sure that's actually an issue before optimizing it. The main issue a highly tessellated mesh causes for a GPU is usually micro triangle issues; this is because the pixel shader always samples in blocks of pixels, and along any edge it ends up sampling pixels which get thrown away. So if your triangles are very small, you end up with what's equivalent to a lot of overdraw, because a lot of pixels get rendered and thrown away.

    Baking out the vertex data into a texture for transfer to a new mesh is something that could be added; but you wouldn't get the exact same paint job because the control points would be missing or in different locations. Still, it could be a useful tool that allows you to save off paint jobs and reapply them after making changes to a mesh, since sometimes you just have to do that.
     
  12. mbbmbbmm

    mbbmbbmm

    Joined:
    Dec 28, 2013
    Posts:
    59
    Hi, I bought the asset and am really liking it so far!
    However I have a question regarding workflow.

    Say I have the bottom layer with multiple texture clusters, mainly cliff and some details like dirt etc. When I start painting on the top layer with e.g. moss it slowly creeps through the cracks getting slowly denser and it's easy to control. But if I change my mind and start to paint over it with another cluster - maybe I want to replace some of the moss with sand - everything that was moss is replaced very immediately and abruptly.

    Is there some kind of eraser so I could first reset the area so to speak?
    I know I could go to the bottom layer and repaint the cliff texture there, but then I would lose all of my dirt detailing.

    So is there a layer eraser that diminishes the current layer but preserves the other layer?
    Thank you!
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Repainting the bottom layer is equivalent to erasing the top layer, since it just biases the blend in the other direction. That said, you can also just paint into the raw data itself if your using the vertex painter and using a mesh. If you switch to the color tab, and change the painting target (likely on color) to UV3.X, that will paint directly into the channel that controls the blend. The nice thing about doing this is you could set your target to a specific amount (say, 0.4) and as you paint the blend will go towards that exact value. When you paint with the regular brushes, the blend is always headed towards 1 or 0.

    Let me know if this turns out to be a useful workflow- I could easily bubble this functionality up to be a "mode" on the MegaSplat brush if that makes sense to people (and could add this to the terrain painter as well).

    Also, if you have a particular blend look you want to paint down directly, the blended brushes allow you to dial in that exact setting and paint on both layers at once.
     
  14. mbbmbbmm

    mbbmbbmm

    Joined:
    Dec 28, 2013
    Posts:
    59
    Painting into the raw data with a value (but no texture associated) is exactly the function I was looking for! And it would be awesome to have as an additional mode/button for quick working. I think most painting applications use something like "hold ctrl to erase", right? So "hold ctrl to bring back other layer" seems fitting and would be a quick way to do things. And shift+ctrl could drive the blend towards the current layer? Such a mode would be super for fine tuning on the go.
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, on the backlog. I'll add it to the terrain painter as well, since you can't paint into the raw data there like you can in the vertex painter.
     
    mbbmbbmm likes this.
  16. erich202

    erich202

    Joined:
    Sep 24, 2016
    Posts:
    38
    Hey all,

    Sorry for the noob question, does anybody know how to change the far distance texture? When far away, it shows snow on the mountains, but when zooming in there is no snow, and you can see that when running around too which is kind of weird. Thanks in advance for any tips!

    Edit: Is Nomibuilder's answer right? Change all the texture settings?
    http://answers.unity3d.com/questions/371713/terrain-texture-looks-really-blurry.html

    upload_2017-1-2_11-16-48.png

    upload_2017-1-2_11-39-45.png

    upload_2017-1-2_11-42-41.png
     
    Last edited: Jan 2, 2017
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If you don't want a far texture, just turn off "Macro Texturing" in the shader options on the material. Or if you want it further out, you can adjust the fade distances.
     
  18. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Oh, a new terrain tool! How fun! I will definitely get this now that it works on Unity's terrain and I can convert from Gaia or World Creator. I must add it to my collection once I finish with the character system.

    Thanks, Jason! Looks wonderful and can't wait to try it.
     
    jbooth likes this.
  19. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Hello again, I'm continuing to troubleshoot my meshes/textures problems. I made a test scene with an object converted to megasplat on the left and the original one on the right. I put a megasplat shader on the _splat object and a standard shader on the original one. I used the normal map texture only on the megasplat's 'macro texture', and the same texture as normal map on the standard shader.
    No diffuse, no specular.
    I can't imagine why they look so different, and why they react so differently to the scene light, any hints ?

    Scene View with light removed from scene options. MegaSplat on the left, standard on the right.
    SplatVsStd_NoLight.png

    Scene View with directional light enabled into scene options. MegaSplat on the left, standard on the right.
    SplatVsStd_SceneLight.png

    Material details - MegaSplat:
    SplatMaterial.png

    Material details - Standard:
    StdMaterial.png
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey Steven, if you can send me those files I'll take a closer look.
     
  21. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    @jbooth I've already sent them to you, they were in the last mail I sent (the one with zip file on Google Drive)
     
    jbooth likes this.
  22. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    126
    I am wondering how to integrated MegaSplats into the Amplify Shader. I would really like to try it out.
    I have the latest version of Amplify Shaders and I have found the two nodes files included in the MegaSplat folders. But what do I do with those two files to make them show up in Amplify Shader?
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    They should just show up in the node menu under MegaSplat. If they're not, maybe the amplify guys changed something and I'll need to take a look..
     
  24. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    126
    The are definitely not showing up by themselves.

    I just looked at the code and on a guess removed the #if AMPLIFY_SHADER_EDITOR and #endif in your two files.
    They are showing up after that.
    I will test them out and see if they work correctly now
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, the main reason these look so different is that the default values for the textures are different between the standard shaders and megasplat. For instance, the default diffuse texture is grey in MegaSplat, but white in the standard shader. So if you don't provide them, that is what you get, making the results look really different. I'll update the defaults so that in the next version they match Unity's.

    That said, I still have one case when using Standard packing where, when all 3 textures are provided, the MegaSplat one looks a tiny bit darker than the standard shader. I'm not exactly sure why that is, since they use the same lighting, but I'll continue to look into it.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, did you get the latest from their site or the Asset Store? Because they don't update the Asset Store one much, and I wonder if that define hasn't shipped in the Asset Store version yet?
     
  27. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    126
    I got the latest version from their site ASE 0.3.0 dev 03 from 2nd January. I email with Ricardo and he told me that version should support MegaSpats
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, I'll take a look in a few hours when the kids hit bed..
     
  29. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    The problem is not the diffuse color or the darker looking but the normal map that for some areas seems inverted, giving that checkerboard look. In that areas the painted textures looks different, as in this screenshot. I simply filled the top layer with diff_sharp_02_diff texture and the result is the checkerboard looking. In this image you can see the light parameters too.
    Snap-2017-01-04-at-06.54.00.png

    If you look in the lower right corner you can see that the texture orientation is different. How can I change the orientation to have a seamless looking ?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ah, got it- one sec, I'll send you a patch..
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, I looked at this tonight and sent an email to Rick about it - for now, remove the #if AMPLIFY_SHADER_EDITOR and matching #endif and they'll show up. We'll have to figure out a good way to conditionally compile them in, or I'll just include them without the #if #endif in a zip file in the next release..
     
  32. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I've tested your patch and the normals now looks fine. The direction of textures, instead, still has problems.
    What I do: I simply filled the mesh wih the texture (top layer), it looks like each mesh element is Painted with a different UV orientation.
    I made a little movie that show this: while changing the texture scaling, is easy to see that each element of the mesh get different splat texture orientation.


    PS I've just realized that probably what I need is splat textures in world coordinates, to avoid seams when I paint on adjacent meshes
     
    Last edited: Jan 4, 2017
  33. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Other artifacts using latest patch. This is what I do:
    Put the mesh in the scene, create the shader, create the material, assign material to the mesh, select the Alpha Layer, assign textures to Splats.



    If I fill the bottom layer all the splats artifacts are deleted, but removing the UV3 Channel, the artifacts appears again.

    As usual I apologize for my english. ;)
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That is the expected behavior, since Unity copies the UV data into UV3. Once you fill the bottom layer, everything looks like the macro texture and you paint the top layer to add splat details. When you clear the UV3 channel, Unity reverts this data back to the original UV channel (which is a gradient in the X and Y channels, which makes it select different textures for each vertex).

    That's because it's using the original UVs of the mesh. It would be possible to add texture projection options so that your macro texture uses one set of UVs from the model and your splats use another (planar projection or triplanar), but not without raising the minimum shader model of the shader, because I'm using all the available interpolators in shader model 3.5 already. (Note, because I have a shader generator now, this is all possible).
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    integrating Tessellation & Physics:

     
  36. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    This means that we can expect in a future a new version with world coordinates available for splat maps or some other smart solution to paint seamless on adjacent meshes ?
    How can I change UV for the splats to avoid seams on a complex UV mapped mesh?
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I can put it on the backlog, but I'm not sure when I'll get to it. It's actually quite a bit of work because it means breaking up the shader generator so it can deal with multiple shader versions and adjust the input structures accordingly. I want to do that for optimization reasons anyway, so I'd do that work first. Ideally, I'd end up adding options to use a second set of UVs or one of several projections (Planar on each axis and triplanar, most likely).
     
    StevenP94 likes this.
  38. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    So, if I understand well:
    - UV0 is used for the main texture
    - UV2 is used to paint flow direction
    - UV3 + Color are used for splat layers blending
    probably I miss UV1 scope
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    UV1 is currently open- but I believe this is where enlighten stores it's UV information if you are using that lighting pathway..
     
  40. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Btw tessellation breaks my mesh: where the UV inverts the texture direction, tessellation moves vertices in opposite directions, opening holes in the surface.
    I'm starting to feel depressed :(
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, that's the nature of tessellation. Any discontinuity in the vertices uv or normal will cause a divergent displacement. There's no a great way to fix this within Unity's multiplatform framework other than to not displace those points. I plan to add a way to paint a displacement modifier on the vertices so you can remove displacement there, but that's not going to work well with your meshes since they're broken into lots of small discontinuous areas. You can accept removing displacement along an edge in a large mesh, but not on every edge in a mesh.

    Note, if only your normals (and tangents) are divergent (not UVs), you could use Up bias to have your displacement only go up, but I'm not sure how useful that would be..
     
  42. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    The problem is that meshes have UV mapping because are complex objects and obviously they use UV to define their aspect.
    The Alpha layer painting should use a different mapping instead to allow to paint details, dirt, mud, snow, cracks, etc. without seams between adjacent objects and, as extra, to cover joints between them. So the mapping could be planar just adding a rotation parameter to allow the use of textures with patterns like bricks: Could be very nice to paint cracks with visible bricks through the plaster walls, and so on.
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Right, it just can't do this on a shader model 3.5 device due to the hardware limit on texture interpolators, which requires me to add a bunch of new stuff to the shader compiler to support variable feature levels, so it'll be a while before I can entertain these kinds of features.

    Note that a planar mapping will be insufficient for most models though, since it would only be able to be a top/side or front projection. To work on all sides, you'd need to do a triplanar projection, which is 3x as expensive since you have to sample each texture once for each projection. The other option, which is likely better, is to UV your model twice - once for the standard mapping and once for splat mapping. However, since Unity uses UV1 for enlighten and most modeling apps do not support UVs as Vector4's, you'd likely have to make a choice between lightmapping and a second set of UVs in this case (unless you can use the same UVs for enlighten).
     
  44. aflatau

    aflatau

    Joined:
    Oct 7, 2015
    Posts:
    29
    Hey,

    Just purchased the Mega Splat, and was pretty much what I was looking for.. but is there a way to pain textures with more precision?

    I have attached an example image of what I would like to accomplish.. Currently it seems what the painter does is go off a vertex point and paint from there in X direction to the next vertex point.. is there a way to pain more like the unity terrain system? As in where ever your pain brush is, regardless of where the next vertex is, it will paint at that location?

    If not, is there a way I can make this edge more liner?
    I would like to accomplish being able to have the rocks just go to the red line..
    the blue Xs are not what I want.
     

    Attached Files:

  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    In mesh mode, the vertices are equivalent to the pixels in Unity's terrain system - each vertex is a control point, so to add more control points, add more vertices. In Terrain mode on a Unity terrain, the control points are pixels in a texture map (same as Unity), but the data and how it's used is different. Between any three control points (pixels or vertices) the texture choices are blended based on the height map data and the barycentric coordinates of the 3 control points, which form a 'weight' to bias the height map blending. Finally, a contrast is applied to the blend factor to sharpen or soften the edge. This means that the transition between the textures is controlled primarily by the height maps of the textures being blended; it's not designed around producing linear results, but rather more organic ones.

    If you want to tighten up the blend in a specific area, having vertices which are closer together (for instance, along your red line) would allow you to do that since the area of the blend would be smaller.
     
  46. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    Looking around, I used Uvee https://www.assetstore.unity3d.com/en/#!/content/6933 to check how UVs are mapped
    and I've just realized that we always use the 0,0:1,1 space but there are other quadrants (negative axis) that we could use to store other info.
    Maybe this can help about the lack of UV channel or I'm totally wrong ?
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, they don't work like that. They are just two float values on each vertex which need to be interpolated to the pixel shader; the part that is "full" in shader model 3.5 is that you can only interpolate so many values to the pixel shader. Moving up to a higher minimum hardware fixes this, but I don't want to do that across the board for MegaSplat, just in the cases that require it.
     
  48. aflatau

    aflatau

    Joined:
    Oct 7, 2015
    Posts:
    29
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You turned off read/write on your mesh, so the vertex component cannot access the mesh vertices. If, for some reason, you need to make the mesh static and turn off read/write, then you need to bake the mesh out in the utilities panel.
     
  50. aflatau

    aflatau

    Joined:
    Oct 7, 2015
    Posts:
    29

    It is adding the Vertex Stream script to objects that I am not even painting on... what is up with that?