Search Unity

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

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

  1. wmpunk

    wmpunk

    Joined:
    Sep 5, 2015
    Posts:
    71
    I was wrong I didn't fix it, I was just in a area where it was looking more accurate on the terrain.

    So to reproduce import a fresh copy of the Megasplat, go directly to the MegaSplat_Example_Terrain material and turn on parallax and foam. Open the non tessellated terrain example. Parallax should be incorrectly displayed ( stretching upward with slopes as opposed to view) and foam texture will be just lines. Enabling per texture parallax should break the shader and material editor as well.
     

    Attached Files:

    Last edited: Jul 28, 2017
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, repro'd. I have a fix for the shader compile error with per tex parallax being turned on (send me your invoice if you need a patch for this), but the sliding on the parallax is perplexing. I've had a bug logged with Unity for over a month now on the shader compiler either a) sending viewDir in the wrong space or B) stripping the viewDir information completely - I've yet to get a response, despite giving them a repro project clearly showing the issue. If you edit the shader MegaSplat produces and comment out the following:

    Code (CSharp):
    1. // hack around unity compiler stripping bug
    2.          #if _PARALLAX
    3.          splats.Albedo *= saturate(i.viewDir + 999);
    4.          #endif
    Then you'll see the original issue I was having, which looks even more messed up. Anyway, I'll look into it further. I suppose, worst case, I can compute the View Direction myself instead of trusting Unity's code, which seems to randomly break in various ways..
     
  3. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    Hi Jason,

    I am having a problem with the Terrain Painter Utility Splat from Colormap

    I have created my own texture generator in Unity that uses satellite images to create a colormap based on colors on the base texture. Those are my steps

    1. I assign the macrotexture to the terrain in the Megasplat terrain manager script
    2. In terrain painter - Utility - Splat from colormap I select my texture and a ColorToSplat config , I fix the few errors (read write and conversion to ARGB)
    3. I hit Bake from image, the editor gives this error and the texture gets blanked.

    Edit: I tried to set the mipmaps to 12 on the original texture and the error is gone, but the texture is not preserved when I hit bake, I get a generic noise texture with no reference to the original colors



    Graphics.CopyTexture called with mismatching mip counts (src 1 dst 12)
    UnityEngine.Graphics:CopyTexture(Texture, Texture)
    JBooth.MegaSplat.ColorToSplatConverter:BakeFromTexture(TerrainJob[]) (at Assets/MegaSplat/Scripts/Editor/Utilities/ColorToSplatConverter.cs:238)
    JBooth.MegaSplat.ColorToSplatConverter:OnGUI(TerrainJob[]) (at Assets/MegaSplat/Scripts/Editor/Utilities/ColorToSplatConverter.cs:43)
    JBooth.TerrainPainter.TerrainPainterWindow:DrawUtilityGUI() (at Assets/MegaSplat/TerrainPainter/Editor/TerrainPainter_GUI.cs:649)
    JBooth.TerrainPainter.TerrainPainterWindow:OnGUI() (at Assets/MegaSplat/TerrainPainter/Editor/TerrainPainter_GUI.cs:583)
    UnityEditor.DockArea:OnGUI()


    I see this is a problem with mipcounts but found no way to fix it before I submit my texture to Terrain Painter

    Here's a link to the original texture...

    https://drive.google.com/file/d/0B4POH-yEbELIUVg2ZE9IbTBHekk/view?usp=sharing


    thanks
    Fred
     
    Last edited: Jul 28, 2017
  4. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    another issue I have is that in Editor the cluster previews are almost black as the light seems to come from the back

    I am on Unity 5.6.1f1 is this the issue ?

    EDIT:
    I fixed this by adding this line to MegasplatUtilities RenderMeshPreview line 208

    sPru.m_Light[0].transform.rotation =Quaternion.EulerAngles(45f,45f,0f);

    maybe you can fix it in next release ?





    screen1.PNG

    thanks !
    Fred
     
    Last edited: Jul 28, 2017
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, first, ColorToSplat is a tool to convert a color image to splat mapping data (texture cluster choices)- it doesn't project the color onto the mesh. It doesn't matter if you have a macro texture or not- a macro texture is what you'd use if you want to color the whole mesh a certain way. Just making sure we're on the same page about what your trying to do..

    Hmm, the CopyTexture there is supposed to avoid having to set your texture to read/write. Can you tell me which code is throwing the read/write error?

    Can you tell me what type of machine your on, and if your in linear or gamma? This issue seems to be specific to some combination of those two settings. (It works fine on my mac and windows machine, but this seems to be a common issue for some people, so I'm trying to figure out what combination of checks I need to perform to adjust this based on machine/linear/Unity versions/etc).
     
  6. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    Hi Jason,
    thanks for the prompt reply

    1. ok, my mis-typing, I am talking about the Splat Texture variable in the Megasplat terrain manager Script that is attached to the terrain game object...

    2. I restarted Unity and could not reproduce the error... sorry

    3. here's my laptop model MSI , should be quite standard... anyway I believe the lighting problem could be fixed by orientating the light as per my code above... by default the light is set at 0,00 euler...

    I found another issue... I believe the importer from Colormap inverts the texture.

    I have highlighted an eroded canyon were this is quite evident:
    DestinationColorMapSplatMap.jpg

    Above is the original colormap

    splat control.PNG


    This is the generated splat control... which seems to be flipped vertically... also the mapping on the final terrain is not correct....


    I bought this asset when it was still in beta and started to dive into it just a few days ago... I must say incredible work.... congratulations !
     
  7. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    checked the colorspace... was in gamma... sorry :( I did not read the QA...
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Looks rotated 180 degrees to me. Try rotating the image by 180 in an image converter and let me know if it lines up then.
     
  9. Frednaar

    Frednaar

    Joined:
    Apr 18, 2010
    Posts:
    153
    you are right... it is rotated 180 degrees...
     
  10. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    119
    Thanks! So I got this working. I just started out simple, working through the examples and got texture graph and terrain painting both working.

    Tesselataion looks really good, and it doesn't affect frame rate too bad. I attached your TesselationPhysicsFloor script to my vehicle wheels, and to my joy it worked straight away.

    However: It is not really working on my 2017 Mac. If I try to tesselate shadows I get some pretty crazy artifacting with triangles flashing on and off.

    With tessealation shadows not enabled. The object appears to hover with what appears to be the shadow hitting below what appears to be the non-tesselated surface below.

    I thought perhaps the artifacting was an openGL in-editor issue, and might go away when I published.

    When I publish on my Mac, objects appear to interact with the tesselated surface, but tessealation isn't displaying in the viewport.

     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Glad it's going well- I think I saw a few posts from you pop up and get removed before I could answer them?

    So, a few things:
    - Shadow biasing can definitely cause the "flashing shadow triangles" issue, and I notice it's pretty finicky on my mac, but that I don't have nearly as many issue with it on PC.
    - I see you have displace from center on; this means the tessellation can go both down and up. When this is enabled, you have to make sure your vehicle is colliding only with the fake physics object, and not with the actual terrain. Otherwise it will collide with the non-tessellated physics whenever the height is below 0.5 in the texture. If you turn this off, the tessellation will only displace upwards- but this also means it's a greater distance from the actual geometry, which can cause issues elsewhere (object placement tools, etc).
    - The physics floor is basically an example; depending on your needs, it may or may not be enough. The code is well commented though, so if you need to go further it should show you how to interact with the API to roll your own solution that does as little or as much as you need.
     
    MonkeyPuzzle and Dwight_Everhart like this.
  12. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    119
    Thanks again - your support is awesome.

    They physics is working pretty good. The main problem is that on publishing, the tessealation is not working on Mac at all visually - although the collision script appears to be working.

    Shadow settings, bias, et. al. does not seem to have any effect on the flashing traingle issue when Tesselate Shadow Pass is enabled in editor, but again tesselation doesn't work visually on my Mac with a published game.

    Not to complain! Seriously, this is a great add-on for Unity! If I can get tesselation working with published games on Mac, that woudl be awesome, if not, I will push forward and perhaps have this be an option that is vailable for PCs.

    Have you got Tesselation working visually with shadows and collison on your Mac with published games?

    With Unreal, I have seen tesselation work by tesselating the terrain mesh itslef close to the player, Do you know if this is possible with Unity? It seems like it would eliminate the need for collision scripts, and woudl keep overhead low by only tesselating what is close to the camera.

    With terrain meshes perhaps?
     
    Last edited: Jul 29, 2017
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, works fine - I actually do all my dev on a Mac. However, keep in mind that newer Unity versions choose different APIs for the editor and for the published game. The current default is to use OpenGL in the editor, but Metal in the published game. Not sure why they would do this, as it only seems to cause issues. Anyway, you can check this by turning off the "fallback" option - this will make it not generate a non-tessellated version of the shader (which is what Metal would select), and in the build it will most likely fail to render the terrain if you are running on Metal. You can then remove the metal API from the list of APIs (and re-add OpenGL if it isn't there).

    Distance based tessellation does exactly this - though note that even if you don't add any vertices, there is a cost to running a tessellation based shader. When things get far away, it's best to swap them for a non-tesselated version.

    What I've prototyped on the 5.6+ version of MegaSplat is using the Unity Terrain basemap shader to remove the tessellation at a much closer distance than, say, the distance at which you could swap the material. This provides a pretty healthy speedup, but isn't really viable until I rewrite the lighting pipeline (there's a slight difference in lighting between the tessellated and non-tessellated versions, so you see a line where the swap happens right now).
     
    Dwight_Everhart likes this.
  14. GrichDesign

    GrichDesign

    Joined:
    Mar 29, 2013
    Posts:
    25
    Hello, this may have been talked about somewhere else but there are 50 pages here and I couldn't find it. My terrain painting resets whenever I restart Unity. I have lost a couple hours of work twice now. Is there a button I am missing?

    Other than that I am in love with this asset. Really great work man :)
     
  15. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Hi there -- you have to click the 'Save' button in the 'Terrain Painter' tab every time you want to save your current painter actions. To start with I kept forgetting to do this as well, however it becomes second nature after a while of using the system.
     
    jbooth likes this.
  16. GrichDesign

    GrichDesign

    Joined:
    Mar 29, 2013
    Posts:
    25
    THANK YOU SO MUCH! I'm not used to saving within the inspector tab so I wasn't even looking for that giant button. Looks like it is working great and I'm back on track. :D
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, I keep meaning to go all GeoCities on that button or something. For reference, the reason it needs a save button is that saving involves writing the textures to disk, which is too slow to do while painting.
     
    Dwight_Everhart likes this.
  18. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Back on the topic of the dark material previews:

    Tried this fix on my system, the previews that were already dark then became completely black, whereas before could see a slight bit of material appearance and specular... but still very dark. So in my case this was not the fix.

    Have verified the following on my setup:
    • Working in Linear color space.
    • Diffuse textures are marked as sRGB on import settings.
    • The 'linear' button on texture array is not enabled for diffuse (if I enable then my terrain texture colors go all light and weird, so it's not that).
    • Packing mode is Standard no spec. However other packing modes gave me the same result on the material previews.
    • Have tried various settings and re-generating the arrays / previews but however it's always the same.
    Hopefully this info is helpful, let me know if I can send more details.
     
    Last edited: Jul 31, 2017
  19. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Regarding the blending of geometry with MegaSplat -- I'd like to discuss and understand the process further. I've read back through the thread and your earlier comments on the topic, however I've not yet managed to get it working effectively on smaller objects like rocks and ground debri etc.

    Success so far:
    • I can work well with MegaSplat on terrains and meshes, it's so nice. :)
    • By turning a terrain in meshes, I can then cut out pieces of the mesh and use it to create tunnels and terrain blends. I copy the terrain shader into another version that I then use in mesh mode.
    • Using the terrain splat, I can paint back vert data onto the meshes, it gives a perfect blend with the terrain, and the UV scale is the same.
    Failing / need more info:
    • I'm using tessellation, and painting some areas to remove the tessellation, to try and make the objects blend naturally. This help to some extent, however the seam / lip where objects meet the terrain overlap is still visible. This could relate to parallax.
    • You mentioned in the past that it's not possible to disable parallax effect in some areas via painting (same as tessellation), as you don't have enough channels available? Would it be possible to use another channel from another feature that isn't currently being used in a MegaSplat setup ... in theory? I'm just exploring options on how to get perfect blends with tessellation and parallax enabled together.
    • When I try to blend in separate models / objects on the ground, for example rocks or debri sticking through the ground. What is the best way to get a natural looking blend? How to blend smaller objects with the terrain, any tips or pointers?
    • You mentioned that when blending to do a UV project in world-space on the objects that you would be blending, can you explain this further? Can I do it from within Unity with a plugin perhaps?
    • When re-using the MegaSplat mesh terrain shader on smaller objects the UV scale is massively different, due the scale of the terrain I suppose. Is it better to change the objects UV scale to match the terrain shader, or to create another instance of a MegaSplat material using a different scale?
    • In terms of performance with MegaSplat, how does the number of active MegaSplat materials / shader instance variations stack and affect scene performance? i.e. 1x for Unity terrain, 1x for mesh terrain, 1x for objects etc.
    Any help / clarity here greatly appreciated.. thanks!
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, in the next patch I added ambient lighting to the sphere previews. This has been a long standing issue, and it seems no matter what I do it happens to someone, on some combination of machine/settings. I'm hoping that simply cranking the ambient lighting means you'll always be able to see a preview, even if it's not as well lit..

    My plan is to share the displacement dampening with parallax, such that painting displacement dampening removes both tessellation and parallax.

    The main issue here is likely vertex density. You're trying to get normals/tangents/uv's to be the same, but you likely don't have vertices that are in the same place, so it's sort of like balancing a ball on top of another ball.

    That's to get both objects to have similar UVs. Think of it this way- you UV map your rock to a texture sheet, which has a 0-1 space. Then your entire terrain is UV mapped in a 0-1 space. So the chance of the UV coordinates lining up perfectly is basically near 0. By using a UV projection in world space, such as a top down projection or triplanar projection, then you are mapping the position of the vertex to a UV coordinate, and thus two positions in the same place will have the same UV. You can change the UV mode on the shader from UV to Project or Triplanar in MegaSplat to do this.

    It's unlikely you'll get these to line up perfectly without using a projection (See above). Also, if you are applying the terrain version of the shader to a mesh, then there's a chance that your tangents won't look good because tangents are calculated automatically in the shader instead of read from the mesh for Unity terrains based on them always having a fixed UV space (this is a Unity thing they do as an optimization).

    Well, keep in mind that Unity terrains are terribly in-efficient in this regards. Unity breaks up the terrain into lots of tiny meshes so it can do dynamic LOD on the vertices - which is kind of ironic, since on hardware today vertex throughput it hardly ever the bottleneck. So a single terrain can easily be hundreds of draw calls. That said, because they all share the same material, they should have minimum overhead from those additional draw calls.

    Anyway, MegaSplat is really no different than any other shader in this regards. Each unique material means a new draw call, which requires re-setting the material parameters (textures, settings, etc). Usually this is a small CPU cost. If two objects share a material, the cost of the second draw call is reduced. If two objects can be batched together, then they can be combined into one draw call.
     
  21. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Thanks for the great reply, you really answered everything well / clearly ... it's much appreciated!! :)
     
  22. Lijianjian

    Lijianjian

    Joined:
    Feb 26, 2017
    Posts:
    16
    I need some help .
    My megasplat have some display problem in unity 2017.1.0f3 ! The TextureArray "megasplat_diffuse" looks wrong !But console do not give error message .
     

    Attached Files:

    • JP1.jpg
      JP1.jpg
      File size:
      801.2 KB
      Views:
      748
  23. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Using the standard UV1 projection, No Spec and No Normal version of the shader and then also dragging in my custom texture array into the Albedo Height area of the Splats section I was finally able to paint on the model. (It was painting nothing before I did this so I thought it was a bug)

    Now however I have set the interpolation to 1 and it's looking really smooth.
    I did want to mention it seems aside from the brush size in the custom brush area the flow and falloff don't seem to do anything am I right?

    Also here's my first image of getting it working, it does really look nice for diffuse only lighting!
    1.I wanted to ask however if you plan on making the interpolation control even greater than 1 for an even more faded look between textures?

    2.Also I noticed it behaves strangely when painting on the default Unity plane. Is this because there's no source file to convert the default plane into a mega format or is there something I missed?

    3.It mentions to be careful when using the static checkbox and static batching. Would it better to not use this to avoid using errors or is it really worth exploring the baking meshes section?
     

    Attached Files:

    Last edited: Aug 1, 2017
  24. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    [I am referring to mesh to mesh blending here not terrain]
    After messing around with the Normal Blend brush I found it difficult to work with and extremely situational. In most cases if I want to blend a rock with the ground mesh I will most certainly have different uv data and textures.

    One way I would like to request to achieve this would be similar to this video except this video is using terrains and meshes while I am looking for meshes to meshes but if implemented correctly it could also work with terrains too.



    In theory all we need is a shader or component on the Rock that will start a fade effect from the very bottom of the rock and with a slider can continue that fade until the user is happy. The trick is that this fade will cause what is below to show up in this case the ground object but the fade effect will look really nice causing the user to see an illusion of blending when there is none.
    Would that be a reasonable request to include or not because blending is sort of the final frontier of terrains lol?

    We most likely can just fade the texture using Alpha's but I don't want to specifically mention it in case there's a better way.

    Also if we really want to get a specific fade in certain areas you can create a specific brush which will fade only the areas you choose to paint on the rock. There might be some issues with this such as shadow problems but I am willing to make some sacrifices where need be.
     
    Last edited: Aug 1, 2017
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Try clearing the clusters and autogenerating them again.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You can already make objects alpha and paint a fade on them - but that won't do what you're after. That will just make the object transparent, which not only means no shadows, but that you'd be able to see through the object. Unfortunately there is no easy way to 'automagically' do arbitrary blends between multiple shaders like this. All the solutions basically fall into one of a few camps:

    1) Draw the object multiple times for each shader it has to blend with. Lets say we have 5 meshes that intersect- we now need to draw each mesh, then draw each mesh again with each shader it intersects with, somehow fading the alpha along the edge. Worse, we somehow have to draw each of these meshes as if they were textured as the other mesh - which is basically impossible if they use UVs. Then we'd also need to optimize it such that we'd boolean the geometry to only perform this expensive operation in the areas the blend is active. And while we do that, we also need to light each of these areas as if they are continuously smooth geometry- which they are not since the geometry is just mashed together. This likely means more boolean operations between the geometry such that each intersecting polygon creates a new edge along the intersection with identical vertices, so they can be lit the same.

    2) Greatly limit the domain of the problem so that you can solve a simpler case. For instance, one way might be to:

    - only blend meshes with terrains; since this means you only have a 1 mesh to 1 terrain blend, not some 5 way monstrosity.
    - Use projective UV coordinates so the UV coordinates of the two models line up.
    - Keep a copy of the terrain height map and normals in a HDR texture in memory.
    - Write a shader which contains both the regular shader you use and the terrain shader you use as one shader, which samples the HDR texture, determines where the blend needs to happen, and computes both shaders and blends the results.

    Now, what people really want is something they can slap on any object and it just works. But without greatly limiting the domain of the problem in some way, that's basically an unbounded problem with endless solutions, each of which is custom for each parameter you change. If you're terrain is an arbitrary mesh, then keeping an HDR texture with height/normals in it isn't possible- because that's an assumption that your not working with an arbitrary mesh but rather a height field. If your mesh has UVs, then we can't rely on the UV mapping being the same. If you need multiple meshes to blend together, then you have the combinitoric explosion problem of #1.

    So yeah, I could easily produce a system that solves this problem- but there is no predefined set of limitations which just works for everyone, and certainly not across the millions of unique shaders that MegaSplat can produce.

    Recently someone released a free terrain blend toolset on the asset store. What this toolset limits the problem domain to is:

    - You only want terrain blending at height 0 on your terrain. So if your terrain has any hills, objects won't blend with things on those hills. (Known/no geometry to terrain)
    - You use the stock Unity terrain shader (known UVs, topology)
    - You only use 4 textures on your terrain (known texture scope)
     
    neoshaman likes this.
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    They will have no effect in a single layer shader- in a two layer shader, you can blend between two sets of textures by painting on the top or bottom layer (or using the Auto brush mode to automatically select the layer for you). So the opacity and falloff come into play here, as they control how the blend between the two layers happens. (A two layer shader will be much closer to the experience you are used to from something like a Unity terrain).

    This was added for terrains, but due to the way meshes work you cannot go past 1. If you want a smoother fade, you likely want a two layer shader, where you have greater control over the texture blending.

    Yes, the mesh preprocessor puts certain information on the mesh that's needed by the shader. Without it, you'll get areas where it suddenly interpolates between textures that aren't painted down.

    It's really going to depend on your game. Basically, Unity requires that things be marked static for 2 reasons. The first is if you want them to be statically batched together. The second is if you want them to be light mapped by a pre-baked light mapping solution (enlighten or the new progressive lightmapper).

    So if your game is using runtime lighting (the default), and you don't need the static batching optimization, I'd just keep it as is. However, if you need those features, you can either bake out the final painted mesh one at a time, or use the "bake mesh cache" feature to bake out the entire scene at once. The latter can be inserted into a build pipeline, such that you always work on the unbaked scene, but have it bake out all the meshes as part of the lighting build.
     
  28. Lijianjian

    Lijianjian

    Joined:
    Feb 26, 2017
    Posts:
    16
    I just select megasplat_diffuse clearing the clusters and autogenerating them .

    I still have this problem and alos in Texture Graph and ColorToSplatConfig.
    But i do not have this problem in 5.6.2
     

    Attached Files:

    • jp2.jpg
      jp2.jpg
      File size:
      864.1 KB
      Views:
      991
    Last edited: Aug 1, 2017
  29. altfuture

    altfuture

    Joined:
    Mar 4, 2015
    Posts:
    3
    Jason, thanks for all your work, MegaSplat is awesome!

    I have a question that might have been answered or in the documentation (apologies if it is), but I'm not sure what it's called in order to search for it. Is there a way I can adjust the size of hexagonal-looking cells that mix different textures within a cluster? Eventually after reading more I thought their size depends on terrain mesh resolution (as they seem to be vertex color based), but even after changing mesh resolution, their size remained the same. I have a fairly large world with low mesh resolution, so the size of each "cell" is 50+ meters resulting in a lot of visible tiling of the texture within. Is there something I can do about that?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The choice of texture is based on the cluster noise scale. This is adjustable on the individual cluster, or on the brush (or texture graph, etc). The noise is based on the world position of the vertex or control texture pixel (on Unity Terrains). If you have a vertex every 50 meters, then it can only choose one texture every 50 meters, because there's only one vertex, so you'll be forced to tile the texture until you get to the next vertex. So you need enough vertex density to be able to choose additional textures over a given area. The other thing that happens sometimes is when people have a lot of vertex density and don't set the cluster scale correctly is they end up transitioning between textures in the cluster constantly, which can create a non-repeating, but heavily synthesized look of the texture as it only shows a few percent of the texture before switching to the next one.
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hmm, I wonder if something got munged with the shaders during the upgrade? I've seen data get messed up in both upgrades and installs from the asset store. Also, there were fixes to these shaders in 1.41, so make sure you're up to date.

    You can actually regenerate the shaders it uses to generate the previews pretty easily and see if that fixes it. Basically, go into the MegaSplat/Scripts/Editor/BrushPreviews folder and select each material. Change any option in the shader generator section and change it back and it will regenerate the shader. Then try regenerating the clusters and see if that works.

    If that doesn't work, I'll install the latest 2017 and see if I can repro it..
     
  32. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    "You can already make objects alpha and paint a fade on them - but that won't do what you're after."

    Actually that is what I am after. Where he paints the model in the video it becomes transparent and it reveals the ground. While it isn't perfect it can look Ok in the right view angles. I also don't care for shadows for this specific case as good blending will distract attention to the blend.

    There is a 4th option too-I thought of another way perhaps creation of a 3rd model - a shell object that covers the areas where the two models intersect and generates a meld of the two textures with a blur effect to make the illusion of blending-I guess it's a sort of decal effect.

    So in theory I place a rock mesh through my ground mesh and then a new geometry object is created which detects the intersection area and generates a shell object which occupies the intersecting area between the two objects.

    At that point the intersecting object will generate a texture that is in simple terms both textures mixed with a gaussian blur effect where they would intersect and all of this is happening on the shell decal object so the rock and ground are not actually being manipulated in anyway. Hows that?

    Here is an image demonstrating this method: Solution 4 Object Blending.png
     
    Last edited: Aug 1, 2017
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That doesn't really solve the issue though - you could simulate this by bluring the boundary area in photoshop. It wouldn't look like the two materials are seemlessly blending, but like you put a blur over the area like one of those videos where they blur the witness. Maybe that would be fine for your viewing angle/game, much like the alpha idea above, but it is not a universal solution which 'just works', rather an extremely specific one with extremely specific viewing requirements.



    SOLVED!

    Anyway, snark aside, to blend two shaders you need to blend all the parameters of the shaders. This means UVs, normals, tangents, and texture choices must be able to be computed for both shaders, along with any blend area data to mask the effect. Things like generating shell meshes are optimizations to this process, but you must solve for all of those factors to get a seemless blend that always works.

    MegaSplat allows you to generate shaders which fit these requirements (use triplanar for both to ensure the UV space is the same, AlphaLayer shaders to paint splats over regular texturing), and gives some tools to help with this (normal blend brush to align vertex normal/tangents), but it doesn't attempt to completely solve the issue for what is an arbitrary number of potential cases users may have.
     
    neoshaman likes this.
  34. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I was about to post a question about those hex patterns, so now I've read your answer and trying to understand better. Makes sense, and we are starting with a very large terrain which we will slice up. However, the problem persists after slicing, and even after increasing the control map resolution in the Unity terrain settings. See screenshot -- that's one slice, and I increased the Control Texture Resolution from 128 to 1024, but that has no effect on the pattern (though now it's a square, whereas it was a hex before on the huge terrain). Even if I shrink the terrain dimensions down to 500x500, those squares remain. So I'm obviously still not understanding something correctly.

    thanks
    Dave
     

    Attached Files:

  35. Blomidev

    Blomidev

    Joined:
    Dec 16, 2015
    Posts:
    11
    Hey jbooth! Just considering buying Megasplat. For my application of it, I require saving and loading terrains, e.g. an in-game map editor. Does this program allow for saving splatmaps so that they can be applied to terrains upon loading?
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Very odd- I've never seen that before. Is each square essentially a texture of a single color or something? Do you not have height information in your textures? Any chance you can send me one to look at?
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MegaSplat uses it's own splatmap format, which is stored as a texture on disk. So you can easily apply/change textures at runtime. You might want to look at the section in the doc that describes the format (it's available online). There are also "runtime painting" examples included, which basically shows you how to apply brush strokes at runtime the same way the painter's do..
     
  38. Lijianjian

    Lijianjian

    Joined:
    Feb 26, 2017
    Posts:
    16
    Yes i thinks everything is ok after i update to 1.41 ! Big thanks!
     
  39. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Actually if you improve the blending a bit that image result can indeed look passable Perhaps gausian isn't the best but averaging out the areas around the intersection gradually with greater blur towards the point where they meet could work.

    In Photoshop I select a region then modify the selection as a feather with 30 pixels and then apply an "average" blur which will combine the colors, it produces this result which is actually fairly usable if a shell is created between the ground and the rock. I would use it in my game.

    average.jpg

    This is my current solution. It attempts to solve it in an interesting way:
    https://www.assetstore.unity3d.com/en/#!/content/71664

    I suppose the complexity that you are referring to is why no one has found a way to solve it and they are for specific cases yes.
     
    Last edited: Aug 2, 2017
    neoshaman likes this.
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Heh, one of those objects is not textured, so bluring towards it's color will not catch the eye. Try the same thing with something like this:



    Essentially, there's no way to make these two arbitrary grids line up without looking odd. Imagine that each square on the ground/sphere is a tile of a texture; one is brick, another wavy cloth. There's just not a good way to blur these two grids into looking like one continuous grid. You solution is making lots of assumptions right now about the content you are trying to blend- these might be fine for your use case, but you can be sure they won't be fine for everyone else's, or that they will even work in many cases. Meanwhile:


    Here's a shot from the object blending demo in MegaSplat, with the wireframe turned on so you can see where the mesh is. Notice that the textures line up perfectly, and the lighting is reasonably consistent between the two models. This is because the models are both using projective UV coordinates and tessellated enough that the control points are reasonably close.
     
    neoshaman likes this.
  41. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    The battle of blending was interesting to follow lol I hope this continue a bit so I can see more solutions and their drawbacks :p
     
  42. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    It's strange that you would say 2 different textures wouldn't blend well when you use the interpolation method slider being set to 1 to achieve a decent blend with 2 different textures right in the splat settings menu right?

    By the way these are the sort of visuals where I would imagine it would work well:

    Between sand and rock would be a very common use case.

    But yes I admit defeat for now until further notice but what I don't like about your megasplat example is that they need to have the same texture in order to achieve any sort of blending.
    Anyway if I must use it at least get that tutorial video on blending up with a few different objects lol.
     
    Last edited: Aug 2, 2017
  43. altfuture

    altfuture

    Joined:
    Mar 4, 2015
    Posts:
    3
    Thanks! A couple weeks ago when I first encountered this problem I tried playing around with cluster noise scale parameter in the Terrain Converter tool, but it wouldn't make the clusters smaller. This time, I thought it had to do with the mesh resolution, however as I pointed out in the previous post, even after I increased mesh resolution (4 times), clusters keep the same size. If I play with the cluster noise scale parameter, I can make the clusters go larger (sometimes needing a few clicks on Convert in order to update in the scene), but in no way can I make them smaller. I tried changing values in the Texture Graph as well and clicking Compile, but to no avail.
     

    Attached Files:

  44. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It all depends on the look your after - in some cases, a blurry blend is fine and doesn't look out of place if the rest of your terrain is using blurry transitions, or if the media you are blending has a soft look (sand). But another common use case is to blend rocks such that they look as if they are part of the terrain mesh itself. IE: here's my fake cliff, which is blended so it looks like I'm not using a height field.

    Yeah, basically the idea is to keep the textures aligned across the boundary and then perform the transition to any other texture once your past the blend point. You can actually blend across the transition area, but if the vertex's are in different places (likely) you'll get small discontinuities.

    To summarize, I totally get what you are after. I'd really love to have a component you just slap onto an object and poof, it all looks amazing. This can be done if you a) round down the domain of the problem space in some drastic way and b) spend a lot of development time writing multiple complex solutions.

    I suspect there is a post-processing style way to solve this problem, but most likely it would only work in combination with other rendering pathway choices - for instance, rendering in deferred with temporal AA turned on there are some possibilities I can think of, but they would totally break in forward rendering.
     
    one_one likes this.
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If you can zip up an example of this I'll take a look. Perhaps we running into some kind of precision issue with the noise when the scales get very small?
     
  47. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, UE4 has a distance field generation step than basically generates a distance field for all of your geometry. This makes it much easier to do this kind of stuff because you know how close you are to other objects in the pixel shader without using alpha. It's a nice technique, but doesn't exist natively in Unity, and is super high end in that the distance field is a pretty massive amount of data.

    Basically, every technique you find will rely on a set of assumptions- either about your scene and look, or about the shaders and tech you are using.
     
    one_one likes this.
  48. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Interesting debate on the terrain / object blending, it's definitely a critical area to address, if there was an easier way or at least some more documentation and/or video tutorial would be really helpful, I agree.

    With my existing scene, I'm using Unity terrain, mesh terrain and objects. At the moment the Unity terrain and mesh terrain are both using the standard UV mode for splat. It's possible to change the splat UV mode without having to re-paint everything again? Also can / how does this mode work with Unity terrain?
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, it doesn't affect the mesh/terrain data at all - when you use projected UVs, they are computed in the shader from the world position. The original UVs data is untouched, and with the 'second UV' option it's possible to use multiple UV sets.
     
    WildStyle69 likes this.
  50. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I have seen water use image effects for the shorline effects where the water can actually detect the collision of objects and create a blue ring around it, so that might be one way.