Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

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

  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Sorry, I must have missed updating the docs. Just create a Megasplat Shader and set its type to terrain.
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    A
    The sliders aren't there because unity hides them if the window isn't wide enough.

    The conversion process should just work; but a few things to check:

    What is the texture scale in your material set to? You likely need to set this to some large value so the textures aren't scaled once over the whole terrain.

    Additionally, the texture size property under 'Terrain Data' needs to be set to the same size as the backing texture and Unity terrains splat map data size.
     
  3. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    735
    that was exactly my point! many thanks Steve-Tack!
    MegaSplat will surely become a must have!
     
  4. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Oh, you mean the one that's not only in the documentation, but also in your example scenes? :D My bad.
     
  5. Kiwi-Hawk

    Kiwi-Hawk

    Joined:
    Jul 17, 2015
    Posts:
    288
    To posts and ignored twice, not sure I didn't waste my time and money on the guy
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    My reply is three posts above this. If you expect a personal man servant for $40, I'd rather not have you as a customer.
     
  7. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    Trust me, you didn't waste your money, Jason is working really hard, and Mega Splats is very impressive, so no way has anyone wasted there money. in my opinion.. and at first, I was concern, but after seeing great support, updates and how well Jason's tool works, its been one of the best looking I have seen on the store, and I own a lot of them..

    /cheers.

    thanks Jason for your hard work. Its looking great on our new mobile game,with a great looking terrain so far.. Our testers are amazed and very happy due to MEGA Splats.
     
    Steve-Tack, Teila and StevenPicard like this.
  8. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    Nice.!
     
    StevenPicard likes this.
  9. Kiwi-Hawk

    Kiwi-Hawk

    Joined:
    Jul 17, 2015
    Posts:
    288
    Kia ora

    I'm sorry man really, Firefox was not reloading correctly (was using the old cache) I was trying to get into sorting out the issue and could not see the answer, what with Firefox playing up and me getting frustrated I lost it a bit and snapped at the wrong guy (should have walked away for a bit) again I am sorry, don't get ole lol. BUT I do have the stones to front up when I'm wrong, thank you Sir for ALL your effots. I'll slow down so my head can keep up.
     
    StevenPicard, Teila and jbooth like this.
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Ok, so I'm finally back in the country and not on a boat with $1 a minute internet access..

    While I was gone, I still managed to get some work on MegaSplat done:
    • Unified core splat map code, so that all 4 shader types (tessellated or not, mesh, terrain) run through the same pathway. This will help me prevent bugs in the future, but also means that all features are available in all modes.
    • Finished tooling for painting flow maps, puddles, and displacement dampening on Unity terrains.
    • More control over UV mapping. You can now choose UV0 or UV1 or project UVs in local or world space on any axis. You can enable a second set of UVs (which unfortunately bumps the minimum shader model up to 4.0), so you could, for instance, have your macro texture use UV1 and your splats UV0, or use a projection, etc.
    • Added more features to the puddle system (multiple specular models, for clean and dirty puddles)
    • All the other stuff posted above. This release is a huge amount of changes in all.
    Before I'm ready to release this version, I will likely add support for a second macro texture. Why, you might wonder? Well, if you've played with the macro texture modes, you'll notice it provides a lot of options other than just fading into a macro texture at a distance. With the new UV modes, you could easily use the macro texture to project a vertical texture onto your terrain to create striated landscapes formations. However, then you wouldn't be able to use the macro texture optimization. So rather than adding a feature just for the striated landscape formations, I'm considering adding a more general feature for a second macro texture, which can easily be used for a striated landscape, but could be used for other things too (such as projecting a "tint" map over the terrain, while still using the switch to macro texture in the distance optimization). While not as obvious as adding a 'striation texture', it's more powerful and general. Hopefully tutorials and documentation will be able to make up the difference in usability.

    I also need to test the crap out of this release on Windows as well as Macs, as there are a ton of changes and refractors. I'd like to get this submitted early next week if possible.
     
    Goodgulf, StevenP94 and StevenPicard like this.
  11. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    How'd you get it to work well on Mobile? I'm still newish to shader stuff, but i believe I turned off all the options I could for Megasplat, but it still ran slow. Like under 20fps. I'm gonna try it again with the no-normals option once that comes out.
     
  12. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Come on!
    This guy create revolution in Unity terrain system :)
    I think since Unity going more and more AAA they should make MegaSplat a part of.
    The current Unity terrain system is really bad.
     
    Last edited: Jan 26, 2017
    Teila likes this.
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    This is all going to depend on what you consider mobile - an Ipad Pro is roughly 100x faster than a low end mobile device, so the range is much wider than we see on PCs. I haven't done extensive testing of MegaSplat on mobile, but here's what I would try:

    Switch to meshes instead of Unity Terrains. Unity's terrain system doesn't give you a lot of access to it's internals, so there are only a few ways you could do the MegaSplat technique on a Unity terrain. The technique MegaSplat uses is to store the choice of textures and blends in a texture, sample it, and reconstruct virtual triangles to perform the same technique that the mesh version uses over the terrain.
    However, this has one major drawback. It creates what is called a dependent texture read on the GPU. This is where the GPU must wait for one texture to be read before it can read the next set of textures. This doesn't happen in Unity's shader because it can sample all the needed textures at once, then use the results to blend the pixels. That's why it's limited to so few textures though. But MegaSplat must sample the control texture first, then use those results to sample only the textures in the array that are actually used for that pixel. With a mesh, none of this is necessary because that data is passed to the pixel from the vertices. If you are going to use a terrain, I suggest keeping the control texture size reasonable (which can look better, IMO, anyway) as this will make it more likely that that data is in the cache and fetches quickly. You can also set the control texture to point sample, which is a bit faster (I'll be doing this in the next update automatically).

    The rest is more obvious stuff, like turning off flow mapping, using a one layer shader, and using NormalSAO packing instead of something that takes more textures. A one layer basic MegaSplat shader on a mesh should be faster than Unity's terrain shader with 4 textures, but might be slower on a terrain, or with more features turned on. The cost of these various features may vary with GPU as well.
     
  14. ikefrc

    ikefrc

    Joined:
    Jul 3, 2012
    Posts:
    81
    Could you add a way to have textures snap to grid (maybe per texture property)?

    We have the following issue:




    As you can see we cannot fill the grid completely (the grid is 4 Game distance units big).
    The splat overreaches.

    So when we use our in-game realtime road painter the road is just a little bit too big:

     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Hmm. The problem is that MegaSplat uses height blending to resolve it's blends, as that looks much more natural on terrains, so it's not really designed to do hard edges between surfaces (well, unless your height maps are designed as such). If you were to increase your texel/vertex density, you would get a smaller transition area, but it will always be an area, not an exact line, and what happens within that area is determined by the height maps that are being blended.

    What I would suggest is using polygons for your actual road surface (which gives you an exact edge, directionality, etc), and using the megasplat modification you're doing to blend in the edges of the road (rubble, etc). To create this type of effect:



    This gives you the directionality you'll need for road lines or brick direction (if you're doing fantasy type roads) and very tight transition points, but uses MegaSplat to blend those roads into the surrounding terrains in a pleasing manner.
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Also, do you have a cloudy texture for your road height map or grass? Because it looks like the height data does not match the brick data, otherwise I'd expect to see the grass go into the brick cracks before covering the bricks.
     
  17. ikefrc

    ikefrc

    Joined:
    Jul 3, 2012
    Posts:
    81
    The in-game road painter sets both top and bottom texture to the road texture. Height map as in normal map?

    This is the road normal map:
    upload_2017-1-26_17-58-6.png


    The thing is, it kinda is a straight line (a little rugged), just at the wrong spot. It overreaches by 10-20%.

    upload_2017-1-26_17-59-25.png
     
  18. ikefrc

    ikefrc

    Joined:
    Jul 3, 2012
    Posts:
    81
    A blend is not a problem for us, if it only would not overreach the Tile by so much it would be fine for our use:

    upload_2017-1-26_18-20-17.png

    I feel like other than the overreaching, it works perfectly for our use.
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Well, in that case, you need to subdivide your mesh or adjust the resolution of the splat map texture so that the blend points lie slightly closer to where you want them. If you are, for instance, at 4 pixels per game square, maybe try moving to 5.
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Come to think of it, one thing I might be able to add is some kind of blend bias in the per texture properties which changes the slope of the blend factor. I'm not exactly sure how this would look, but essentially it would let you make the linear blend across the triangle (which is perturbed by height) biased to a curve, causing it to pull in or out towards the control point. After I finish testing this release and get it shipped, I'm going to refactor PerTexProperties to be much more general, and can look into trying something like this.
     
  21. ikefrc

    ikefrc

    Joined:
    Jul 3, 2012
    Posts:
    81
    Thanks for your help, I tried not filling the complete road square (before I was filling the full 4*4) and i think i can work with that. Just had to make sure to overlap where 2 roads connect.

    upload_2017-1-26_18-50-32.png
     
    jbooth likes this.
  22. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    I finally started to play with Megasplat. It looks impressive after a few hours of testing/learning. Rereading the manual and testing and trying again. Next step would be to test the textures, to find the best way to have a nice blending and the appropriate number of textures in each cluster, based on the desired look.
    I do have .fbx files format imported in the scene with 3 LODs included in each imported .fbx file. Workflow wise, what would be the best way to avoid all the extrawork during the mesh conversion (cloning/duplicating, renaming after baking, reparenting to keep the GroupLOD working). I was asking myself if it's possible to convert the original mesh, without duplicating it, and baking it when all the painting is done. If some mistake is done during the painting process, I would rather delete it and reimport the fbx file.
    I'm asking this because I have some floating island with 16 parts/tiles each and the plan is to have 12-16 floating islands in each scene.
    Thanks!
     
    StevenP94 likes this.
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    It's not really possible to replace the original mesh, since Unity doesn't allow you to save FBX files, only .assets. Additionally, the converter often has to add a few vertices, so it can't stamp the data on the vertices as part of the paint job. That said, I think the converter could be improved to batch covert things so you could drop them all in at once and convert them all.

    Sometime, when I get a moment, I want to do a little video on clusters, control point density, etc. A lot of people go straight for the two layer shader, but if you design your clusters well and keep your control point density low, you can get a really good look with a one layer shader. Mainly, design your clusters so they have a wide variety in them (grass, several grass+rock textures with a different density, all rock, rather than just variations on a theme, or even make clusters that share textures with other clusters). When you have a low control point density, the blend area between each painted cluster gets wider, so closer emulates the transitions people want from a two layer shader (soft transitions).
     
  24. Kiwi-Hawk

    Kiwi-Hawk

    Joined:
    Jul 17, 2015
    Posts:
    288
    Do you have a tutorial that would help convert textures correctly? some of these natural tiling textures of them there US mountains are really quite neat and look great https://www.assetstore.unity3d.com/en/#!/content/35173 and hey bet you couldn't beat the price mate lol
     
  25. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Ohh, that would be of great help! Maybe taking /selecting all the desired meshes and dropping them all at once might work?
    I can go with obj file format if needed. I just want to avoid all the annoying and tiring work. Only to manually reparenting and renaming the painted objects for LOD to work is really killing me.

    Yep, I was even thinking to use ZBrush's Groups Loops to channel the flow of the polygons according to the surfaces/textures and have this way lighter or bigger, size wise, meshes. A bit of extrawork there, but maybe possible with some interesting gains.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    It's all in the docs; basically you want a diffuse + height map image, then choose a packing format for the normals/specular components and pack them all the same.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    pretty sure you can select all the submeshes in an FBX file and convert them all at once - but I haven't converted any meshes in a while or looked at that code so I might be wrong..
     
  28. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    I need to convert only the LOD0 in every fbx file. The others (LOD1, LOD2) are far away from the player, so no need for that. I was thinking to filter with LOD0 the scene assets, shift select and drop them all in the converter.
     
  29. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @jbooth I don't know if you understand whats causing the faded texture look in the window.. the textures seem to paint fine. They are represented in the window at half the color they would normally show.. I'll show you the array window a couple textures show as normal.


    Showing textures normally:

    upload_2017-1-26_21-41-8.png
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    I don't, but was planning on looking into this tonight as part of my bug pass. It's most likely some difference in how the light skin handles default colors with GUI commands, as I've found a few of these issues before.. Should be an easy fix once I narrow it down..
     
    Ascensi likes this.
  31. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Thanks, I squeezed out a couple more FPS (it's actually running at ~12), which isn't gonna be good enough for (lower end, running on Moto G4 Play which is new but low end) mobile yet. Probably need about double that. I'll probably hold off on doing mobile stuff until I buy the next tier up, thinking a Xiao Redmi 3 Prime(or perhaps if the tool gets more optimized for mobile, but I understand that's not a real priority atm)

    I still really want to use it, so I think I'm going to play around with terrain creation for a bit.
     
    Last edited: Jan 27, 2017
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Ah, Android. I swear they throw parts in a box and see what mates to create those things.

    I do mobile at work, so I'm well aware of the issues. The problem is that the quest to basically give these things away for free or < $50 has resulted in them selling some really crappy devices. Additionally, they often are not balanced very well; I have one device at work that is about a year old, has a 3k screen, but the GPU is so weak that it can barely fill that screen with text, let alone do 3d rendering at full resolution.

    One thing you may want to try is simply lowering the screen resolution. The simplest way is to use Screen.SetResolution. However, what we do on our current game is a little more complex. We run the rendering back buffer at 16bpp and a reduced resolution (as a render texture), then blit this to a higher screen resolution in the post processing. This way we can run our UI at 3/4th of the device resolution, but render at 1/2, and since we do a fair bit of color correction and noise in the post processing (which happens during the upsample to 3/4th res and is done in 24bpp color), you can't really tell the difference. Even rendering the back buffer at 1/4th resolution is acceptable (but noticeable). This can gain back massive amounts of fill rate while still providing decent quality, and the UI is still sharp an crisp.

    With the back buffer at 1/2 and 16bpp, it's a 1/4th the fill rate, and 1/8th the memory bandwidth. To do anything reasonable in 3d on low end android, you pretty much have to do stuff like this.
     
    auhfel likes this.
  33. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Thanks! I had no clue you could do that, and likely never would have even thought of it. Throwing down to 640x480 pumps up fps to ~26, which is really good enough for me on a mobile device. If I design accordingly, I could probably come up with a nice style that will complement the lower resolution well enough.

    I'll have to check out how I would implement your more advanced method. I'm really only a slightly-past beginner programmer, so it should be fun finding out how to do that stuff!
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    A lot of those devices have a 1920x1080 screen on a 4 inch phone, so you can't actually see those pixels. The nice thing about using multiple resolutions is that you can get even more speed by going to 16bit color, do post processing in the upsample shader, and still render the UI at higher resolutions so text, etc is crisp. It's not that much code to do it, but you'll have to dig deep into the graphics pipeline to do it. This is likely a 40% speedup over just using Screen.SetResolution for similar quality.
     
  35. Kiwi-Hawk

    Kiwi-Hawk

    Joined:
    Jul 17, 2015
    Posts:
    288
    Kia ora

    Do you get to choose the text colour when you make the UI's? I ask because with Unity standard the array interface and a lot of those UI area's show white on the dark UI (only Pro version) but on the standard UI is shows as white on white and is almost impossible to read, something that may have slipped passed as your using the Pro version. Feedback ment as help NOT a complaint, food for thought
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    I just fixed this and a few others in the patch I'm currently uploading.

    The problem is that Unity has different defaults for things based on pro and standard mode. For instance, the textures drawing dimmed was because I was calling:

    GUI.DrawTexture(rect, texture);

    On pro, this draws the texture without alpha. But on non-pro, it draws it with alpha, so you have to do:

    GUI.DrawTexture(rect, texture, false);

    A previous one was caused by this code:

    // works fine in pro
    GUI.DrawTexture(rect, texture);
    GUI.Box(rect, "");

    // but draws a grey box in standard, so you have to do
    GUI.Box(rect, "");
    GUI.DrawTexture(rect, texture);

    Basically, on pro, the box style is defined with alpha of 0, but on standard it has alpha of 1.

    Silly stuff..
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    0.97 has just been submitted. Here's the change list:

    - Feature parity between terrains and meshes. You can now flow map terrains, paint puddles, etc.
    - Paintable Puddles, with multiple reflectance models and flow mapping.
    - Examples of painting at runtime, extremely optimized with extensive comments
    - Batch save of meshes to asset cache. You can insert this into your pipeline to automatically convert meshes to static before lightmapping or builds.
    - Use of multiple UV sets and projected UVs in world or local space added for splat and macro textures.
    - Added support for Ramp lighting model, which uses a texture for diffuse response instead of computing lighting
    - Added support for a diffuse only lighting mode, removing the need to sample normal maps. Can be used with Ramp lighting for NPR rendering and extremely cheap rendering.
    - Only brush selection is encapsulated by scroll window in painters
    - Added hooks for third party tools to listen to paint strokes
    - Added PerTexture Contrast control option
    - Preview sphere render re-written using BeginStaticPreview
    - Controls for displaying vertex normal/tangent now only show in brushing area. When working with large meshes, the old scheme was prohibitive
    - Optimized vertex painter brushing by roughly 2x
    - Unified surface functions between all four shader types, reduces chance of code divergence and bugs
    - Fixes to RenderBaking
    - Fixes to color scheme and texture display on non-pro Unity
    - Fixes to warnings in vertex painter preview shader
     
  38. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Hi!

    Is there an option in the shader to have the "Diffuse scattering" effect like in RTP / UBER ? I check in the doc but didn't saw it so i guess not, but may be there is something similar ?
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Got a link to a paper on it? I have an extensible lighting model system, so it would likely be easy to add..
     
    pixelsteam likes this.
  40. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    I just have this from the doc of RTP:
    upload_2017-1-28_23-37-24.png

    Hope that help, in RTP and UBER its a layer that can be set per layer (often used for grass part).
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Welp, just got the website working. Still have a lot to add (mainly the tutorials section), but it's a decent start:

    MegaSplat
     
    Goodgulf and mk1978 like this.
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    So is this a per pixel or per texture thing? Seems like some kind of fresnel hack. Anyway, my next major thing is to re-do pertexture properties so users can fully configure them (and internally I can support an arbitrary number of them per texture). Once I do that it will be relatively easy to add more..
     
  43. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Sorry im not very familiar with how shader works :p
    All i know from using RTP is that i can set this per texture. In Uber its an option in the default part of the shader.

    The effect is extremely noticeable in those (from http://klass.artstation.com/projects/1lPBG) :



    Its from UDK but just to show something more obvious, it gives that nice peach skin look :)
     
  44. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    855
    If the size of my terrain is between 500-750 is it beneficial to convert it to a mesh?
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    Mesh rendering is always faster than Terrain rendering from a shader cost perspective. However, working with meshes is more manual, as you have to manage your own LODs, object placement, etc..
     
    StevenPicard likes this.
  46. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    855
    Thanks for the answer. I'll most likely pick up an asset to help generate LODs.
     
  47. gn0ll

    gn0ll

    Joined:
    Sep 29, 2016
    Posts:
    16
    Been playing around with it, and its super fun!

    The tessellation is pretty amazing.

    In very low light conditions I noticed a weird artifact that I tried to capture here (sorry if the quality is crappy): https://gfycat.com/ActualVengefulCockatoo [tiny white specs as I move around]

    Not sure if it is something else to do with my setup, but when I turn tessellation off it definitely goes away.

    Any help would be appreciated.
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,445
    It's hard to tell from that video, but my guess is that it's from the angle of the faces changing as vertices are added/removed and displaced, and that your surface has some specular component that's catching the light in those moments. But again, hard to say. I'll play around in extreme low light and see if I can reproduce it.
     
  49. gn0ll

    gn0ll

    Joined:
    Sep 29, 2016
    Posts:
    16
    Thanks for the quick reply! Sorry for the crappy quality, not a gif master yet. Let me know if you are able to reproduce.

    Switched all my (gaia generated) terrain really easily, and everything looks and performs amazing. I really enjoy the documentation as well, and always pick up something new each time I read it.

    Definitely 5/5 for me, i'll post a review in the next couple of days.
     
    jbooth likes this.
  50. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Looking at the manual for conversion from Unity to MegaSplat, is this a typo? Unity texture is on left, megasplat clusers is on the right, right? Conversion left Right.JPG