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. FuhaoXie

    FuhaoXie

    Joined:
    Nov 18, 2016
    Posts:
    26
    Hi JBooth,
    I have megasplat always works. but recently it dosent work in builder version, No thing have related to megasplat is changed recently. All the artifact I can recongnized,it looks like alpha texture like tree's billboard and dashboard of car's. Do you have any idea of this? which place should I look into?
    megasplatimage.png
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I just don't know how to work with fbx file with multiple objects with this asset. When I run the converter, it converts but none of the object's original position / rotation is preserved, so when I drag converted meshes, it all just positioned at 0,0,0 ... How do you deal with this?
     
  3. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    I will be dealing with this problem in the near future too. I am watching mesh process C# code and it could be modified:
    1. when the script is looping through FBX meshes it is possible to extract name/position/rotation/scale,....then store this informations in array variable.
    2. then the script is adding all meshes into one asset.....it could be changed to create one asset file per FBX child mesh
    3. put all created assets into scene
    4. last step will be adding another button, which would set transformations for all objects from the variable(step 1.) according their names.

    As Jason many times said, it is easy to do :D
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Still seems like few too many unnecessary steps to me. If I have to do this only once I can take any approach... but making game rarely never happens that way.. so the tool needs to reduce the steps, not create more.
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    It is also worth to note that vertex painter uses third uv set which is the same one that the Unity's realtime GI uses, so in order to do realtime GI , you have to "bake' out the working mesh set first and then replace it in the scene (again) Or have to keep the originals in the scene or save as prefab so you can continue modifying it. So in order for this tool to be better :

    1. converting meshes needs to keep their original transform when instantiated in the scene.
    2. vertex painter / needs to use 4th uv set, so we don't have to keep baking out the mesh for GI baking.

    Also baking combined texture map (for lod purpose etc) causes error.
     
  6. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Just few clicks more. Maybe Jason finds a better solution and fully automatic.
    video
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok.. umm.. nice try. where do you store the transform values into?
     
  8. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    In two List variables. I have send you the code via PM.
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ohh.. I see so you are storing those in the Editor Window script so it will only work for the mesh you created immediately. I thought you were storing it on the asset some where so they are perm. stored... Ha...Sigh..
    Why the world can't just be simple and easy haha.. thanks for the code btw.
     
  10. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    Can I use microsplat and all it's addons with the HDRP in 2018.3? I've been using all modules to full satisfaction in the default unity pipeline, but team is looking to get new project done in HDRP.

    Cheers!
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not sure what you mean here- Unity uses UV2.xy and UV3.xy to store lighting information- MegaSplat does not use these channels (it uses UV2.zw and UV3.zw).
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, they are still changing that pipeline constantly and have no documentation on it's shader system yet, so I'm not going to write a module to support it until that changes.
     
    StayUpLate likes this.
  13. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    57
    hi,
    i'm creating large (100+ km) quadtree planets, with each chunk of terrain starting of as a 64 x 64 mesh plane prefab which is normalized into a sphere. A heighmap is procedurally generated for each chunk with noise, and applied to the chunks to create the terrain. I have looked through the documentation but i cant fully understand whether or not megasplat can be useful in my situation, and how it would be applied to texture the terrain in a satifying way?

    thanks for any insight,

    paul, uk
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MegaSplat has two modes- one uses vertex data to control texturing, but requires that the mesh be preprocessed such that each triangle has exactly one red, one green, and one blue vertex on it. So if you were generating these chunks and wanted to procedurally texture then, you would write the colors into the vertex color rgb values, along with the texture index you want into the color.a channel (so, if it's texture 7 in the array, you'd write a value of 7.0/255.0 in there). You can use a second layer of texturing as well; in that case the texture index is written into UV3.w and the blend between the two textures at that vertex is written into UV3.x.

    The other mode is used for Unity Terrains, and stores the same data in the RGB channels of a texture. So R/G are texture index's for the two layers, and B is the weight between them.

    So first you should decide how you want to store texture choices- by vertex, or from a texture. If your doing quad tree planets, and the vertices are constantly changing, then a texture makes more sense.

    Also, if you're going texture based, you could also use MicroSplat. It's blending is going to look softer from a distance, which is going to be better for planet scale views. It would be the same process, except it uses Unity's splat map format (one texture for each 4 texture choices, with the RGBA channels representing the weights of those textures).

    Once past basic texture choices you likely want to use global scale textures to blend into at a distance- both packages have a version of these techniques (Macro Textures in MegaSplat, or the global texturing package in MicroSplat)
     
  15. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    57
    Hi, thanks for your very helpful reply. In my quadtree planet Each terrain chunk is a prefab (64 x 64 plane ), and the vertex positions are then modified. Would it work to pre process the meshes as prefabs before they are instantiated to get the vertex colours set correctly, and then add the texture choice to the alpha channel as the noise is added? That way i can encode for different biomes/ height / normal angle etc on the fly as they are created. Would that work? Or do the red green blue vertex colours need to be added when the vertexes are in their final positions? Also is there a way to blend between textures in that first texture layer?

    Or using the other mode I can encode texture indexes on r and g channels and blend on the b channel? Which i can do as I add noise to the vertexes? That sounds like it should work.

    Or as you suggest using microsplat, i thought it only worked on unity terrains but that would work in my situation? I didn't fully understand how the textures are assigned microsplat? how many textures can you have in microsplat.
    Thanks for your help

    Paul
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That would work fine. Textures are blended automatically across the face (which means the blend area is equal to the size of the face, though there is a contrast setting- but obviously the blend has to be finished by the time it gets to the next vertex, because each vertex only has one texture choice per layer). However, in a two layer shader, you get two textures per vertex and a blend weight between them (index in UV3.w, blend weight in UV3.x).

    MicroSplat supports 32 textures (though through clustering, etc, can support more, but 32 choices basically). A Unity Terrain is really just a mesh under the hood, but without tangents (these can be generated in the shader automatically for a height map based terrain, so you might have to modify the code to read the mesh tangents instead), and MicroSplat just reads the standard splat map format that unity uses. Basically, for textures 0-3 it has a backing texture with 4 weights in the RGBA channel, then if you have more textures, it repeats this with another texture. MicroSplat is free- so you could give it a go, then buy whatever modules make sense for you (global texturing and anti-tiling being likely candidates).

    I'm assuming you are doing LODs on this by scaling your prefab around, right? If so, then you really want to use a texture backed solution- otherwise the LODs will change the texturing.
     
  17. gaiastellar

    gaiastellar

    Joined:
    Nov 8, 2013
    Posts:
    57
    Ok, so the texture based mode in megasplat seems like the best option. I can encode a texture with the index and blend info for the vertexes of each chunk as they are created. However my one concern with this is that if the material with the shader on can only reference one index/ blend texture I would need a different material for each chunk which increase draw call considerably , whereas if i go down the route of reading the index / blend info from the vertexes and uv3 , then I can use one material for the whole thing and just encode the vertexes and uv3 as i create each chunk. My only query with that is that I'm not that familiar how uv channels work, but i thought uv's are in vector 2 format and the uv3 is already being used? I cant seem to find any documentation on the uv.x and uv.w channel , but don't they normally take values 0 - 1? Or perhaps they can take any value?
    Thanks

    Paul
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You don't need separate materials; the index's you write into the texture are per control point (pixel), so each pixel in the control texture can have 2 textures and a blend weight, and all the chunks could reference the same control texture. UVs are actually Vector4's. The old API assumes Vector2's, but there are new APIs for working with the Vector4 versions.
     
  19. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Well, then for some reason. I can't use Unity Enlighten realtime GI with the prepared mesh, if I use vertex painter to paint splat details. It's the same problem described here :

    https://github.com/slipster216/VertexPaint/issues/16
     
  20. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Now I see it, after painting it somehow shrink the UVs.
    1:40s in video: http://images.bzucko.sk/megasplatRealtimeGI.mp4

    EDIT: Bake Scene to Mesh Cache from vertex paint utility tab solved the problem with realtime GI.
     
    Last edited: Jan 11, 2019
    castor76 likes this.
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's because you have to make your mesh static- look into the section about baking the mesh out in the docs. Basically, the vertex painter uses the addtionalVertexStreams feature, so if you want to mark the object static, you need to bake the paintjob into the mesh.
     
    Bzuco likes this.
  22. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    I just got Megasplat for 2018.3 and I can not seem to load a terrain and get it to work.
    Can you post the steps, as these do not work.

    "To get started with a Unity Terrain in MegaSplat, simply select the terrain and open the
    terrain painter. The terrain painter window will notice that your terrain is not in MegaSplat format
    and ask you if you’d like to convert it."
    Thanks
     
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have compile errors in your console window? Have you tried this on a fresh project?
     
  24. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    No errors show up. I even tried it on the example project by deleting everything and then placing a new terrain. No luck
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you open the terrain painter and select the terrain? What does it say?
     
  26. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    Does not say anything. just acts like normal terrain painter, As if MS was not installed
     
  27. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    Oh S***.... hold on
     
  28. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    I think I am figuring it out. I needed to select the "Menu/window/Texture Painter"
    Now I think I am getting someplace....
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Open the MegaSplat one..
     
  30. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    OK, at least I am now getting someplace.
    upload_2019-1-10_17-16-29.png
    Getting this error
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Doesn't look like anything to do with MegaSplat..
     
  32. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    well.. so the whole work process with preparing mesh and then having to reconstruct the whole world again from converted mesh then paint the splat detail... then having to bake out the mesh again for gi baking... and then you have to do this iteration again and again for any changes to the mesh feels like it is not very optimal work flow...

    dont wanna sounds like a cry baby.. but cant things improve a bit?

    having said this.. why cant the baking happen to the prepared mesh? or paint directly to the converted mesh data? right now we have original fbx, prepared mesh (which doesnt preserve transform info), and then baked mesh for gi ...
     
    Last edited: Jan 11, 2019
  33. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    It happens when I press the "Select material" button on the Terrain painter, so the Terrain painter is not doing something needed. and I just have a grey Terrain I can not use.
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You can insert the baking process into the build process such that it happens at build time, such that your final game gets it done on each compile. There's an included utility function which will bake the entire scene at once, rather than having to do it one mesh at a time, which you can also trigger manually. But yeah, if your changing your mesh data, there's not much that can be done because the mesh needs conversion and you've likely changed the vertex count, which invalidates the vertex information. If there was a way to move that data back and forth between blender/maya/max, maybe, but there isn't a way to do that in Unity really..

    It would be nice if Unity allowed for 'static' additional vertex streams - basically a version of the API which applies the stream at load time and considers it static, but they don't allow such functionality. The vertex painter could be re-written to write directly into the mesh, but then you'd lose a lot of the nice things about it being in it's own data stream (more compact, ability to use one mesh with multiple paint jobs without creating a new mesh, ability to easily remove/undo the data edits, etc).
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Strange- I can test this- maybe something changed in 2018.3, but the call stack doesn't have MS in it at all. Anyway, you can select the material from the project window- all that button does it make a shortcut for it.
     
  36. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    It would be nice if you had some type of tutorial showing where and why to set things up. I have no clue how to get it working.
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The manual's tutorial is always up to date. I can't keep videos up to date because there's like 15 hours of them, but the process hasn't changed in a long time.
     
  38. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    OK, I think I got it working, not sure how. is there a way to change all the scales of the materials being placed on the terrain? They are way to large.
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's a UV scale option on the material, as well as per-texture UV settings which can be enabled.
     
  40. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    Man, I lost everything i did.
    Do you have a walk through showing the exact steps for setting up a terrain from scratch?
    So confusing with so many things called the same thing.
     
  41. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    Would be nice to be able to select a new terrain, press a button and have it set things up as needed. Maybe asking a few key questions?
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's actually what the terrain painter does. You select the terrain, and push a button, and it sets everything up. But you still need to do things like decide what textures your going to use, what settings you want on the shader, and assign textures to the material, etc. I can't really make those choices automatically.. If your newer to this stuff, MicroSplat might be a better fit..
     
  43. SpikeFinch

    SpikeFinch

    Joined:
    Nov 5, 2016
    Posts:
    17
    I am newer to this stuff, yes. I just really want to be able to make the best looking ground I can get.
    Should I keep Mega installed while I use micro?
     
  44. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    static problem... is this related to the static batching only? because if so i can live with the meshes not being static batching. we just need to figure out the way to not interfere with unity realtime gi using the same data stream as megasplat vertex painting.

    my ideal work flow would be...

    prepare mesh. ( for what ever the reason )
    maybe use unity fbx exporter at this point to write fbx version of prepared mesh.
    use vertex painter to paint splat data directly into the mesh.
    use fbx exporter again to iterate mesh in the maya. (if needed)
    at some point bake out gi
    and so on...

    i can live with unable to undo on paint job. i think if painting can be done directly in the mesh then it is going to be possible to move data back and forth between maya.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unless something has changed (unity doesn't document their shaders, like at all), unity's lighting system uses uv1.xy and uv2.xy, and MegaSplat does not use those channels at all. That said, I think someone mentioned it not copying the existing data from uv1/2 when applying the vertex stream, which I should look into. But anyway, there should be no overlap.

    Does realtime GI require static? Because I think it might.

    [/QUOTE]

    It puts data that's needed for filtering on the mesh color channels. This data can be generated in the shader (preprocess mesh option in the shader), but that causes it to invoke the geometry shader, which is a lot slower than using the preprocessor.

    This would, at minimum, require re-preprocessing the mesh because the vertex data would not have the correct RGB values on it, as many geometry changes would cause that data to become invalid.

    Not in any way that will survive significant changes. I've never really considered this option, because it just won't be stable or reliable. It would be worse in programs like 3dsMax too, which allows you to adjust modifiers on a stack, changing the base tessellation of the mesh after it's been modeled.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Doesn't really matter either way, they can coexist in your project, though I personally like to keep my projects really clean. You can try out the workflow of MicroSplat for free, and it's much closer to Unity's system. I personally prefer it for Unity terrain work, because it's a lot less setup, has more features available, and runs faster.
     
  47. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    lightmapping including realtime gi only needs lightmap static. not batching static.
     
  48. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    Don't know if you've seen this Screen Space Displacement Mapping. Just wonder what you're thoughts are on it, and could it be integrated with Megasplat through the customisation functionality?
     
  49. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    Just got this answer on the thread:
    @Bodyclock, it just comes down to the shader being able to export position, color+ lighting, normals and heighmap info to the MRTs and the low poly mesh or terrain being on the DisplacementMappingLayer. The rest is handled in compute shader automatically from there. So if could mod Megasplat in such a way then I do not think it would be a problem.
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, I've seen this technique before. Essentially you modify your shaders to write out the height information into the GBuffer, then displace/distort the screen data to displace it. I've never seen this ship in a game though, because it has artifacts that cannot easily be worked around. Imagine if you have a plane nearly edge on- maybe taking a pixel or two on the screen. Imagine that the height map says it needs to go like this: /\/\/\. Well, you have 2 pixels worth of albedo, normal, etc to work with, so it is forced to interpolate that information across the newly displaced area, which makes it look (and light) very low res. Much like SSR, if you don't have the pixels to work with on the screen, you can't really recover what would have been rendered there.

    Anyway, modifying megasplat to write height into the gbuffer wouldn't be that hard.