Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[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

    Annoying; I’m not sure when I’ll have internet access next, but will post a build if the asset store doesn’t do a push in the morning.
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, hopefully the asset store will have the fix for this out today, but if not, here is the file that needs replacing..

    https://www.dropbox.com/s/2iq8bt8p21zt2mk/TextureArrayConfig.cs?dl=0
     
  3. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    Hi,

    I'm Marc, from Playstark Games. We are working using Vegetation Studio + Terrain + Microsplat (many modules). We have a strange effect, a line of pixels, on our terrains using the splat and we don't know how to solve it. Which is the way to setup correctly the problem?

    Thanks in advance
     

    Attached Files:

  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Update to the 2.11 patch (should be available today, or use 2.1 and the patch posted above) and switch to the gradient sampler mode. In older versions, use sampler mode LOD.
     
  5. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    I post another screenshot and about documentation I followed without results.
     

    Attached Files:

  6. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    Cool, I will test it and post the results. Thanks for the fast reply! Nice weekend
     
  7. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    427
    Works again after 2.11 update. Thanks for super speedy response :)
     
  8. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Hi Jason

    Just updated from 2.0 to 2.1 (with the 2.11 patch) and am getting the following error with texture clustering set to three:

    Shader error in 'MicroSplat/WorldCreatorTerrain': Unexpected token ';'. Expected one of: ',' ')' at line 873

    Code (CSharp):
    1.      half4 ClusterSampleNormal(float3 uv, half4 cluster, MIPFORMAT mipLevel)
    2.          {
    3.    <SNIP>
    4.             a1.ga *= 2;
    5.             a1.ga -= 1;
    6.             #if _TEXTURECLUSTER3
    7.                float3 uv3 = float3(uv.xy * (1 - _ClusterScaleVar);     <--- THIS LINE IS MALFORMED / TRUNCATED
    8.                #if _PACKINGHQ
    9.                   half4 a1 = half4(MICROSPLAT_SAMPLE(_ClusterNormal3, uv3, mipLevel).ga, MICROSPLAT_SAMPLE(_ClusterSmoothAO2, uv3, mipLevel).ga).brag;
    10.                #else
    11. ...
    12.    
    switching to two texture clusters works OK.
     
  9. Larzarus

    Larzarus

    Joined:
    Jun 4, 2016
    Posts:
    27
    Also...

    When using a Substance generated maps, I get the following error when I click 'update' in the config texture packer (with or without texture clusters):


    InvalidCastException: Cannot cast from source type to destination type.
    JBooth.MicroSplat.TextureArrayConfigEditor.RestoreSourceTexture (UnityEngine.Texture2D tex) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:968)
    JBooth.MicroSplat.TextureArrayConfigEditor.RestoreSourceTextures (System.Collections.Generic.List`1 textures, SourceTextureSize stz) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:985)
    JBooth.MicroSplat.TextureArrayConfigEditor.CompileConfig (JBooth.MicroSplat.TextureArrayConfig cfg, System.Collections.Generic.List`1 src, System.String ext, Boolean isCluster) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1017)
    JBooth.MicroSplat.TextureArrayConfigEditor.CompileConfig (JBooth.MicroSplat.TextureArrayConfig cfg) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1517)
    JBooth.MicroSplat.TextureArrayConfigEditor.DelayedCompileConfig () (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:855)
    UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)​

    It works with image textures, just not the dynamic maps created by 'Substance in Unity' v2.0.1 in Unity 2018.2.0f2 I tried different options in the Substance Graph (output size, format, etc) without result.

    It was working fine in V2.0 of MicroSplat.

    PS: I miss the convenience of MicroSplat generating the maps from a substance automatically. Any hope of getting that back in 2018.2 using the 'Substance in Unity' plug-in incarnation of substances?
     
  10. miklelottesen

    miklelottesen

    Joined:
    Mar 7, 2015
    Posts:
    19
    Programmatically changing material properties/settings at runtime

    Hi

    I know this question has been asked before, but I wish to make it possible for the user to change some of the settings in the main terrain Material (eg. tessellation on/off, blend quality, etc.), and I understand that the correct procedure is to generate shaders with different settings, then switching between these shaders as the shader used in the Material. (There might be other posts about this in this thread that I have missed, in which case I apologize.)

    Now, ideally I'd want it to be possible to change each setting individually (without having to generate 50 or so shaders for each combination possibility), but if that's not possible I can definitely be content with just having "low", "medium", "high" and "ultra" shaders. But when attempting the latter, I ran into some problems:

    I created a shader and named it "TerrainLow". Then I generated another called "TerrainMedium". In the terrain Material, I picked TerrainLow and set blend quality to Fastest. Then I picked TerrainMedium and changed blend quality to Balanced, but then when I pick TerrainLow again, it's been changed to Balanced as well. In fact, all settings (except for the Shader name) seem to change for all shaders, when I attempt to change them for just a single shader. I must be doing something wrong?
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The shader compiler settings are stored with the material, so make a material for each and change them. At runtime, you can just change the shader, but use the material to store the compiler settings.
     
  12. adndima

    adndima

    Joined:
    Jun 11, 2015
    Posts:
    47
    I'm using Vegetation Studio and Microsplat, the problem is that the shadows from the plants turn black, does anybody know why this happens?

     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Nope, but MicroSplat doesn’t have any shadowing code in it, it’s surface shader based (well, unless your using the LW render loop)..
     
  14. adndima

    adndima

    Joined:
    Jun 11, 2015
    Posts:
    47
    Here's how the standard shader looks

    https://1drv.ms/u/s!Au8tZndzxPGC2Av340bIbY7-L7Mm
     
    Last edited: Jul 15, 2018
  15. adndima

    adndima

    Joined:
    Jun 11, 2015
    Posts:
    47


    here is the solution to this problem
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you repack the maps on the texture array config and reassign the new normal array? Also, do you have your own AO/Smoothness maps or are they being auto generated?
     
  17. adndima

    adndima

    Joined:
    Jun 11, 2015
    Posts:
    47
    Each texture has its own AO/Smoothness maps
     
  18. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    Using 2.11 on a fresh project, Unity 2017.31f1 I get an obsolete API warning. And this.

    Assertion failed: Property (_Control3) already exists. Use SetTexture instead.

    I also notice that most of the texture compression settings turn everything white. Is this expected behavior?

    I get this warning when it happens.

    Graphics.CopyTexture called with mismatching mip data sizes, perhaps formats are incompatible? (srcsize=4096 dstsize=16384)
    UnityEngine.Graphics:CopyTexture(Texture, Int32, Int32, Texture, Int32, Int32)
    JBooth.MicroSplat.TextureArrayConfigEditor:CompileConfig(TextureArrayConfig, List`1, String, Boolean) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1358)
    JBooth.MicroSplat.TextureArrayConfigEditor:CompileConfig(TextureArrayConfig) (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:1517)
    JBooth.MicroSplat.TextureArrayConfigEditor:DelayedCompileConfig() (at Assets/MicroSplat/Core/Scripts/Editor/TextureArrayConfigEditor.cs:855)
    UnityEditor.EditorApplication:Internal_CallDelayFunctions()

    Same stuff on 2018.2.0b10.

    A related question. Will automatic, adjust automagically when I build for Android or do I need to force ETC2?
     
  19. superkratos

    superkratos

    Joined:
    Sep 4, 2017
    Posts:
    112
    Thank you for your quick response,Jason! This fix should help! And sorry for the late reply because I was stuck into other stuff last week:D
     
  20. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    I'd like to request a world space distance blend option for mobile devices. It is faster than other anti-tiling methods and works well enough for mobile.

    I saw it in an amplify shader video and it made me wish microsplat had it too. It should fit in nicely with your anti-tiling package.



    Also, this is something you might find useful. It outlines a method for a single calculation hue, saturation, brightness adjustment. It could be worth a look.

    http://www.graficaobscura.com/matrix/
     
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    How is this different than the distance resampling option that’s already there?
     
    EvilGremlin likes this.
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Automatic chooses ETC2 for Android, PVRTC for iOS and DXT for everything else.

    Which texture setting is producing this error?
     
    EvilGremlin likes this.
  23. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    21
    We update to 2.11 from the Store and assign the Gradient Sampler and voilà! It's fixed. Thanks jbooth!
     
  24. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    You bake out a composite texture for the terrain that is used in the distance. I haven't compared it because ASE only has 4 splat maps and that would not be a fair comparison to Microsplat's 16. But it is faster than resampling in theory.

    Also, please do check this out. I mean, if optimization is as important to you as I think it is.

    http://www.graficaobscura.com/matrix/


    DXT PVR ETC2

    I didn't test the others. It does the same for both albedo and normal. Okay... now it is black instead of white? Not sure what I did different to get that.

    microsplat.png
     
  25. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Hi Jason,

    I bought your 'Puddles, Streams, Lava & Wetness' module today, got the wetness working nicely, but after enabling streams the whole shader was messed up with following errors:

    Shader error in 'MicroSplat/Terrain_BlendWithTerrain': maximum ps_5_0 sampler register index (16) exceeded at line 3028 (on d3d11)

    Shader error in 'MicroSplat/Terrain': maximum ps_5_0 sampler register index (16) exceeded at line 1552 (on d3d11)

    Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SCREEN LIGHTPROBE_SH
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING


    After that I could not open the shader generator anymore and the whole terrain went black.

    Any suggestions how I can fix this without having to remove MicroSplat and do the whole texturing from the scratch?
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You have too many features turned on, basically. Hardware has a 16 sampler limit, but on modern apis you can share samplers, so in some cases I can squeeze extras in there.

    You can restore the interface by assigning the shader to a new material, then unchecking on option to recompile it.
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I already support that via the global texturing module and the render baking tab. That said, it’s not as big as an optimization as it would be on something like unity’s shader, because MicroSplat only samples 4 texture sets regardless of how many are on the terrain.

    I’ll see if I can repro the compression issue.
     
    EvilGremlin likes this.
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, I have a fix for the compression settings and will upload it the next time I have a net connection for my laptop (traveling in a converted school bus right now)
     
    EvilGremlin likes this.
  29. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231

    I didn't realize that the global texturing module did that. Thanks for clearing that up.

    Cool. Thanks for the fast support.
     
  30. Aaron2348

    Aaron2348

    Joined:
    Dec 12, 2016
    Posts:
    328
    Hi so i'm on a Mac trying to use Micro splat for my first time and i have little problem, when I convert to the microsplat material the terrain turns white and i only can see my material when i paint or edit the terrain other than that is just plain white, how can i fix this?
     
  31. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231

    I was just having this issue. He has a fix for it. See this reply here:

     
    Aaron2348 likes this.
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unless you’ve set the compression settings to force instead of automatic, I don’t think this is the same issue as listed above. Do you have any errors in the console?
     
    EvilGremlin likes this.
  33. Aaron2348

    Aaron2348

    Joined:
    Dec 12, 2016
    Posts:
    328
    Hey thanks for getting back to me, Im actually away for a few days but once im online again i will look into this, but off the top of my head errors in the console a i cant recall...but im also working in 2017.3 which idk if that could be the issue
     
  34. Aaron2348

    Aaron2348

    Joined:
    Dec 12, 2016
    Posts:
    328
    And im sure i did not change any settings
     
  35. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Hi Jason,

    I couldn't restore it that way, so I removed MicroSplat completely from my project and started then from the scratch with it, but I again have problems with the 'Puddles, Streams, Lava & Wetness' module. Wetness is working fine, but puddles are not working, the brush only raises my terrain. Similar problem with streams, the brush raises the terrain and makes a kind of hole. I've added two videos to show the problems. Any suggestions what causes this?
    BTW: When I start the demo scene, nothing happens.

    Other bug, when I select Packing Mode Quality in the MicroSplatConfig I have about 122 errors (see image)

    Puddles:


    Streams:


    Packing:
    MicroSplatBugs.png
     
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Both your videos show up as unavailable. A fix was submitted yesterday for what looks like your error, but they should only be an issue if you are using forced compression types.
     
  37. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Videos are working now! (first time I uploaded videos to YouTube, sorry).
    Compression was automatic!
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok; I can see them now; and chance he Unity height painter is still active? Puddles have no effect on the height of the terrain (unless using tessellation). Also, do you get any errors when running the example scenes?
     
  39. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    I'm using tesselation, Unity height painter is not active and no errors in examples scene. The strange thing is, that puddles are only raising terrain, but no water is visible.


    I checked the compression bug again. I wasn't aware that the quality setting was adding some smooth settings and they were set to 1024, while all others were set to 2048. Setting smooth to 2048 removes the errors!
     
    Last edited: Jul 19, 2018
  40. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    i had the same error
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Found this too- the smoothness array was pulling its nip count from the anti tile array size instead of the smoothness array size. I’ll upload a patch when I next have reliable internet, which will most likely be Monday.
     
    EvilGremlin likes this.
  42. Solphist

    Solphist

    Joined:
    Mar 1, 2015
    Posts:
    12
    Hi,

    I'm pretty new to microsplat and had the same problem I think, I added a shiny new tessellation shader and my whole terrain went magenta and the microsplat shader state changed.

    Do you have any idea how many samplers each add-on takes normally?
    That way I can determine the best combination to run.

    Perhaps you could add how many shaders are in use to the interface ?
    Perhaps add a little number beside each add-on of how much it would 'likely' cost in terms of shaders?

    Is there a faq/tutorial for things like this with fixes for them should they occur,like moving the shader and unchecking it?

    Your stuff is great by the way :)

    Kind regards,
    Sol
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Unfortunately it’s not that simple. Basically hardware supports 16 samplers per shader, but some APIs allow you to share samplers if they have the same state, which I do when possible. Additionally, Unity compiled different versiions of the shader for different lighting configurations. So, for instance, if light probes are used a sampler is used for the light probes texture. So there’s no easy way for me to calculate usage and prevent too many.

    That said, if you click on the shader you can see how many textures it uses, which is a pretty good count of unshared samplers (OS X OpenGL, for instance, doesn’t support samplers).

    I may try to add a mode to pack all effect textures into a texture array in the future. This will be clunkier than the current system, and waste a bit of memory if you are only using some of the effects, but might be a nice option for reducing sampler usage. That said, tesselation doesn’t use extra samplers, so if your seeing an error there it may be something else. The sampler error usually says something about a max of 16 sampler states in it.
     
    EvilGremlin and LennartJohansen like this.
  44. Solphist

    Solphist

    Joined:
    Mar 1, 2015
    Posts:
    12
    Thanks for the reply.

    "The sampler error usually says something about a max of 16 sampler states in it."
    Oh that was definitely the error, so it was probably another shader, maybe the wind one, I was just playing around with it to see what each of the things did to my terrain, then playing with sliders like a kid in a candy store :)

    While I understand the basics of some of the stuff, the full technical details are beyond me at the moment.
    Just how to fix it, should it occur is great and what to keep an eye out for in future is good enough for me and you've already answered that ;)
     
  45. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Did a quick test this weekend and it seemed that tesselation doesn't work on iOS / iPhone X - true? Known? Unknown?
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Never tested it, but doesn’t surprise me at all; most likely unity doesn’t support it or your particular device/api doesn’t.
     
  47. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    @jbooth
    What might be the reason for terrain shadows becoming a lot darker when I bake the terrain with a Shadowmask mixed light mode?

     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No idea; there’s actually no lighting or shadow code in MicroSplat as it’s just a surface shader; so it should respond to lighting the same as any other surface shader does since that code is generated by Unity.
     
  49. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Looks like it needs 2018.1. I just tried a quick new project creation and I'm getting a single compile error on (of all things) Microsplat/Tesselation_Example - looks like a unity signature has changed. More later when I'm back at the project.
     
  50. DevIsDave

    DevIsDave

    Joined:
    Aug 8, 2017
    Posts:
    19
    So just to confirm, this asset does not support WebGL 2.0 nor are there any plans to? I've tried it out and it throws an error:
    I've tried this with uncompressed textures and the result is the same. The only thing I can see online that hints at the cause is this link on the function, but I gather this is potentially not something you can correct on your end?
     
Thread Status:
Not open for further replies.