Search Unity

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

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

  1. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @jbooth - Playing around with the newest version and wanted to let you know of a couple bugs I ran into. My setup is Unity 5.5.1 Pro, DX11, Forward rendering(to save overhead since its VR) with Linear Color space and running on a Windows 10 box.

    1. When using MegaSplat_procedural, Shader Type Mesh in Single, Project 3 Way and World Space, if you enable PreProcess Mesh it will throw these errors and turn the shader broken pink:

    Shader error in 'MegaSplat/MegaSplat_Example_Terrain': invalid subscript 'color' at line 2805 (on d3d11)
    Compiling Vertex program with LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF DIRLIGHTMAP_OFF
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

    Shader error in 'MegaSplat/MegaSplat_procedural': invalid subscript 'color' at line 5565 (on d3d11)
    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF DIRLIGHTMAP_OFF
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

    Shader error in 'MegaSplat/MegaSplat_procedural': invalid subscript 'color' at line 8322 (on d3d11)
    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF DIRLIGHTMAP_OFF
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

    2. When using MegaSplat_procedural with Single, Project 3 way, Mesh - if I set the Space to Local, it breaks the shader and we get this error:

    Shader error in 'MegaSplat/MegaSplat_procedural': undeclared identifier 'o' at line 980 (on d3d11)
    Compiling Vertex program with DIRECTIONAL
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

    3. With the same shader in the same setting, if I try to set Single Layer Mode to Two Layer Mode it seems to change the material but it doesn't bring back the new set for the Texture Projection Editor. I can see the changes on the material applied to the mesh but have no control over the new areas.

    Thanks for the new features, will continue to play and probably break stuff and let you know about it. :p
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Thanks; I'll get these fixed up tomorrow night; if you pm me your invoice/email I can send you the patch..
     
    Tethys likes this.
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The trick is that you need normals and uv's to line up between the objects. You can see how this is done in the examples, but basically you use the normal blend brush (custom brush in the vertex painter) to blend the normals of one mesh with another, and use some form of world space projection to line up the UVs (triplanar most likely).

    Sorry, this particular workflow isn't heavily documented yet, and only works for meshes, not terrains.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    In line 812 of megasplat_tess_body.txt, change the existing code to:

    #if _PREPROCESSMESH
    v0.weights.rgb = half3(1,0,0);
    v1.weights.rgb = half3(0,1,0);
    v2.weights.rgb = half3(0,0,1);
    #endif

    In line 904 of megasplat_shared.txt, just remove the o. from the beginning of the line and recompile the shader to fix the second bug.

    If you need me to send you a patch I can, but these are simple enough that it seemed fine to post them here.
     
    Last edited: Apr 10, 2017
    Tethys likes this.
  5. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Hi, I have a large landscape made up of 16 tiling meshes which I have painted with MegaSplat.

    I would like to edit these meshes and make changes to them but do not want to have to re-paint the whole landscape again.

    Is there some way of saving and then applying texture? Preferable per tile as this would ensure higher res results.
    Thanks
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If this is with meshes, then there's no easy way to do this. With Unity Terrains, everything is stored in the control textures, so it's easy to do. The big issue with revisioning on meshes is that the vertex arrangement can be effectively arbitrary between two edits of a mesh- you may have added many verts, removed, or changed them in arbitrary ways. If you wanted to write a utility to attempt a transfer, what you could do is copy the data from the nearest vertex (color's alpha channel only, and UV3). It would at least get you close.
     
  7. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Ok thanks, so basically rule is dont paint till mesh is 100% finished :-(

    How about saving each mesh's texture into a color map which can then be used to re-paint the mesh via "Splat from color map"? I did this originally to color the meshs using a color map I made by combining ones exported from RTP.

    So basically a per tile (or mesh) color map which can then be applied on a new mesh/s once it has been edited. SImilar to Render Baking but per mesh so we can use hi res colormap for large landscapes.

    Is this something that could be done?

    Thanks for your help.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It might work, depending on your texture data; if, for instance, you have a bunch of green textures, it's likely not going to know which is which. And then there's the whole issue of the render baker only supporting unique UVs, which may or may not be an issue for you.

    That said, it would be possible to add a new render baking mode to bake out the raw index data (essentially the raw values the vertex painter stores in color.a, UV3.x, and UV3.z). You could then use the VertexPainter's bake texture to vertex feature to bake the data back into your new mesh. I can add this to my backlog..
     
  9. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Sounds like a plan, looking forward to that. Thanks again.
     
  10. ChinChiaYeh

    ChinChiaYeh

    Joined:
    Sep 14, 2016
    Posts:
    23
    "Blend Target" gone in Megasplat 1.04
    Really need this handy tool...
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Whats really.. odd.. I'll take a look tonight and see what's going on and send you a patch..
     
  12. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Ok I have created a new landscape mesh model with the changes I needed.

    I then used Megasplat to convert mesh and added a new material with Megasplat shader, then used util splat from color map and used my original colormap I made which has 8 colours and 8k resolution.

    When I run bake I get weird outlines in some textures only - others look more or less ok, please see attached images of colormap + result.

    Any ideas what may be causing this?

    Thanks
     

    Attached Files:

  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you happen to bake into the vertex color channels? If so, it likely overwrote the data the converter writes into the RGB channels of the vertices. You can press the RGB button to remove this from the paint job in the vertex painter..
     
    Last edited: Apr 12, 2017
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey, so I'm not sure why this suddenly disappeared, but if you go into line 90 of TextureArrayConfig_Brush.cs and change:

    Code (CSharp):
    1.  
    2. else
    3. {
    4.    BrushData.brushWeightTarget = EditorGUILayout.Slider("Blend Target", BrushData.brushWeightTarget, 0.0f, 1.0f);
    5. }
    6.    
    into:

    Code (CSharp):
    1.  
    2. if (layerMode != LayerMode.Auto)
    3. {
    4.    BrushData.brushWeightTarget = EditorGUILayout.Slider("Blend Target", BrushData.brushWeightTarget, 0.0f, 1.0f);
    5. }
    6.  
    That should fix it..
     
    ChinChiaYeh likes this.
  15. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Yes RGB button removes paint, that works but how can I use Splat from color then, every time I run bake I get same results.

    I have created a standard unity plane and went through Megasplat process. This time i have used your Terrain guide image.

    Please see results in attached image.

    Thanks
     

    Attached Files:

    Last edited: Apr 12, 2017
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The data about the splat map is not stored in the RGB channels- it's stored in the alpha channel. So clearing RGB should not clear the paint job. The RGB channels just store filter weights that MegaSplat needs to work correctly.
     
  17. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    yes thanks but this does not help.
    Its just not working for me.
    Any other prog I use to texture my mesh seems to work fine.
    Looks like I will have to go back to RTP.

    Just made a new mesh from my terrain and imported in new project with megasplat and get same problem.

    Can it be related to Terrain to Mesh, but it seemed to work 1st time around though.
     
    Last edited: Apr 12, 2017
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I'm not exactly sure what you are trying to do- are you trying to convert the texturing from a Unity Terrain into a vertex painted mesh?

    The issue you are having is that you are overwriting the RGB channels with some kind of data. I don't know why you are overwriting them or what you're overwriting them with, but those channels are used by MegaSplat to filter the texture choices, which are stored in the alpha of the color channel and UV3. If you are trying to convert a Unity terrain to a mesh, I would suggest using the terrain converter to convert it into a MegaSplat terrain first - then take the control map it uses, and project it's data onto the vertices (the control maps red channel should go into color.a, the green channel into UV3.w, and the blue channel into UV3.x). You shouldn't write into the RGB channels AT ALL..
     
  19. StevenP94

    StevenP94

    Joined:
    Jun 3, 2013
    Posts:
    143
    I think he is trying to save a paint to apply back on a new terrain after geometry changes...
     
  20. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    1st thanks to @jbooth & @StevenP94 for looking into this - I'm going round in circles here :)
    This is what I have done.
    1st step, I painted my terrain mesh (not unity terrain - its a mesh converted from a Unity terrain using Terrain to Mesh) with Megasplat using Color to Splat by using an 8 colour image and defining 8 colors.
    This worked well then I retouched all the terrains by manually painting using the custom vertex paint tool tools.
    The terrain is fine but has a lot of data that will not be visible so basically I wanted to remove parts of the mesh.
    I then found there was no easy way of doing this.

    So I started from scratch. This time I changed terrain before.
    But now when I use Color to Splat I get as you say data in the RGB channel - I dont know how its getting there.
    Could I send you the colormap image and maybe you can test and see if this is causing the problems?

    Thanks
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Sure, I can take a look.

    Last night I added a way to render bake out the splat data from a mesh, which might make this much easier in the future. I can add an import utility as well, so you can just bake out the splat data, then suck it back in on the new mesh. Note that there is no correct way to interpolate the data between points, so what I do is take the highest weighted texture index. Overall, I think it should work out pretty well, even if you have a somewhat arbitrary set of changes.
     
  22. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    This would be great. It would be very useful to be able to apply the same data to different meshes.
    eg Once I painted my mesh I noted that I could reduce verts due to the excellent results MegaSplat provides so a way of saving the paint data, and then applying it to an edited mesh will save a lot of hours. Even if the mesh cant be edited directly and a copy has to be used.

    Thanks
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Might be easier for me to just send you this once it's done - if you send me your invoice and email, I'll do that.
     
  24. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Will pm you.
     
  25. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    OK heres another test I did inspired by your suggestion.

    Created a unity terrain using WorldCreator and textured this with 8 textures using the same guide image I sent you.
    This worked with no problems so now I had a full textured unity terrain.
    I then added the Megasplat terrain painter and used the Terrain Convertor to assign Megasplat textures.

    This worked flawlessly however when I zoom out terrain turns black which I assume is due to no basemap is this correct? Is the idea to use a macro texture instead of this?

    It would be ideal to be able to save the current u-terrains MegaSplat texture via splat maps, then convert u-terrain to mesh, then be able to apply the texture/splat maps again to this mesh.
    Then if we wanted to create other meshes like for LODs etc, simply create lower res meshes and re-apply the MegaSplat texture. This might be a sort of workable workflow in order to make changes to terrains.

    Update:
    OK Ive made a mesh from the u-terrain, copied the Megasplat Material, changed shader from terrain to megasplat and applied to new mesh and it worked fine.

    So if this correct all I need do make changes to another mesh then apply the material and thats it?

    Update:
    It no works when I change from terrain to mesh in shader properties all is lost :-(
    I thought I had found a solution.
     
    Last edited: Apr 12, 2017
  26. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Greetings @jbooth - We had a little feature suggestion. Any chance we can get the awesome glitter effect added to the snow? Like in Battlefield or Battlefront, or in the event you haven't seen one of those games that have it, like the main screenshot on the RTP page: :p

    https://www.assetstore.unity3d.com/en/#!/content/5664
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Already there- crystals..
     
    Tethys likes this.
  28. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Ahhh, thanks man!
     
  29. Martin-Baun

    Martin-Baun

    Joined:
    Apr 12, 2015
    Posts:
    7
    Hi
    Where did you get the 60 PBR textures from that comes with Megasplat? I currently download textures from Gametextures.com and repack them in Photoshop.
     
  30. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    We use that resource as well, but recently moved over to Substance Source (which has many textures from GameTextures but correct PBR values, unlike many of the textures from GameTextures). For $20 a month its a pretty decent value if you also need something like Substance Painter or Substance Designer. Lastly, I thought I would mention that we had the same workflow(texture source to Photoshop for editing to Unity to use) but we recently started using this great texture packer asset and it saves a LOT of time and effort. I have no relation to the asset developer, just sharing it here because it works good with MegaSplat and saves time.

    https://forum.unity3d.com/threads/channel-packer-pack-your-maps-in-a-textures-image-channels.456057/
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I made them in Filter Forge and Substance Designer, since both tools could easily create variations for texture clustering.
     
  32. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Is there by chance something wonky with the way the Cluster Noise works when doing the automatic terrain conversion? No matter what I set the cluster noise to in the window, it either does nothing and only shows a single texture, or it at best generates a few random splotches that look nothing like the noise. Using the brush on the same area with the same setting produces much better results.

    Auto-generated: grass almost all one texture with a few random splotches of second and third
    Capture.JPG

    Same area after going over it with the brush: much better mixture.
    Capture2.JPG

    This is with the default grass cluster at the default cluster noise setting of .05 for both.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yup, there certainly is.

    the fix is to change line 58 of TextureCluster.cs to:

    int texIdx = (int)(n * range);

    Should be fixed in the 1.05 patch, which is basically ready, but easy enough to patch yourself...
     
    Tethys and makeshiftwings like this.
  34. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Ah, that's much better! What a difference a set of parentheses can make. ;)
     
  35. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    We are really impressed with MegaSplat and have adopted it for our game after extensive evaluation. I'm working in Unity 5.5 with surface texture sets from Quixel Megascans, and overall they look great. However, even after inverting their Roughness maps to make a Smoothness map, for NormalSAO packing, I am still getting really bad specular highlighting on all the textures. I've checked to see that the metallic level is 0 for all the textures in the shader. I've compared the texture channels and formats with the examples in the MegaSplat package. I've compared the material configuration settings for my Terrain shader to the examples over and over again. And I can't find anything different that would create this excessive glossiness.

    Is there something simple I'm overlooking?
     

    Attached Files:

  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Can you show me one of the textures? Common issues people have with NormalSAO include:

    - Not getting the packing correct
    - Not importing the textures as linear
    - Not setting the TextureArrayConfig to linear

    When in NormalSAO without using PerTexture properties, the metallic value comes from a global slider under the Splats section of the shader. If you turn on PerTexture Material settings, then each texture can have a single metallic value.

    Having played with it, I notice one bug in that the global slider is only shown when your in NoSpecTex packing mode - when it's actually being used in NormalSAO as well. If you switch to NoSpecTex, see if the metallic slider has value, set it to 0, and switch back to NormalSAO. I'm betting that's what it is- I will expose it in the next release while in NormalSAO mode..
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Development Log 16 is up, covering:

    - Procedural Texturing graph editor
    - Transferring paint jobs between mesh revisions
    - Rain Drop filtering on slopes
    - Etc...

     
  38. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
     
  39. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    OK, so I rebuilt one of my Quixel textures from the source and it behaves properly with my TextureArray and shader. So I will just have to go back through that process again. Thanks again!
     
  40. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Awesome new features. It's amazing how great this procedural stuff is coming out. At 29 minutes into the video the results are looking pretty darn good for not being painted by hand. Good stuff, thanks for the video!
     
  41. WileE

    WileE

    Joined:
    Apr 12, 2016
    Posts:
    21
    Are macro textures working in 1.0.4? (Unity 5.5.3) I did the macro bake from the Utility tab, and all of the generated textures (Albedo, AO, Smoothness, Height, and Normal) are the same as the Albedo. I'm pretty sure it's not supposed to be that way. If i just put an alpha channel in the albedo and then attach it to the both diffuse and normal macro slots in the Material, it shows up if I choose Macro On Top (it's a bit dark and flat, but I assume that's because there aren't any normals or height info in there).

    But if I choose Fade macro and even set very close distances, the macro texture is never used.
     
  42. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    I'm working on a dynamic terrain LOD system for my project, basicly I'm just disabling terrains and replacing them with generated chunk models at runtime. Every thing is working but I am having a hard time figuring out how to transfer the megasplat terrain data to the mesh at runtime. If I assign the LOD mesh renderer to use the terrain template material then is works but at certain angles the mesh will disapear (I'm not sure if this is a culling issue or a mesh using terrain shader issue). So I am trying to use a instanced mesh shader instead and transfer the splatmap data at the start of the scene but I have no idea how to access the texture array data from the terrain shader. How would I go about getting texture array data (splatmaps, diffuse, ect) from the terrain shader through code?
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I just tested these and they both appear to be working fine (I used the mesh example scene). Any other info?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Well, in theory the mesh you generate should work fine using the same material/shader as the terrain does. The main difference between the two techniques is where they pull the splat map data from (verts or texture). However, if you want to transfer the information to the mesh, you'd need to copy the data from the terrains splat_control texture into the vertices (Red -> color.a, Green -> UV3.w, Blue -> UV3.x).

    The culling is likely something being wrong with your bounding volume on the mesh you're generating. The shader should make no difference here, as it doesn't know anything about culling.
     
  45. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Thank you for the answer to my question.
    Hope for some more infos and documentation later so i can make great looking overhangs that transfer smoothly into terrain (i know, meshterrain for now).

    Because i read somewhere in the thread that megasplat support mapmagic i would like to know if you will try to support also voxeland from the same publisher?

    He wrote in his thread that voxeland can be used together with mapmagic so i hope for megasplat support too.
    https://forum.unity3d.com/threads/v.../page-13?_ga=1.67992401.1918894172.1467142881
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I believe the map magic integration is going to ship in about a week. I don't know what the status of voxel land integration is, as I know he has combined some of their feature set to work together (map magic and voxel land).
     
  47. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Hi Jason, I just followed through on you video of MegaSplat Mapmagic conversion. Quick Tutorial: Converting Unity Terrains to MegaSplat
    When I got to the section of convert. See attached. It does not apply the Megasplat materials to the MM materials layout.
     
    Last edited: Apr 17, 2017
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Check your terrain settings and make sure the material type is set to custom and that the megasplat material is assigned. Also make sure your megasplat material has the texture arrays assigned in the "Splat Data" section.
     
  49. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    I went back through it all. Possibly my laptop does not have the horsepower. Thought it plays all of your demos. I will check on my desktop tomorrow.
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Shouldn't matter - it's not processor intensive, I do all my dev on a several year old laptop.

    Can you post a screenshot of your material settings?

    Also, a direct map magic node integration is coming in a week or so, which will make all of this much easier.