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

Lux-an-open-source-physically-based-shading-framework

Discussion in 'Assets and Asset Store' started by larsbertram1, Mar 19, 2014.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    :)
     
    neoshaman likes this.
  2. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    I meant, when fog is turned on the skin shader immediately turns almost fully the color of the fog, even when close to the camera. But I'll double check if it was in forward rendering (I am using Unity's post processing stack though, which by default turns on fog even in deferred rendering).
     
    Last edited: May 26, 2017
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i do not have any problems regarding fog – its just behaves the way it should.
     
  4. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Alright, I'll check my project settings, maybe I've done something wrong.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have just pushed a major update of version 2.02 to github.
    make sure you get it :)
     
    Alverik likes this.
  6. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    Thanks very much for this plugin! We are using face skin shader right now, we feel the face partly is overexposed to the lighting. I wonder in your shader, do you use the gamma parameter from sRGB texture to calculate the lighting? We are using gamma color space.
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have never tested the shader in gamma space, sorry. it is not recommended when it comes to pbs.
     
  8. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    Thanks for replying. So it is recommended to use linear color space for the project? Is there a way only set linear space for lux shader? I thought gamma color space is default chosen in Unity project?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    yes. linear color space is more or less a must have for physically based shading.
    no, that is not possible. or would be very expensive for the shaders had to convert inputs (textures, lights, ...) between the color spaces.
    that is right, but i guess due to the fact that older mobile platforms do not support linear color space.

    if everything in your project looks like it should do you may try to simply cahnge the "diffuse scattering on a ring" texture: that is the lookup table for diffuse skin lighting. you may change it to sRGB in the import settings or try to adjust it in photoshop.
     
    Alverik likes this.
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    lux 2.02 has been updated on github as well as i have sent it to the asset store.
     
    MarkusGod and neoshaman like this.
  11. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Good to know you continue support Lux, Lars. Howewer I have a problems with weather now. Some screenshots:

    P.S. By the way, unity now has a slider, even if you have texture in specular slot, but Lux dosn't have one. Why?
     

    Attached Files:

    Last edited: Jun 16, 2017
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i guess it is "accumulated wetness".
    if you disable wetness but enable snow some wetness still gets calculate in order to melt snow properly.
    please check the dynamic weather script and lower "accumulated wetness" to 0.0.
    i have pushed an updated script to the repo as well.

    because unity has a bunch of full time rendering engineers and i am a one man show :)
     
    Alverik, StaffanEk and id0 like this.
  13. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    For some reason everything back to normal now, but thanks :)
     
  14. Tofu-Huang

    Tofu-Huang

    Joined:
    Aug 25, 2015
    Posts:
    7
    Hi, I got problem with "Specular setup" on mac(& ios), it's fine on windos & android.
    I don't know why "Specular setup" became white...
    shown below
     

    Attached Files:

  15. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Also skin shader not recieved shadows from spot/point light.
     
    Last edited: Jun 18, 2017
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    get the latest version from github to fix this.
     
    id0 likes this.
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    works fine for me on mac using openglcore. metal however bugs...
     
  18. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Quicky about latest Plus release - is it coming any time soon?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i am collecting some more feedback concerning the personal version. then plus will be updated as well.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have submitted Lux Plus 2.02. so it should hit the asset store within the next days i hope.
     
    Alverik likes this.
  21. Tofu-Huang

    Tofu-Huang

    Joined:
    Aug 25, 2015
    Posts:
    7
    thanks,
    it's work on "mac" now, but got some WARNING on ios, and it's still white in the scene...
    (using Unity 5.6.1f1)

    WARNING: Shader Unsupported: 'Lux Standard (Specular setup)' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'Lux Standard (Specular setup)' - Pass 'FORWARD_DELTA' has no vertex shader
    WARNING: Shader Unsupported: 'Lux Standard (Specular setup)' - Pass 'SHADOWCASTER' has no vertex shader
    WARNING: Shader Unsupported: 'Lux Standard (Specular setup)' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'Lux Standard (Specular setup)' - All passes removed
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i have not looked into any support for metal so far.
     
  23. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm experimenting with the Lux skin shader and it looks great in the example, but when I try to use on another model I find that I don't have a texture for the Translucency. I looked at the sample map and I have no idea how to generate such a map for an existing head texture. Is there any guidance on how to create these maps from existing head textures? I couldn't find anything in the documentation.
     
  24. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    851
    im assuming you mean the thickness map? you can bake them with xnormal, or alternatively you could just create it in photoshop. lux needs them to be packed in a channel, dont remember off the top of my head which though.
     
  25. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I guess. It's the one with the greenish areas and dark areas.

    That's vague and I doubt I could accomplish it from that.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you may generate the thickness map by reverting the normals and then bake ambient occlusion in your 3d app.
     
  27. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    851
    The thickness is really just where light scatters more though an object, for example in people its the ears and nose that it tends to be most apparent in a strongly backlit situation.


    however its not limited to ears and noses, given a strong enough light it can be seen in other areas too



    You can use xnormal to bake a map out, just like you can use it to do normal maps, occlusion, cavity etc etc. Xnormal for a while was one of the standard tools game artists used, nowadays there are more good alternatives and its interface looks awful, but it still does a solid job and its free.
    http://www.xnormal.net/Downloads.aspx




    plug your model source in the high def page, lowres in low definition, and in backing options tick the thickness map like in the image. hey presto thickness map.

    Lastly I found I had to tweak my own results manually in photoshop, to get the best result with lux. Like I said you could just paint it yourself, it would be pretty simple(unlike handpainting an occlusion or god forbid a normalmap) but xnormal does give you an automated workflow.
     
    no00ob, Alverik and neoshaman like this.
  28. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    Hi

    Questions about specular and transmission in Lux Plus (but I'm sure that question about specular goes to both Lux and regular Unity standard shader)

    We've replace our vegetation shaders to Lux Plus Deferred Translucent shaders and now at evening and morning times we have weird lighting on it (also issue quite noticeable in shadow area):

    Transmission on (in shadow area):
    upload_2017-7-27_13-4-0.png

    Transmission off:
    upload_2017-7-27_13-6-3.png

    It looks like transmission applied not only on regular lights but also on ambient light

    Second question about specular (Unity Standard shader has same issue):

    Specular on:
    upload_2017-7-27_13-15-0.png

    Specular off:
    upload_2017-7-27_13-13-59.png

    You can notice that specular "eats up" all colors. All our textures and materials are from quixel megascans and they do look and work great in all conditions except ones with low angle of sun
     

    Attached Files:

  29. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    One more issue with specular:
    upload_2017-7-27_13-18-57.png

    You can notice stripes, but in shader I'm doing smooth sine based transition from specular to no specular (0..1) and instead of having smooth looking specular waves I'm having those hard edged stripes

    Thanks for help in advance! :)
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    specular = 0 is defined as being handled as true lambert lighting.
    so you have to keep your spec values > 0 otherwise you get those hard edges.
    spec = lerp(1.0f/255.0f, 1.0f, sinspecvalue);
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    lux lets you specify the shadow strength on translucent materials. i guess it is set to < 1, so the shadows do not block translucent lighting.
     
  32. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    got it

    is there a way to make this transition smooth? Currently it ruins image
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    no way. you will always have a harsh break when going from pbs lighting to lambert.
     
  34. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    ok, maybe there is a way to decrease amount of "washed out" effect in distance in counter-light conditions (as on screenshot)
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you may try the lux texture preprocessor to reduce specular aliasing and lighting.
     
  36. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    Thanks a lot for your help, by tweaking parameters here and there we achieved way better results!
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you are welcome!
    btw.: your screenshoots look quite interesting. anything else you can show from your project?
     
  38. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    those screenshot are from programmer testbed, we will announce our game in a couple of weeks and I'll share screenshots here )
     
    larsbertram1 likes this.
  39. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    Hi,

    I would like to ask what is the best approach on making the snow look less populated on roads, paths in parks etc. I would like to create similar effect like this:

     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    heavily depends on whether you need snow to be dynamic or not...
    you may have a look at the "custom snow mask" shader.
    you also could use mix mapping and2 different materials from which one does not really accumulate snow.
    you may even use the geomoetry decal material and extra geometry just for the tracks.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    btw. in case you want lux to be continued you will have to make some more noise:
    go to the asset store and write a review – or at least give a rating. right now there are a lot of trolls putting it down :(
     
  42. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    5* and review for Plus version
     
    larsbertram1 and hopeful like this.
  43. Fured

    Fured

    Joined:
    Jul 3, 2014
    Posts:
    3
    Hello everyone. Hello creator . I have a question (Of course ), Does the Lux skin shader have the ability to add a map to control the alpha cutout of an object? If not, is this something you can add to the shader? Or even tell me where I should look at for that.

    I made some research about it found something called "combine" in ShaderLab , but I am big noob shaderwise..
    I tried the combine thing , didn't really work with Lux. Your toughs ? Thanks a lot.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you do not need an additional map.
    [NoScaleOffset] _SpecTex ("Translucency (G) AO (A)", 2D) = "gray" {}
    _SpecTex has 2 free channels: red and blue. so you could dd alpha to one of those.
    then in the surface function find this:
    fixed4 combinedMap = tex2D(_SpecTex, IN.uv_MainTex);
    that is very the according texture is sampled.
    add:
    clip(combinedMap.b - 0.5);
    right after that line ( 0.5 is the theshold. you may raise or lower this value).

    in order to make shadow work properly you will have to add a custom shadow pass.
    do so by changing:
    #pragma surface surf LuxSkinSpecular fullforwardshadows vertex:vert
    to:
    #pragma surface surf LuxSkinSpecular fullforwardshadows vertex:vert addshadow

    making e.g. ssao work properly in forward is a bit more cumbersome. so i will leave this out here.
     
    Last edited: Aug 22, 2017
    Fured likes this.
  45. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Hey larsbertram1, I work with Fured, this is the current shader we are using. Is there a newer version we should be using that has a spec channel? We want to put another black and white map in to control areas that are transparent and opaic upload_2017-8-21_15-47-2.png
     
  46. Fured

    Fured

    Joined:
    Jul 3, 2014
    Posts:
    3
    Thanks a lot for you fast response , that actually helped us a lot. I managed to keep the translucency channel and add another for our cutout. Thanks again.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the variable name is "_SpecTex" – but it is called "Translucency (G) AO (A)" in the inspector.
    btw. i corrected my code above:
    clip(combinedMap.b - 0.5);
    i added ".b" – which would make the shader take transparency from the blue channel.
    clip(combinedMap - 0.5);
    would always take the red channel.
     
    Fured likes this.
  48. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    as I promised earlier, here's our game:
    https://www.thislandmyland.com/
     
    Vondox, elias_t, thelebaron and 3 others like this.
  49. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Wow beautiful project! Good use of Lux :). Definitely following
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    That looks insane!