Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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,711
    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,711
    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,711
    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.
     
    KeithBrown likes this.
  7. bodzi0x95

    bodzi0x95

    Joined:
    May 16, 2018
    Posts:
    11
    Hi,
    is there any option to delete microsplat and go back to default unity terrain system without loosing all textures painted on it?
    Don't asky why, I think microsplat is great but we have more issues than advantages and no time to fight with it, and we don't even use 1/10 of its functionality :p.
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,711
    Yeah, just turn the basemap distance back up.. It doesn't edit anything about the terrain texturing.

    Can you post whatever issues you're having?
     
  9. bodzi0x95

    bodzi0x95

    Joined:
    May 16, 2018
    Posts:
    11
    To be honest it's too long to write, I mean - we have started using it during development when we had some parts of our game done and one of many issues was for example using microsplat with multiple terrain tiles (unity system) was terribly slow and painting textures from one tile to another didn't work well (something like the terrain layers were changing order). Sometimes terrain was loosing material in editor or only in build.. Ofc everything was easy to fix but still I'm only person in team who know how it works and I have a lot of other work as a 2d/technical generalist, too much to run from one to another team member and fixing it.
    Maybe it's because we didn't use it from the beginning and our project was simply not adapted from the beginning to work with all pbr textures and other features (and also I didn't have time to make all our textures to work with height maps). However asset is great and despite all issues I had, I'd recommend it to everyone (way better than CTS in my opinion).
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,711
    Painting is entirely Unity's tool set- the painters I provide (for streams, etc) work fine over multiple tiles. So it sounds like your issues would have been the same regardless of what shader you used.
     
  11. bodzi0x95

    bodzi0x95

    Joined:
    May 16, 2018
    Posts:
    11
    I made the same terrain tiles without microsplat and it works, so as I said maybe it was problem that we tried to implement it during development and few people working with those files. Unity sometimes is weird.
    Anyway, thanks for reply and I will experiment with microsplat for sure, but maybe in next game or when I will have more time :p.
     
  12. dzlucas

    dzlucas

    Joined:
    Nov 2, 2016
    Posts:
    12
    Hey Jason,

    What would be the best place in the MegSplat_procedural shader to modify JUST the output position of a vertice, without effecting the shaders calculation of height / world space for the textures (I'm using triplanar) and height-based noise?

    I'm working on a GPU-only game where I keep my camera at the origin and modify shaders to move vertices around the camera. I modified the MegaSplat_procedural frag files to do this, and it technically works, but the textures move all over the place when I move around since modifying the position also threw off all the UV functions. Right now I'm changing the position at the top of vert() underneath "UNITY_INITIALIZE_OUTPUT".

    Code (CSharp):
    1. i.vertex -= float4(_playerPosBuffer[0].x, _playerPosBuffer[0].y, _playerPosBuffer[0].z, 0);
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,711
    Well, texturing can be in either world space or uv space, so it depends on what you're using. It also depends on which pathway you're using (mesh or terrain, tessellated or not), but ideally you'll need to move the UVs and the worldPos to counter your system.
     
  14. PineappleParty

    PineappleParty

    Joined:
    Jul 31, 2017
    Posts:
    17
    Hi I really need help learning how to use Megasplat. I've owned it for 2 years now. The tutorials are all outdated showing an old UI version. If anyone sees this and could help me learn it I'd be grateful. It sucks to buy something and then not be able to use it. Maybe there is a discord out there for people that do use it? :(
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,711
    There's a discord channel, my server is listed on most of my assets (I just recently made sure it was on every MicroSplat asset). Happy to help you get past whatever hickup has you stuck.
     
  16. thefallengamesstudio

    thefallengamesstudio

    Joined:
    Mar 7, 2016
    Posts:
    385
    Hey. Can you send me a pm so I can ask something privately? It's off-topic. I can't start a conversation using your profile page. You can also email me.
    Just to be clear: I'm not asking for vouchers or favors

    -- Lucian
     
  17. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    87
    Hey @jbooth,

    Another question about your Stochastic Sampler for Amplify shader :

    Do you plan to support texture array input ?

    Thanks,
    Jonathan
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,711
    Nope.