Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Lux snow shader for unity 5 [beta 22]

Discussion in 'Unity 5 Pre-order Beta' started by larsbertram1, Jan 31, 2015.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    just a first preview on the upcoming snow shader for unity 5.
    right now it supports dynamic accumulation based on an adjustable snow direction, snow erosion, melting and drying.

    update: shader is online now and works with unity beta 22.
    get it from my github repo:
    https://github.com/larsbertram69/Lux_2.0/


    feedback is welcome ;-)

    thanks,
    lars





    melting snow

    melting_snow.png


    melting snow using the erosion feature

    melting_snow_erosion.png
     
    Last edited: Feb 5, 2015
    m4d, Dweep, gurayg and 3 others like this.
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    as usual, pretty cool lars.
    edit : Just curious, what the plan for lux terrain shader? would be cool if there's a variant between standard terrain, wet terrain, and snow :)
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks rea!
    as far as the terrain shaders are concerned: beta 21 brought a lot of changes and i will see, what unity might come up with.
    terrain shader solutions usually are a lot of work – so i might just update my color map ultra shader package...
    but we will see.

    lars
     
  4. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    as always... epic. :)
     
  5. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    @lars - What maps/tex do your Unity5 terrain shaders need? I love the wet/puddle shader and the snow build-up shader, but would like to know how easy they are to implement over and above the needs of the basic Unity5 standard terrain shaders.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the snow shaders currently are no terrain shaders but shaders for custom geometry. next to diffuse, normal and smoothness ( spec is hardcoded as dieletric at the moment) they need height and ao. snow (diffuse, normal, smoothness and micro distribution) are global maps.
     
  7. SazanOFF

    SazanOFF

    Joined:
    Oct 20, 2014
    Posts:
    11
    Thank to you. Is very good work. Waiting this system in AssetStore.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    i have updated the shader to work with unity 5 beta 22 and pushed its initial version online.
    i have also added some more sophisticated functions for snow accumulation and adjusted the setup script so in case you also use the wetness shaders – you will have to update those too.

    get it from my github repo:
    https://github.com/larsbertram69/Lux_2.0/


    snow accumulation now supports a growing amount of snow flakes:

    accumulating snow flakes.png
     
    Last edited: Feb 5, 2015
    Botanika likes this.
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    during the last 2 days i have been looking into adding decals to the snow shader in order to create much more lively environments.

    and as i wanted the decals to blend smoothly with the base surface (using alpha blending) without having to use forward rendering – while the camera would use the new deferred rendering pass – i worked on a "deferred decal snow shader" that supports alpha blending while still being rendered using the deferred rendering pass.
    so finally i came up with a (cg only) shader that does all this: it uses alpha blending (giving you nicely fading borders) while still being rendered using the deferred pipeline.

    finally i have tested it using dantus’ outstanding decal framework – and it works just fine!
    with a bit more of investigation i will probably not even have to use some hacky "alpha blending in deferred" but can simply use "alpha testing" and still get absolutely smoothly fading decals due to dantus’ superior framework (which lets you "steal" uvs from the underlaying geometry).

    snow decals are fully dynamically and react to all changes you make to the values of "snow amount" or "snow melting".

    so this it what you might archive:

    LuxDeferredSnowDecals_anim.gif
     
    Reanimate_L and Botanika like this.
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes i did.
    but those decals do not suite our needs: no ambient lighting, no ambient reflections, no GI – no lightmapping.
    so at their current state they will most likely never fit a given environment in case you use any of the features mentioned above (and you should use a bunch of it!).
    for this reason i have chosen to render "real" geometry in the regular pipeline that might take advantage of everything unity 5 has to offer.

    lars
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    as a video will most likely give you a much better idea about snow decals, here we go.
    all this would not be fancy at all – if it was not deferred only ;-)




    DeferredSnowDecalGBuffer.png
     
    Last edited: Feb 8, 2015
    Botanika likes this.
  13. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    664
    I am working on something very similar at the moment and are stuck with the same problem on decals.
    Your version looks pretty good but I wonder how it works exactly. Are you able to blend the normals as well or are they "clipped"?
    I was able to have alpha tested normals and blended albedo value.

    But what I want is a way to blend each channel by the alpha value (Albedo, Normals, Metallic, Emission...).
    Did you fix any of that in your shader?
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    shader blends all gbuffers – which works fine for albedo (rt0) and normals (rt2):
    rt0 stores occlusion in the alpha channel which currently is not used anywhere as far as i can say.
    alpha of normals (rt2) is unused too.
    metallic does not exist: it is specular color (rgb) and smoothness (a) – and as smoothness is stored in alpha of rt1 using alpha blending leads to some problems here...
    emission (storing ambient diffuse and specular reflections in rt3) is ok as alpha is unused as far as i can say.
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    And thanks for making me having another look into the different gbuffers which helped me fix a huge bug...
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    and here is the latest preview:

     
    id0, Botanika and red2blue like this.
  18. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    225
    Great work, Im impressed with your shader, and believe me, Im rarely impressed ;)
     
  19. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    664
    After my post I have been working on this and came up with a decal which blends all channels, yay!
    But it seemed that the reflections where gone and I assumed that they are in the emission map.
    Now I read your post:
    Do I have to choose another Camera Event where reflections haven't been calculated?
    Or are reflections not calculated in screen space?
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, i would like to have deferred ambient diffuse and reflections too – but they are calculated while filling the gbuffer.
    may be doing it this way made it easier to blend between light and reflection probes… but it is not most efficient, i think.
     
  21. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    664
    At least that explains something. I was always wondering why only the standard shader has reflections.
    Maybe there can be an option for "UseLightProbes or DynamicGI" and if not then skydome reflection is calculated in screen space?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    dynamic gi comes from lightmaps. so its always per object and has to be written to the gbuffer.
    light and reflection probes could be added in the final deferred lighting pass – if they were deferred and culled like lights i guess.