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
    Yeah, a few others have done something like this, but none of it's ever made it to release. It's not that hard to do- the main issue is if you do it on non-tessellated terrains then it's particularly slow and too low resolution to be useful. But if you do it only on tessellated terrains, then there's a bunch of assumptions there (that you have tessellation, that all your users can afford it, etc).
     
  2. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    could use a hand on the Specular Fade, here's my scenario:

    Water height is at 59, want to knock out the specular below that with a fairly quick falloff.


    upload_2018-8-27_19-12-52.png

    Tried:
    upload_2018-8-27_19-27-29.png
    And:
    upload_2018-8-27_19-28-40.png
    But same result in all cases.
     
  3. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    x is where fade ends and y is where fade starts, so x = 55, y = 59 will give you a fade from 59 wet to 55 try.
     
    jbooth likes this.
  4. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Ah, I see. Well, understanding those limitations, I'd still be thrilled to see another module that does this, but I appreciate that it would have less market potential.
     
    Last edited: Aug 28, 2018
  5. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    I assume you mean "from 59 full specular to 55 no specular?"

    Doesn't work for me. No change to these parameters results in any change to the specular.

    Do I need to force recompile of the shader?

    Is there a dependency on another feature?

    I can change these values randomly, scroll up and down, and the image doesn't change.

    upload_2018-8-28_7-3-51.png

    upload_2018-8-28_7-3-19.png


    upload_2018-8-28_7-11-0.png

    upload_2018-8-28_7-4-37.png
     
  6. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    fade.jpg
     
    Last edited: Aug 28, 2018
    mmaclaurin likes this.
  7. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Yes, I believe it works for you :) I'm trying to figure out why it doesn't work for me.

    Wondering if it's coordinate space? Is your water height at 0? Are the numbers relative to water height or absolute world coords? Hmmm....damn day job...
     
  8. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Everything was going well enough when I clicked the per texture UV scale checkbox for a texture, and had this happen. It was all green and muddy beforehand. It was accompanied by these errors:

    Shader error in 'MicroSplat/WC_TerrainPart_9': invalid subscript 'xy' at line 902 (on d3d11)

    Shader error in 'Hidden/MicroSplat/WC_TerrainPart_9_Base-170271495': invalid subscript 'xy' at line 898 (on d3d11)



    I then switched off the checkbox for advanced details (got that yesterday and trying it out), and I got the terrain texturing back. Maybe a one off, don't know, thought I'd better report it.
     
  9. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    My water height is 10 m, numbers are world coords.
     
  10. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244


    Here you can see the wetness height is clearly at 60, but a fade from 55 to 60 does not fade (or affect) the specular.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You should let @wmpunk know as that’s his module. Likely a code error in there.

    It's in world space..
     
    JBT27 likes this.
  12. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    In that case I'm pretty sure I've found a bug (see video) - anything you'd like to take a look at? My next step is to delete the microsplat directory and reinstall and see if that fixes it.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Pretty sure it's something with your setup or version of MicroSplat. About a week or two ago the asset store was delivering old versions to people, but I'd be surprised if the UI showed up in that case. You might want to make sure your on the latest and try it in an example scene? Pretty sure the math is right (I used the same math elsewhere), but perhaps that would narrow the possibilities down.
     
    mmaclaurin likes this.
  14. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    Got it!

    Didn't figure it out, tho - just did the delete & reinstall and boing.

    Very satisfying though. Now the ocean looks like a solid volume instead of a thin shell - what lengths we will go to for that last few pixels.

    upload_2018-8-28_19-55-30.png
     
    jbooth likes this.
  15. robbob44

    robbob44

    Joined:
    Apr 16, 2018
    Posts:
    22
    I know this is pretty ancient at this point, I put this issue on the backburner since I was still having difficulty finding a solution, but I am fiddling with it again today.

    For the "deferred" decal shader we are using, if I manually change the LightMode tag for the SubShader to either Always, ForwardBase, or Vertex it no longer removes the Microsplat blended terrain effect but does alter the appearance of the decal slightly: removing the normal mapping and a loss of detail (and I believe the performance is worse). Ideally I would have the decal appear how it does previously if possible.

    From the notes in Unity documentation for the ShaderLab "These tags are rarely used manually; most often shaders that need to interact with lighting are written as Surface Shaders and then all those details are taken care of." As far as I can tell the shader I am using is also a surface shader since it uses the surface pragma.

    Does anything come to mind (i.e. some pragma I'm missing, or maybe to support secondary shaders such as the microsplat blended terrain one) that I could tweak in the shader that me changing the lightmode is correcting for this shader to properly include the microsplat blended terrain effect? I have already been experimenting with the render queue order for this shader without any success (after a point the shader just fails to render correctly rather than incorporating the blended terrain effect). Adjusting the RenderType tag from Opaque to Transparent also had no effect.

    Just to note, The LightMode tag was not previously specified in our decal shader, and the LightMode of "Deferred" is the only setting that has no effect on the original appearance (but still removes the Microsplat blend effect).
     

    Attached Files:

    Last edited: Aug 31, 2018
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Those tags are most likely forcing the shader to render in forward rendering, which no longer makes it a deferred decal shader. Basically, a deferred decal system blends with the data in the GBuffer- if you force either shader to render in forward, then that data isn't there to do the blend correctly. I'd use the frame debugger and look at the draw calls to see how each layer is being rendered..
     
  17. robbob44

    robbob44

    Joined:
    Apr 16, 2018
    Posts:
    22
    When using "LightMode"="ForwardBase" (correctly works with Microsplat Blend w/ Terrain effect but other features of the shader are not working): Out of a total of 178 events when the camera is just at this position, the microsplat blended terrain effect is applied on event 130: Draw Mesh (MicroSplat/Skiia_x3_y4_BlendWithTerrain, SubShader #0 Pass: FORWARD (FORWARDBASE)) into FactoryTempTexture. Three more events occur for BlendWithTerrain. Then the first decal is drawn on event 135: Draw Mesh (Hardsurface/Decal/Deferred Packed Parallax, SubShader #0 Pass: DEFERRED (FORWARDBASE) into FactoryTempTexture. No other events alter the decals (just different events for each one).

    When using an unspecified LightMode (appears correct except it removes Microsplat Blend w/ Terrain effect): Out of a total of 170 events when the camera is in the same position, now the first decal is applied on event 25 with Pass: DEFERRED (DEFERRED)) into Deferred GBuffer. The microsplat blended terrain effect is applied on event 138 but it does not draw the terrain blend effect in the bounding boxes of the decals.

    Is the issue that our shader is using Deffered GBuffer and not FactoryTempTexture like Microsplat is using, or is it the order of the events? Regardless I'm not exactly sure what can be done. To me it seems like I may possibly want to use the DEFERRED (FORWARDBASE) pass but still use Deferred GBuffer somehow.
     
    Last edited: Aug 31, 2018
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So what's happening is that unity is rendering the blend with terrain effect in the forward pass; which happens after the gbuffer resolve- but I would expect that to blend with terrain but draw over the decal, not the other way around..

    Ideally everything would render in deferred, with the blend effect blending with the existing gbuffer data. But I don't think it's possible to hack that within the confines of a surface shader, which abstracts the various pass semantics. If you send me a small repro scene, I can look into it and see if I can trick it into doing the right thing.
     
  19. diego_ger

    diego_ger

    Joined:
    Dec 17, 2017
    Posts:
    8
    Hello. Thanks a lot for your answer. I have download MicroSplat.
    Regarding to the previous question about editing the terrain texture in different spots at runtime, can I ask to you for some hints about "grab the control textures from the material instance and edit them directly - bypassing the Unity Terrain system all together"?
    Because I would like to implement it with MicroSplat to be able to use more than 4 textures.
     
  20. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I have an issue. I removed Microsplat from my terrain and reverted back to Built In Standard, but the terrain only shows solid colors instead of textures. However, if I select a texture to paint on the terrain and I click on the terrain and hold the mouse button down then I see the terrain completely textured as it should be. When I release the mouse then it goes back to rendering in only colors.
     
  21. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Here is what it looks like:

    upload_2018-9-2_15-42-18.png

    And when I click on the terrain to texture it:

    upload_2018-9-2_15-42-54.png
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Basically what Unity's terrain system does is store a float[][][] of weights for the control data internally, then generate textures from that data and sets them on the shader. So you can go through Unity's Terrain system to set those values, but when you do that it will regenerate all the textures for the whole terrain, which can be slow. So rather than doing that, you can just get the control textures directly from the material with GetTexture("_Control0") and write your edits directly into that texture, avoiding the need to re-generate the texture on every edit. In either system you can use more than 4 textures though- MicroSplat just reads the same control data that the Unity shader does, it just uses it better.

    Set your base map distance to something larger.
     
    diego_ger likes this.
  23. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Ah, of course. Thanks.
     
  24. robbob44

    robbob44

    Joined:
    Apr 16, 2018
    Posts:
    22
    You should see a link to the test project in a Unity forum conversation from the other day. Thanks again for your time.
     
    jbooth likes this.
  25. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Jason, I finally did manage to reproduce the black-mesh issue with the Terrain Blending module -- sent you a download link on Skype last week. I know this is a hassle to look at, but I'd sure appreciate any help with it, it's a real problem for me. Thanks.
     
  26. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    321
    Thanks for MicroSplat, You are the Hero that saved my brain sanity :D
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Guess I should setup Skype on my new machine then..
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Reviews always appreciated!
     
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yay, Unity shader compiler issues- fixed and uploaded a workaround to the asset store..
     
  30. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    OMG really?! Thanks so much!!
     
  31. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    MicrosplatShaderGRoundTexture2.png GameShotGround1.png GameGround2.JPG Hi, I seem to have an issue when adding textures to microsplat and unity terrain. my new texture seems to paint an old texture. I also updated the texture in microsplat and unity terrain but it still paints the old texture.... Adding a new texture to unity terrain only paints the same old texture no matter what I select in unity 2018.2.6

    Also when I remove a height map from a Texture in microsplat and rebake, it still leaves the terrain tessellated for that texture....

    Also, any way to Tint channels of the textures. I find downloading PBR textures, sometimes you want to tint parts of the image, like the leaves on a ground texture are too vibrant and you want to darken them but the soil color is ok. Only option is too tint the entire texture which can ruin some of the correctly colored parts of the texture. Not sure if this is something thats possible.

    Bye the way, here are some screen shots below from my current project. This shader is amazing. Its SOO fast and the detail is nothing short of amazing.
     
    Last edited: Sep 4, 2018
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    You don’t need to add them to the terrain, just the texture array config, and hit update afterwards. If you remove the height map, it will generate one when generating the arrays. If you want to remove displacement from one texture, you can turn on the per texture displacement property and set it to 0. If you want to tint part of your image, use a image editor to mask the areas and tint it.
     
    Unlimited_Energy likes this.
  33. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Thanks, When I did add to the texture array It would act like it was painting under the texture. Even hitting update did not allow me to paint new textures added. I had to remove the microsplat terrain script from my terrain and re add it and then click the button on the microsplat terrain script to integrate with the terrain. The textures added to Microsplat were not transferring over to the Unity terrain either for me to paint.

    I will check today and see if its till doing it. Whatever the initial textures added to unity terrian before the script is added end up being the only ones I can use period.

    is it possible to use microsplat on regular non terrain objects? if not any chance of you doing a shader for adding parallax and tessellation ect for regular game objects like a wooden barrel or a rock, car ect?
     
    Last edited: Sep 4, 2018
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There's a mesh module coming, but it's more for splat mapping regular objects. If your looking for the standard shader + tessellation, I believe that's what Beast is.
     
    Unlimited_Energy likes this.
  35. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    516
    Hi tried to update to latest, 2.15, with 2017.4.9f1, and those error appeared. I implemented dummy func for now

    `JBooth.MicroSplat.UnityLDRenderLoopAdapter' does not implement interface member `JBooth.MicroSplat.IRenderLoopAdapter.GetPassType(int)'

    `JBooth.MicroSplat.UnityLDRenderLoopAdapter' does not implement interface member `JBooth.MicroSplat.IRenderLoopAdapter.GetVersion()'
     
  36. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    516
    Also whenever I try to modify some settings in the material I get :
    Code (CSharp):
    1.  
    And last but not least. Only first texture is modified when I used the per texture properties, others textures properties won't affect them. (Might be related to the shader generation issue)
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461

    If you delete and reinstall the core folder this will be fixed; or just delete the UnityLDRenderLoopAdapter..
     
  38. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Any way to remove the "white film" reflectiveness from the terrain. Unless looking directly at the ground any view angle makes the terrain look like its sprayed with some semi white gloss as a clear coat over it. I am trying to get a more "dry" look when viewed from a distance or angle. Ive played around with every setting from metallic to normal strength to tint to smoothness strength and brightness and nothing seems to fix this.

    WEhiteFilm.JPG
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That’s unitys GGX specular model, you can change the lighting mode to use a different mode (though this will force forward rendering)
     
    Unlimited_Energy likes this.
  40. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Ahh, I was thinking it was unrelated. Its ok, Thanks for the info, at least I know know.
     
  41. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    137
    Hey, messing around with vegetation studio now. Can't seem to get Microsplat terrain blending working on objects drawn by vegetation studio.Is there a special process aside from taking a prefab with the terrain blending component on it and adding it to the list of objects drawn by vegetation studio? In all of the integration documentation dealing with both Microsplat and vs, I can't find anything about this. Thanks for your time!
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I think that should be it, have you asked Lenart?
     
  43. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    137
    Yep, posted in both threads :)

    Will let you know if there's any helpful info to pass on for others.
     
    jbooth likes this.
  44. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
  45. DanielSnd

    DanielSnd

    Joined:
    Sep 4, 2013
    Posts:
    382


    What setting do I need to tweak so reflections on the Microsplat terrain don't look super ugly/wrong on medium/low quality? Right now it gets so different than my grass it's terrible.
     
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not sure exactly- you'd have to look into the graphics quality settings to see what you are selecting- I don't do anything with them myself, but since MicroSplat is a surface shader it inherits whatever stuff Unity is doing..
     
  47. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
  48. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    244
    From the english version: (instanced drawing seems to be the only relevant one?)

    Terrain: Terrain system improvements:

    • Introducing Brush and TerrainLayer assets
    • Added instanced drawing mode reducing the number of drawcalls by about 2 orders of magnitude.
    • Tools for creating adjacent terrain tiles
    • Seamless painting across terrain tiles
    • Autoconnection of terrain tiles
    • Basemap calculation moved to the GPU
    • Terrain paint tools have been moved to the GPU
    • Introducing terrain stamp tool.
     
  49. basil3

    basil3

    Joined:
    Dec 3, 2015
    Posts:
    29
    Hey,

    Quick question - I am using a projector to project Caustics onto my terrain and using the microsplat Tessellation module but where the terrain is Tessellated the caustics are clipped. I assume this is something to do with the render queue of the projector shader but I can't seem to get a result that puts the caustics on the tessellated part of the terrain.

    Any pointers?

    Ste
     
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
Thread Status:
Not open for further replies.