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. par-002

    par-002

    Joined:
    Jul 4, 2012
    Posts:
    52
    Gotcha... ok thanks so much for the quick replies! Great info.
     
  2. Kalakaluu

    Kalakaluu

    Joined:
    Aug 14, 2020
    Posts:
    3
    Hello there, I dont have really much Experience in Unity and choosed the Asset Microsplat to learn about Terrains.
    I created a Project to learn with Microsplat and everything went fine.
    Now, i created a new Project and i dont know what i missed, because something went wrong:
    The textures are shiny and looking wet. I copied the Microsplat settings from my old Project but its still shiny.

    Heres a Picture:
    https://ibb.co/cQsFpKP

    Whats wrong here ? With exact the same settings from the old Project shouldnt it be the same?
    Hope someone here can help me.
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    hard to say from the shot but likely you missed something when copying the data. Also, if you are copying within a project there are a number of references that need to be changed to the duplicate files.
     
  4. Kalakaluu

    Kalakaluu

    Joined:
    Aug 14, 2020
    Posts:
    3
    Hm, i guess it has something to do with the normal maps because if i turn off normal maps in microsplat settings the shinyness disappear. Still searching a solution maybe i should just continue use my old project but thx for the help.
     
  5. par-002

    par-002

    Joined:
    Jul 4, 2012
    Posts:
    52
    Hey Jason, so I did a bit more digging and I am not exactly sure how to get the MicroSplat alphamaps.

    My prior alpha values were based on a Terrain that was created with normal texturing and then "converted" to a MicroSplat array. Apparently, I was having issues because the GetAlphamaps() code was returning the original terrain texture data prior to me enabling MicroSplat.

    I have since deleted that Terrain and have started from scratch but this time working with MicroSplat before I put any textures on the terrain.

    Using a Texture Array of 9 different textures, when I actually use the following code to retrieve the alphamaps at any given point
    Code (CSharp):
    1. float[,,] aMap = terrain.terrainData.GetAlphamaps((int)terrainPositionXZ.x, (int)terrainPositionXZ.y, 1, 1);
    I do get the 9 Textures from the array but every single point in the terrain I only get a texture value for the first Texture (as seen in the following image):




    There is no doubt that the MicroSplat Low Poly is in effect and I am absolutely loving it. I just can't seem to get any correct information about the texture data at runtime.

     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    MicroSplat doesn't affect the alpha maps on the terrain at all- it just reads that data and renders it. MicroSplat on or off, you will get the same data from terrainData.GetAlphaMaps..
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You might check your textures to make sure you are setting up the smoothness values correctly for them (in the Texture Array Config), when you turn off normal mapping, you also turn off smoothness and AO values, since they are (by default anyway) packed in with the normal data..
     
  8. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    Hey @jbooth

    as always, thanks for the great work.


    I've started using Trax as part of a project, currently I'm having some performance problems with it (I think).

    As you can see in the image below, when profiling the player, the hierarchy view in the profiler is quoting TraxManager.LateUpdate as regularly using 9+ms.

    This seems high, I have a single trax manager in scene and 8 objects with simple 'sphere shaped' proxies, only 1 texture has a trax opacity > 0. I'm using a single texture and snow is turned off.

    trax3.JPG

    My settings for it are reasonably limited: 1024 Buffer Size, 300 world size - running on a GTX 1070 and an i7-8750


    Thanks for your time and the product.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    yeah, that not actually trax; you’ll notice the wait for target FPS in there? That’s it either waiting for VSync or waiting until the GPU catches up to add the new rendering commands.
     
  10. ChrisBng

    ChrisBng

    Joined:
    May 29, 2020
    Posts:
    7
    Hi Jason,

    I'm currently trying to setup terrains and assign custom splat maps programmatically - doing it by hand for 344x16 maps seems a bit cumbersome ;)

    The problem is that after doing so, the terrains don't look right until I select them in the editor:

    updateIssue.JPG

    In essence the code looks similar to this:

    Code (CSharp):
    1. var microSplat = terrain.gameObject.AddComponent<MicroSplatTerrain>();
    2. microSplat.templateMaterial = templateMaterial;
    3. microSplat.Sync();
    4. microSplat.customControl0 = splatMap;
    5. EditorUtility.SetDirty(microSplat);
    6. microSplat.Sync();
    I tried numerous ways to set things dirty, select terrains in a loop, even too recompile the shader via the MicroSplatCompiler, but so far no luck. Any idea how to get around this issue?

    Thanks
    Chris
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So you have to hook up the rest of the objects to the MicroSplatTerrain component- mainly the PropData, which holds per-texture properties and such, but others like the keyword object may be required (depending on features). Further, SetDirty only matters to mark the object dirty so the editor will save it, and Sync should only need to be called at the end.
     
  12. ChrisBng

    ChrisBng

    Joined:
    May 29, 2020
    Posts:
    7
    Whooohoo, now it works perfectly :D Thanks Jason
     
    camta005 likes this.
  13. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    hi, in regards to the streams and puddle module, is there a cheap way of sampling if there are streams or puddles in the current player position? I need that to play effects when player walks on water etc.

    Thanks for your time
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, there's no API for it, but you can sample the stream texture's pixels, it's a weight map with wetness/puddles/streams/lava in RGBA respectively.
     
  15. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    Thanks, I will look into it. Just so I know, will it be very expensive to play every frame or so you think? I can always create a collision trigger in the areas I have puddles etc, which should be straight forward to do, but ideally sampling the map directly will be much better if its not going to affect fps.

    thanks
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, it shouldn't be that expensive unless you have hundreds of objects doing it.
     
  17. Game-Armada

    Game-Armada

    Joined:
    Apr 29, 2013
    Posts:
    66
    Hey, just downloaded microsplat and bought the anti-tiling and advanced details module.
    This is a great product, however I am running into "basic" issues. I am using Unity 2019.4.2f1.

    Issue1
    : Trying to generate lightmap for the terrain, but can not make it work (built in render pipeline, forward rendering) the lightmap generates but does not effect the terrain.
    solved, juse needed to adjust the light intensity settings..

    Issue2
    : Trying to use post processing effects, mainly works, but can not get the ambient occlusion to work properly, the entire terrain becomes dark when adding intesity to the ambient occlusion.(latest post processing package)

    (not really an issue)Issue3: any additional package to add color variation to texture not only normal noise and not geo? (for example green grass and I'd like to add yellow patches)

    Looking forward for some help! THX!
     
    Last edited: Sep 7, 2020
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Advanced Details Module is not written by me, and the author has not replied to anyone in over a year- I would put in for a refund with Unity, as that module is not compatible with MicroSplat any longer. I've been trying to get it removed from the store so this doesn't happen to people. There is a Scatter module now, which fills much of the same role, and is supported.

    Issue1: MicroSplat is a surface shader in the standard pipeline- so it doesn't actually contain the light mapping code, and gets injected in by Unity. Most likely there is some configuration issue you have to figure out which doesn't have anything to do with the shader (In SRPs this is different, and it could be a shader issue).

    Issue2: The terrain has already been rendered into the buffer by the time post processing happens, so not a MicroSplat issue. However, most post processing AO systems require a normal map to work with, and if your in forward rendering you're not rendering a GBuffer, and the only normal which would be available would be the mesh normals, if you turn on the camera's rendering of a normal buffer. So likely what is happening is it's just darkening because it has no data to actually work with, but you'll have to look in the post processing system docs to figure that out.
     
  19. bobAZ2019

    bobAZ2019

    Joined:
    Mar 28, 2019
    Posts:
    28
    hi jb,

    i want to use the Global Texturing and want to achieve the desert-look like in your sample scene.
    i got the terrain converted to microSplat per Core doc.
    however, it seems like the microSplat GUI is not the same as the Core doc after the conversion.
    so, not sure where to proceed to use the Global Texturing.

    i tried to click on the SYNC button, nothing changed.
    tried SYNC ALL, nothing changed.... oh, would be nice to add "tooltips" to those buttons of what those buttons do.

    also, i checked out the Global Texturing doc but it doesn't explain how to use it... it explains "what it is" but doesn't explain how to use it.

    i'm using Unity 2019.4.9f1 and microSplat Terrain Collection 3.4801

    attached image is microSplat GUI after i clicked on the "CONVERT TO MICROSPLAT"
     

    Attached Files:

  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    That’s not the MicroSlat GUI- that’s Unity’s terrain UI- you need to select the material (either by double clicking on it in the MicroSplatTerrain component or selecting it in the MicroSplatData directory).
     
  21. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    I'm using MicroSplat (3.5) on a PS4 VR game and it's not working in VR mode. One eye (believe it's the left) renders mostly correct but the right eye doesn't render at all. The following errors are reported when making the build. I'm using 2019.4.8f1 with the new XR plugin architecture (3.2.15) which I believe is using single pass instanced. There's no longer an option use multi pass or singe pass and I suspect it may be related to SPI.

    Any thoughts on what might be going on?
    Thanks,
    Reggie

    Shader error in 'MicroSplat/Terrain_0_0_5b429a5e-404d-4478-ab5a-777e9121ad9c': Program 'vert_surf', 'S_RENDER_TARGET_INDEX' is not a valid semantic for attribute 'v.stereoTargetEyeIndex'
    Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL LIGHTMAP_ON DIRLIGHTMAP_COMBINED LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK LIGHTPROBE_SH STEREO_INSTANCING_ON

    Shader error in 'Hidden/MicroSplat/Terrain_0_0_5b429a5e-404d-4478-ab5a-777e9121ad9c_Base-1715511970': Program 'vert_surf', 'S_RENDER_TARGET_INDEX' is not a valid semantic for attribute 'v.stereoTargetEyeIndex'
    Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL STEREO_INSTANCING_ON
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If your in the standard pipeline, then it sounds like a bug in Unity’s surface shader system. In Standard pipeline I use a surface shader, which automatically handles things like VR and lighting, so there’s no VR specific code in the shader. Your best bet it to file a bug with them on it.
     
  23. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    Ok, I'll pass this off to the Unity support to look at. Is there any additional info or instructions I should give them other than what you mentioned above?
     
  24. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    I forgot to ask but what about those build errors? I don't think those would be related to a Unity bug and look like shader incompatibilities with the PS4.
     
  25. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, they are exactly what would be a unity bug. A surface shader does not contain this code- it gets generated automatically by Unity, so if something is wrong with the generation, you get a compile error like this. You'll notice the shader itself doesn't have any mention of stereoTargetEyeIndex and such if you search through it.
     
  26. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    206
    Hello @jbooth, thanks for your amazing software.

    I am creating a quality settings menu for our game and our artist has told me the Tesselation value of the terrain is the main factor, so I have two questions:

    1) On what script is this Tesselation defined, is it a shader parameter? Is there a static way to access it, or I need to manually link some material?
    2) Are there other settings that could be potentially performance-intensive?

    Of course I need values that can be switched at runtime and in build. My apologies for being quite ignorant on microsplat and graphics...
     
    Last edited: Sep 19, 2020
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    If you want to control the tessellation factor that can be accessed via the standard material.SetFloat calls. Usually what you want to do is do this on the template material and then call MicroSplatTerrain.SyncAll() to propagate the change across all terrains, but if your calling it every frame you might want to be more granular than that.

    If you need to turn features on/off, then you would need to pre-compile multiple shader variants and swap them at runtime. Feature cost is a complex topic, but under the Debug section of the material you can see how many potential texture fetches MicroSplat might do per pixel, though that can be reduced heavily by branch sampling in some cases. Anyway, there's an optimization guide in the core/documents folder.
     
  28. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    206
    Thanks! I will only call that SyncAll when graphics settings are changed.

    What is the name of the Float parameter? sorry for my lack of familiarity with graphics.
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's a _TessData1 and _TessData2 float4 that I think has all the tessellation parameters in it- you'll have to look in the fragment file and see which channel it's packed into, most likely _TessData1.x or something..
     
  30. DavidBVal

    DavidBVal

    Joined:
    Mar 13, 2017
    Posts:
    206
    thanks, I got it. In case anyone else wants it:

    SetVector ("_TessData1",new Vector4(tesselation,displacement,upbias,0))
     
  31. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    hey @jbooth -

    I've just installed scatter and updated all my modules to v3.5

    As soon as I updated them all I started getting the following Error everytime I recompile the shader
    Shader error in 'MicroSplat/Terrain': undeclared identifier 'config' at line 3121 (on d3d11)

    This only occurs with Tesellation turned on and per texture mip map bias. With per texture mip map bias turned off it's fine.

    erlin.JPG

    My terrain now appears to be broken, any ideas? I'm on Unity 2019.3.13f1

    erpic.JPG
     
    Last edited: Sep 21, 2020
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Can you show me the code around that line number? Line numbers change based on features, so they don't do any good unless I can see what code the issue is in.
     
  33. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    the line number in question in this snippet is 31, same error. I can send more if needed

    Code (CSharp):
    1. float3 OffsetVertex(inout float4 vertex, float3 normal, inout float4 tangent, float2 texcoord)
    2.             {
    3.            
    4.                #if !_MICROMESH && !_MICRODIGGERMESH && !_MICROVERTEXMESH
    5.                   tangent.xyz = cross(normal, float3(0,0,1));
    6.                   tangent.w = -1;
    7.                   tangent = tangent;
    8.                #endif
    9.  
    10.  
    11.  
    12.                float2 controlUV = texcoord;
    13.                #if _MICROMESH
    14.                   controlUV = InverseLerp(_UVMeshRange.xy, _UVMeshRange.zw, controlUV);
    15.                #endif
    16.  
    17.                half4 weights;
    18.                float3 worldPos = mul(unity_ObjectToWorld, vertex).xyz;
    19.  
    20.                #if _FORCELOCALSPACE
    21.                   worldPos = vertex;
    22.                #endif
    23.  
    24.                float3 worldNormal = float3(0,0,1);
    25.                #if _SNOW || _TRIPLANAR
    26.                worldNormal = UnityObjectToWorldNormal(normal);
    27.                #endif
    28.  
    29.                half4 mipLevel = _TessData1.z;
    30.                #if _PERTEXTESSMIPLEVEL && !_DISABLESPLATMAPS
    31.                   SAMPLE_PER_TEX(perTexMipLevel, 4.5, config, half4(1.0, 0.0, 0, 0.0));
    32.                   mipLevel.x = perTexMipLevel0.a;
    33.                   mipLevel.y = perTexMipLevel1.a;
    34.                   mipLevel.z = perTexMipLevel2.a;
    35.                   mipLevel.w = perTexMipLevel3.a;
    36.                #endif
    37.  
    38.                Config config = (Config)0;
    39.  
    40.                fixed4 w0 = fixed4(1,0,0,0);
    41.                fixed4 w1 = 0; fixed4 w2 = 0; fixed4 w3 = 0; fixed4 w4 = 0; fixed4 w5 = 0; fixed4 w6 = 0; fixed4 w7 = 0;
     
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Fixed, patch should be out tomorrow-ish..
     
    mmaclaurin likes this.
  35. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    Thanks very much, always super helpful!


    I do have 1 other problem since yesterday's update, some of my terrain textures are not affected by ambient light at all, they are 100% black when in shadow. I have swapped the textures in the config to match that of another texture which is affected by ambient light.

    Even after playing with all the per texture properties, some of the texture stay stubbornly unaffected by the ambient.

    Ever see this occur?
     
    Last edited: Sep 22, 2020
  36. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    I am using Microsplat and Microsplat URP support but can't add a material to a terrain in Unity without having it shown in pink! I have found this line in the doc: "Note that your shader will appear pink if it is compiled for a
    render loop which is not active in your project." but have no idea where to look into it and change things to make it work. Didn't find anything useful.

    Any help welcome making Microsplat work with URP. I am using the latest Untiy version 2020.1.6f1

    Thank you!
     
  37. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    This seems like the same problem I have and it still is unanswered. Can you please help with fixing this?
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, and in a surface shader I don't even write lighting code. Sounds like something with the lighting setup or you ability to see ambient on those textures- as ambient lighting doesn't know about what textures it's on, really.


    Read the Unity docs on how to convert or start a project in URP, then read the included docs for MicroSplat's URP module which show you how to change the render loop on the material to URP. Also read the asset description which clearly states which versions of the URP are supported, as you are running an unsupported tech release instead of an LTE release.
     
  39. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    I really like your new Decal addition. It’s working nicely on my terrain but I gave it a try on on MicroSplat Mesh and I’m having what seems to be some transparency issue. I’m not sure if it’s compatible yet with your Mesh module or it’s just me who did something wrong ?
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It should work on meshes, but only dynamic decals are supported. Can you post a screenshot of the issue?
     
  41. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    here's what I got. Took a copy of your decals.

    My floor here is a mesh ( it's all working fine on terrains). I tried both Dynamic & Static with same result.

    Thanks for your help

    EDIT: I just tried with your rocks decal and it works because there's an alpha map for it. And even Static seems to be working fine on a mesh ;-)

    EDIT2: it seems the alpha map is required. I probably misread that step by with an alpha it's all good.
     

    Attached Files:

    Last edited: Sep 23, 2020
  42. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Hi there. I just started using Microsplat recently and was trying to get terrain blending to work on some rocks that are supposed to be cropping out of the terrain. I'm seeing a couple of things that I don't really know how to debug/diagnose/resolve.

    1) I am seeing some hard seams from the terrain textures on my rocks, could this be related to my splatmap resolution?

    upload_2020-9-25_18-40-29.png

    2) I am seeing blending on the bottoms and sides of objects that I believe should be excluded per the curve/slope and contrast settings I'm using. Is this a problem with my UVs?

    upload_2020-9-25_18-40-58.png

    Any help, tips, etc, appreciated. Thanks!
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Your UVs don't come into play with terrain blending- the shader projects the UVs from the terrain (UV, WorldSpace, or Triplanar) onto the object, so the actual UVs on the model are not used. Note that the filtering you're expecting based on curve/slope is based on the vertex normal, which is interpolated across the face; not the face normal. The hard seems I'm not exactly sure about- it could be from the angle filter (or if you have a seem in the original texturing).
     
  44. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,560
    Microsplat continues to be wonderful, but I need a little help.

    I had my terrain textures setup so that they completely covered the texture below them. After I rebuilt the config file now the textures are all spotted, like they cover each other with little dots instead of slid. Im attaching an image of what I mean. Im using it in Mapmagic is that's important.

    I can't figure out what I did before to make the coverage solid and I am trying all kinds of configs like the interpolation contrast (which tightens the transition but the main texture does not go solid) and disabling normal Maps (I don't add normal maps in the config though) and I remember the first time I achieved the solid look it was just an accident so I don't remember what I did. Id love to get it back because it blends well with the grass when I add it.

    Do you have any ideas? Thank you.

    IMG_3321.fw.png
     
  45. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    It could be the Texture Blend Mode, try changing it to one of the other settings.
     
    protopop likes this.
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Either your height maps are different, or your splat maps (generated by MM2) are different.
     
    protopop likes this.
  47. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    I see, this is helpful to go on. It seems like the blending issues (sides and bottoms) I am seeing are possibly due to low polygon counts along the sides then resulting in the interpolation coming to the wrong conclusion about the slope. I'm going to try and raise the poly count a bit and see if that helps with that.

    For the seams, I think I will try and blend a bunch of different objects around the terrain and see if I notice any patterns that may be related to the way the terrain is currently textured. I'll also try putting the objects in my actual scene instead of just this dev scene with a junk terrain.
     
  48. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,560
    These are the settings for the micros plat config file and the material it generates.

    Is the texture blend mode you're talking about one of these?

    Screen Shot 2020-09-26 at 6.52.57 PM.png Screen Shot 2020-09-26 at 6.52.42 PM.png
     
  49. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,560
    Thank you:) Im using MM1 and its the same project, so I know its possible to get the original result, im just not sure what I changed. I remember back when that it suddenly became solid after a lot of testing, but I never figured out why and I just didn't change the MS config file for severe months until now.

    What do you mean my height maps are different? Mapmagic generates the height maps in realtime, do you think like there is some kind of mapmagic height map setting that I can change? Because I don't know really where my height maps are since they are generated.

    On the generated terrain there is this microsplat component that has splatmaps in them. Maybe its something here?

    Im grasping at straws but will try anything:)

    Screen Shot 2020-09-26 at 6.57.48 PM.png
     
  50. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    I was referring to the Texture Blend Mode setting here (different version?), I think the equivalent setting you listed is Disable Height Blending.
    upload_2020-9-27_10-34-53.png
     
    protopop likes this.
Thread Status:
Not open for further replies.