Search Unity

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

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

  1. Sovcenko

    Sovcenko

    Joined:
    Apr 17, 2018
    Posts:
    2
    Dear Jason, first of all, Microsplat is awesome. Thank you.
    That being said, I kinda need to get a toony/cell shading effect on my game. I saw your "low poly" asset, but I need to achieve another kind of rendering (like Borderlands for the obvious example). I have some basic knowledge in shader, but not enough to goes blindly into your code.
    - Is there a way to change the "contrast" of the light/shadows ? To sharpen the shadows ?
    - Is there a way to add some global quantization effect without post-processing, into the terrain directly ?
    - Is there a way to add an outline on the terrain without post-processing ?

    Thank you again.
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,603
    Depending on how lighting is done (baked, realtime), you can modify the shadow maps or shadowing shaders in unity to get different results. Generally, outlines and quantization is going to be better handled in post processing, why do you want to do it directly in the terrain shader? Outlines on specific objects usually involve drawing the object more than once which can be bad for performance (you draw it expanded slightly as black, then draw it again over itself).
     
  3. Blarghle

    Blarghle

    Joined:
    Aug 19, 2014
    Posts:
    1
    Hi Jason, this is a wonderful tool, a sorely needed component for unity's terrain system right now.
    I've been working with splatmaps generated from World Machine and importing them onto the terrain, but which texture layers correspond to which splatmap channel is unclear. Right now I'm importing two splatmap .tgas, with a splatmap loaded into each channel of each texture, for 8 splatmaps total.

    I assume I have to mirror the texture layer order with the splat map channel order?
    Which splatmap channel gets assigned to which texture layer?
    It would be very useful to be able to assign channels to texture layers from within the inspector, it would cut back on a lot of photoshop channel shuffling for large groups of terrains with many layers. If not, labelling them would be quite useful.

    I've also seen a few bugs with LWRP support, for instance enabling per-pixel normals in the material breaks the shader in a way it can't recover from. The terrain disappears and disabling per-pixel normals doesn't bring it back. Replacing the material file with a fresh one is the only thing I've found that will recover it.

    My unity version is 2019.2.3f1, using LWRP 6.9.1

    EDIT: I just realized that the reason I'm having trouble figuring out the layer order is because it doesn't look like it's using the second splatmap texture at all.
    I imported two debug splat maps to my terrain, and changed all my texture layers to rgb colors. The debug splat maps are text labels in each channel of each texture, ie R1, G1, etc. The textures appear to load in flipped on both axis, which isn't a huge deal, but the last four of my 8 materials don't display at all. I've updated my texture array, and both splatmaps appear to be attached to my terrain properly. I get one of the "Duplicate basemap name: '_MainTex'. Ignoring" errors, maybe that's related. Am I doing something wrong?
    Capture.PNG Capture2.PNG Capture3.PNG
     
    Last edited: Sep 10, 2019
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,603
    Splat maps are RGBA format, if you leave the alpha out it will default to 1, which would make the fourth texture get a weight of 1.
     
  5. ncho

    ncho

    Joined:
    Feb 1, 2014
    Posts:
    80
    Is there an option to control mipmapping the same way as with the standard Unity shader? At least I can't find any options regarding it...
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,603
    What do you mean?
     
  7. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,357
    For custom splat maps, is the math for uv localtoworld and worldtolocal the same as when using unity's splats?
     
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,357
    Jumbled a few things into a single file as I have more abstraction around it, but hopefully this is useful.

    It's a simple abstraction around working with custom splats. Couple of utility functions for converting to colors and back. Threw in a localtoworld and worldtolocal also as static methods.

    https://gist.github.com/gamemachine/b2e33112c4b173f868b37bbb47ef9b63
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    3,603
    Yes, the only difference is which textures are used to look up the weights.