Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

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

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

  1. azukaar

    azukaar

    Joined:
    Jun 3, 2013
    Posts:
    1
    Hello!

    I was interested in this asset but first I wanted to make sure it is suited for my usage.
    I currently generate a cubic voxel world using submeshes to split materials and I thought using MegaSplat could reduce the number of draw calls as well as providing texture connection abilities, but I have a few questions.
    - It seems to be using RGBA diffuse channel for mapping texture, can I use, say, UV4-7 for it instead? I actually do use the RGBA channel for texture color variation
    - The shader can load up to 256 textures, does that mean 256 per shader or per mesh? I would most likely have more than 256 blocks available, in that case is this going to be a blocker? If yes, can I use sub meshes in range of 256 textures? (ex: sub mesh for 0-256 then another one for 257-512)? Can I still connect texture between two submesh with 2 different instance of the shader?
    - As far as I understand I should use the node in Unity's UI to feed the textures to the shader, but can I actually load the texture at runtime? In my case I would like to do something like getAllBlocks listing all the block available at run time, and generate the shader. Is this do-able?
    - Which feature will I be unable to use as part of a procedurally generated mesh? (Outside from the obvious with the brush) I'm guessing things like flow maps
    - Are those 256 individuals textures or individual materials (ex: if Lava is part of it, can I give it different material shading options)?
    - I am using different UV scales per blocks (ex: the grass repeats every 4 blocks but the folliage every 2 blocks) will this break the connection?
    - Can I individual set which material can connect smoothly and which needs to have a hard line?
    - Can I manage things like non planar geometry? I have cubes with non connected faces (as in each face of the cube has 4 individual vertices) and sometime (ex: plants and folliage) those are crosses instead of cubes, do I need a separated strategies for them?

    I appreciate this is a lot of questions, thanks in advance for your help
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,678
    You'd have to rewrite the shader system to do the lookups in the new UV locations, but it doesn't really matter where they are stored. Right now it uses UV0-4 and color for everything, because 4-7 were just added by Unity. Thought it's likely easier to add your colors to the UVs instead- less code to change.

    So the shader limits to 256 because vertex colors are often truncated to a fixed precision. If you were to store the same data in a UV channel you could have up to 1024, because thats the maximum allowed textures in a texture array. This is for each mesh, so yes, you could have one submesh use a different set of textures than the next.

    Unity doesn't allow shader generation at runtime, but I don't think you'd need to generate a shader - because that can be fixed regardless of what texture you use. To pack the textures at runtime you'd have to generate a texture array with the appropriate textures in them. What I usually suggest people do when they want to dynamically load and select textures, in some kind of user generated content way, is to pack all the textures into various texture arrays however it makes sense for loading, then Graphics.Blit into the actual array from the source arrays at runtime- that way you can still use my preprocessor to get the textures all into the correct formats and such, as the formats are not what people are used to for speed/quality reasons.

    The data for all of that is read from the vertices, so as long as you paint the vertices with the right data it won't care. You might want to look in the docs (linked in the asset store) as your mesh needs to have some data in the color channels to work (a preprocessor is included, but when generating at runtime you'll have to provide this data), and the format for everything is also described there.

    One material, 256 different textures in use. Effects like Lava are procedural and don't take those texture slots.

    Per texture UV scales are available, so as long as the scale is associated with a texture choice it should be fine. Interpolation between textures is based on the height maps, so you could try to create hard edges by messing with the height maps, but in general it's going to create an edge based on the height maps (note there is a blend factor called interpolation contrast to control how blurry this is). MegaSplat doesn't really care about your topology and works on arbitrary meshes, as long as the color channels have the required information on them.
     
    azukaar likes this.
  3. nlaha

    nlaha

    Joined:
    Mar 14, 2015
    Posts:
    2
    I tried restarting and reinstalling and it's still giving me that error.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,678
    Somehow the assemblies aren't getting patched. You might need to clean your library folder? Hard to say..
     
  5. hasseyg

    hasseyg

    Joined:
    Nov 16, 2013
    Posts:
    37
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,678
    No, the custom function node is not sufficient to perform the task; it doesn't allow people to have options on their nodes, and would essentially turn the single node I provide into 27 different nodes to handle all the different options. Unity talks up the custom function node like it's a replacement for a proper API (which they have and closed off) but they are totally wrong about this, and it's another sign they don't understand their users or dog food their own products. If it was sufficient, they'd remove all their custom nodes and just use the custom function node instead, right? Lame.

    So what happened is unity closed down the node API to try to force people through this route in 2019.1, and everyone who wrote custom nodes was forced to hack the assemblies on load to get access to the internal API. It's possible that the assembly hack has failed and simply uninstalling and reinstalling it will work, or they changed something about the internal API- I will test once 2019.3 is out of beta. My suggestion is to use a proper shader graph like Amplify and abandon Unity's closed system for something more stable and extensible by the user. It's a better shader graph anyway, and I'll happily refund you for the unity version if you'd prefer the amplify version instead.

    Every day Unity manages to make writing shaders a little more difficult.