Search Unity

[FREE]MicroSplat, a modular terrain shading system for Unity Terrains

Discussion in 'Assets and Asset Store' started by jbooth, Aug 9, 2017.

Thread Status:
Not open for further replies.
  1. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, if y'all haven't checked out Vegetation Studio, it was released today:

    https://assetstore.unity.com/packages/tools/terrain/vegetation-studio-103389

    A custom integration is already included in MicroSplat. It adds the following features:

    - Generate a diffuse texture with MicroSplat's render baking and use it to tint the bottom of vegetation
    - Generate a grass mask with Vegetation Studio, and use it to render grass beyond the distance in which Unity can draw it.
    - Generate a custom Shadow Mask from Vegetation Studio which MicroSplat can use to render fully dynamic shadow approximations in the distance, well past the range in which you can use cascading shadows.
    - When using MicroSplat's lava, Lava can burn away vegetation as it flows down the mountain.

    Shadow Example:


    Runtime masking of vegetation from lava flows:
     
  2. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I think it's just the label -- confused me initially too. I agree that "Triplanar Value" would be clearer (that 0=disabled). (And sometimes it seems like there are some intermediate values? Not sure though.)
     
  3. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I created a default cube to blend with and at first it worked with blending but I'm not sure what happened but after scaling the cube it just broke when I clicked the sync button throwing errors about missing properties etc. It's also creating two materials instead of 1 on my objects with Unity warning the mesh has more materials than submeshes.


    Tested with default cylinder and a Cube created from primitives pro result in the same problem with blending just no longer working and making the meshes black when the blend script is applied. I am using 2017.3 Beta.
     
    Last edited: Dec 6, 2017
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So first off, you're using a Beta version of Unity- like most asset store developers, we tend not to support betas because they are rife with issues that are often fixed before release. That said, do you have the logs of the errors? The terrain blending system puts a second material on your object because this material does the blend.
     
  5. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I went back to 2017.2 for now thinking it was the beta. Same issue but should I reimport Microsplat fresh install?
    That's the problem with Unity, they are all broken. 2017.2 has an asset exertion bug while the beta got rid of it and potentially introduced this new one but can't confirm 100% if it was caused by beta. Anyway attached is the log.

    Just an fyi what gpu are you running and what is your average fps with microsplat terrain (shadows and vsync=off).
     

    Attached Files:

  6. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Quick question about wetness: Is there a painless way to query if a position on the terrain is wet? Would be useful for footstep (and other ground collision) sound/particles.
     
    magique likes this.
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You could try that- that error doesn't look like it's coming from the microsplat material though, as I don't use those properties. I believe those are from the standard shader, which is likely what's on your cube.

    I do most of my development on a MacBookPro laptop. My current one has an integrated graphics card as well as a
    Radeon Pro 460 4096 MB. With vsync disabled, frame rates are usually between 120-200fps depending on the features used (running the included demo scenes).
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, you can use GetPixels on the control texture to sample the pixel your under on the control texture. If your unsure how to convert a world position into a terrain pixel, you can find the code for that in the painter which is included in the streams module (Should be called TerrainToWorld and WorldToTerrain, I think). I believe wetness is stored in the red channel.
     
  9. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    In your experience how is the new Vegetation Studio impacting your overall 200 fps?

    Also I get this error regardless of whether it's a fresh or new install whenever I import it and it sticks around popping up every few minutes. I believe this is what's causing the error:

    Assertion failed: Assertion failed on expression: 'scriptParameterClass != NULL'
    https://issuetracker.unity3d.com/is...ening-project-containing-onterrainchanged-api

    That error above is when importing microsplat. Then when importing terrain blending from microsplat I get this:

    Unable to parse file Assets/MicroSplat/TerrainBlending/Example/MicroSplatData/MicroSplatConfig_diff_tarray.asset: [Invalid leading UTF-8 octet] at line 4

    UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)

    Unable to parse file Assets/MicroSplat/TerrainBlending/Example/MicroSplatData/MicroSplatConfig_normSAO_tarray.asset: [Control characters are not allowed] at line 4

    UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)

    *I left the old terrain and it turned white and deleted all microsplat data and re-imported.
    Now these are all clearable errors so I am just letting you know.

    Again after doing the process and applying the Terrain blending to a default cylinder and clicking the 2nd material (the Microsplat Terrain Object blend) I get those errors thrown. The material is black even before expanding it and getting the errors.

    I am using 2017.2.0f3


    What version of Unity are you using?
     
    Last edited: Dec 7, 2017
  10. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    The confusion is because one is working with a certain textures values at that point, while those enable/disable checkboxes belong at parent level.

    If you prefer them in that vicinity, then put them right under the "Per Texture" title, like "Control these per-texture:" then a list of labelled check boxes (which should wrap), then draw a line break, and have the current texture selector and properties below ... Incl the sliders for enabled per-texture properties.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Oh it lowers it, of course. Drawing a ton of vegetation is expensive, no matter what you do. Vegetation Studio is extremely efficient at what it does, but there's no getting around the fill rate cost of dense vegetation, even when placement and drawing is handled entirely on the GPU. The point of keeping any part of your graphics pipeline as fast as possible is to make room for more detail, and to make it possible to make tradeoff's in other areas of your process.

    This is a known Unity regression in 2017.2 which I believe is fixed or about to be fixed in a newer patch. It seems to be happening to hundreds of assets.

    That's interesting - it's having trouble parsing the compiled texture array. If you select the texture array config and press Update, does it prevent this error from happening again? What are your serialization settings set to? (force text, binary, mixed, etc) Are you running in Linux or some other less-tested platform?

    I dev in 5.6.1p2 on OSX, but have various projects and test in various flavors of 2017.1 and 3017.2, including the version you are using, and often test on windows as well.
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That would take up twice as much vertical space though, in a UI that is already very tall. I agree that the two controls in the same area is less clear than having them in separate areas, but once understood the usability is much higher with the current layout, IMO, and in most cases people seem to understand the current layout. It just makes having an option which is a toggle feel a little odd..
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So I reimported on 2017.2.0f3 and managed to repro these errors- however, the example terrain blending scene works fine, and the texture arrays draw fine as well. Loading the terrain blending scene, everything seems to blend fine, and adding new objects to it and adding the blend component to them also seems to work.
     
  14. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Just my luck....I am using Win7 64 bit. Try scaling the cube 100 x and tweak with it some more, see if that causes any issues because that's what set mine off. The problem now seems to be that every created objects turns black now and isn't affected by the blending at all even when it's not black.

    I wonder if I was supposed to do anything with the Terrain component settings?
    I will try to press update and as far as I know I haven't touched the serialization settings where is that anyway?
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I mean, it should just work. Can you zip up a copy of the project in the broken state? I could see if it's broken for me and if so maybe figure out how it got that way.
     
  16. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    @jbooth - just downloaded vegitation studio.

    Integration seems to be missing some files.

    if (p.EndsWith("microsplat_properties_vsgrassmap.txt"))
    if (p.EndsWith("microsplat_func_vsgrassmap.txt"))

    Unity_2017-12-07_12-42-08.png

    the grassmap txt files don't seem to be there.
     
  17. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's very strange, there's no microsplat_fiunc_vegetationstudio or microsplat_properties_vegetationstudio files in my version, only the vsgrassmap/vsshadowmap ones. Do those files have the grassmap functions in them?
     
  18. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I didn't do a full delete before updating to your latest version, perhaps this is the problem?

    I get a null pointer when I try to enable grassmap from shader gui.
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I seem to recall renaming those files when we added support for the distance shadows- perhaps 1.6 shipped with the old files? Source for those files is below:

    microsplat_func_vsgrassmap.txt
    Code (CSharp):
    1.  
    2.       sampler2D _VSGrassMap;
    3.       float4 _VSGrassFade;
    4.       half4 _VSTint;
    5.  
    6.  
    7.       // no per tex is faster, just final value.
    8.       void VSGrassTexture(inout half3 albedo, Config config, float camDist)
    9.       {
    10.          #if _VSGRASSMAP
    11.             half4 tex = tex2D(_VSGrassMap, config.uv);
    12.             half3 tint = _VSTint.rgb;
    13.             #ifdef UNITY_COLORSPACE_GAMMA
    14.             tint = GammaToLinearSpace(_VSTint.rgb);
    15.             #endif
    16.             tex *= half4(tint, _VSTint.a) * 2;
    17.             float fade = saturate((camDist - _VSGrassFade.x) / max(_VSGrassFade.y, 0.01));
    18.             albedo = lerp(albedo, BlendMult2X(albedo, tex.rgb), saturate(fade * tex.a));
    19.          #endif
    20.       }
    21.  
    microsplat_properties_vsgrassmap.txt

    Code (CSharp):
    1.  
    2.       _VSGrassMap("VS Grass Map", 2D) = "white" {}
    3.       _VSTint("VS Tint", Color) = (0.5,0.5,0.5,1)
    4.       //global//_VSGrassFade("VS Fade", Vector) = (50, 150, 1, 1)
     
    frosted likes this.
  20. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Hi, every time I build or close and reopen a scene that has the streams and lava plugin applied, all of the water based treatments to the terrain disappear. Super weird. Any suggestions on how to prevent this from happening? Thanks!
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you press save on the painter window?
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Actually, pretty sure what happened here is I renamed the files, but when you installed over the existing files, they had the same GUIDs in the meta files and Unity replaced the old ones and kept the old names. I'll delete the metas and have them regenerated for the next patch so this doesn't happen for people that update to 1.7..
     
  23. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
    Hey there,
    I just downloaded Microsplat on 2017.2.0f3 and had the errors mentionned before about Assertion failed and Texture 3 is missing from the terrain.
    Effectively the 4th Terrain texture in the example is blank, if I update it with the Cliff texture it is Ok.
    But if I reload the scene or click on Sync on your script the texture is gone again.

    PS : Still did not use your stuff but seeing the comments I can only say great job and thanks to give the base for free, I already bought the anti-tiling module that will be useful soon for sure.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, the assertion is a Unity regression in 2017, is harmless, and happens to a ton of assets.
     
  25. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Any ideas what would cause this to show up the standalone log.
    Shader 'MicroSplat/Landscape': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Is this when building? If you add the addpass shader in the MicroSplat directory to your included shaders in the build it would definitely fix this- it is supposed to add a reference to this to the MicroSplatTerrain component as of 1.5 so that it gets sucked into the build, but what this shader is is a small optimization (it makes the extra passes Unity tried to do on the terrain early out), so if it doesn't get added it's not going to cause any major harm..
     
  27. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I'll give that a shot when back on the machine.
    This message is from a log when running the game, but as you say it does not seem to show anything while running.
     
  28. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Hi, Mr Booth! We've met another problem when splitting the scene with MicroSplat and seriously need your help.
    The blended object on the terrain seems working without error reports now, but the blended area seems not right after the terrain is splitted.
    For example, I split the original terrain into four parts, give them the same template material as the original one, and place one object into one part with blendable object script. The blended area on this object will change when I hit Sync button on each terrain part.
    I thought the problem was that the four terrain parts are sharing the same terrain descriptor data and each time I hit Sync, the descriptor data of four terrain parts are covering each other. So I make sure they have different names and not share the same blending data. But the problem remains after I fix that.
    So my question now is that is there anything else they are sharing except for the blending data(which is the .EXR file named after the terrain)? Or is there anything else we should configure after we split the terrain?
    If you are not sure about our problem, Mr Booth, we will send you a sample project to give you more details:)
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    An example project is the easiest way for me to see what's going on. Depending on what features your using, there are multiple pieces of data which can be unique or shared between terrains - however, for blending, it's just the terrain descriptor which is used and must be unique.
     
  30. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi Jason!
    Any progress on integration with MapMagic's standard texture output?
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You'll have to ask Denis about that..
     
  32. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    I wrote a monobehavior with a function to add the MicroSplatTerrain component on every generated terrain tile through MapMagic's event OnGenerateComplete(Terrain terrain) and seems solved this.
     
    camta005 and jbooth like this.
  33. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    Hello Mr. Booth,

    any update on the global variables for puddles? I am still only able to make this work using the terrain material instance.

    Thanks and regards,
    Wurlox
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Haven't had a moment to repro it yet - should be fixed before the 1.7 patch is ready though..
     
  35. Pointcloud

    Pointcloud

    Joined:
    Nov 24, 2014
    Posts:
    37
    Thanks for the previous response, I did not press save in the window, whoops :)
    Is there a simple way to change the scale of a microsplat texture?
     
  36. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    You have a per-texture override for that ... but don't change it too much
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's a global scale and a per-texture one.
     
  38. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi, somehow the normal maps were ignored . After setting the texture array I get such errors:

    Could not find shader Hidden/MicroSplat/NormalSAOFromNormal
    UnityEngine.Debug:LogError(Object)
    JBooth.MicroSplat.TextureArrayConfigEditor:RenderMissingTexture(Texture2D, String, Int32, Int32, Int32) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:407)
    JBooth.MicroSplat.TextureArrayConfigEditor:CompileConfig(TextureArrayConfig, List`1, String) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:697)

    The shader is set to 16 textures. I have just 8 textures set, im I have to set them all?.

    So, whatever I do with the normal map strength, it has no impact, but I get at least some black spots ;) I had this problem in MegaSplat, but there the normal maps were not recognized by Unity. This is not the case yet. Any idea what the issue could be?
     

    Attached Files:

  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Fixed this while on the plane today..
     
    treshold likes this.
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Seems like some files are missing from your install- The shader it's looking for is the one that generates a smoothness or ao map when they are missing and packs them into one texture, so if that file is missing, it wouldn't be able to pack normal maps correctly.
     
    mkgame likes this.
  41. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    I reimport the whole plugin and bad things disappeared, Mr Booth:). My apologize that I can't always send you a sample project in time! Good thing is that this problem is solved and has nothing to do with your plugin:D. Maybe some files are corrupted when we transfer to each other~:rolleyes:
     
  42. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    I've got another question for you today, Mr Booth~ Our programmer says the terrain-blend shader is using forward rendering path, not deferred.. Is that true? Or is there an option to choose from?
     
  43. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Thanks! Indeed, the files are missing. I guess, that because I already had them in MageSplat. One of your features for MicroSplat collided with MegaSplat, so I removed the MegaSplat folder and I guess the shader files in MegaSplat were used by MicroSplat.
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It should use whichever you are set to; note that I don’t provide the base shader, so if the shader you put on the object forces forward then the whole thing would render forward.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, this appears to be another case of the meta files having the same ids as the ones in MegaSplat. I’ll regenerate them to prevent this from happening in the future.
     
    Baraff likes this.
  46. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    Thanks for the fix. Gonna test it once it is on the asset store. :)
     
  47. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Thanks, Mr Booth! That sounds quite smart and indeed we have some objects using forward rendering shaders, and we will check to see if there's anything else causing performance issue. By the way, the wind and glitter module seems amazing!:)
     
    Teila likes this.
  48. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,269
    Honestly, I really love the feature that you have to press the save button while toying around. Just restart Unity and all testing is gone. When I'm getting serious with it, of course it'll be another matter. Anyway, is there a method to reset e. g. all lava painting and start from scratch directly within the module?
     
  49. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I added the shader but I still get the error message in the log at runtime.
    Shader 'MicroSplat/Landscape': dependency 'AddPassShader' shader 'Hidden/MicroSplat/AddPass' not found

    upload_2017-12-12_15-45-12.png
     
  50. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Please check this out, Mr Booth. I added a point light to the scene, and the terrain and blend area seemed to react differently.. Can we solve this problem?
     
Thread Status:
Not open for further replies.