Search Unity

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,900
    yes!
     
  2. TalkieTalkie

    TalkieTalkie

    Joined:
    Jul 5, 2012
    Posts:
    123
    Hi,

    Total noob here (to Github) who wants to us eLUX (with Enviro asset).

    What do I download from Github and install into my project for this to work in Unity? (should I download the whole thing and extract into a specific folder?)


    Thanks.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    download the whole repo as zip.
    then move the files to your project's asset folder.
     
    TalkieTalkie likes this.
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    Hey lars, is lux pro compatible with 5.6? Im getting some shader errors in the skin and hair shaders(Shader error in 'Lux/Human/SkinExtended': unrecognized identifier 'UNITY_SHADOW_COORDS' at line 171 (on d3d11)) not sure if its something on my end or not.
     
  5. denbi

    denbi

    Joined:
    Sep 22, 2012
    Posts:
    3
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    Hotfix for Unity 5.6.

    you will have to update the "hacked" AutoLight.cginc files.
    use one of the packages attached to do so.
     

    Attached Files:

  7. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i am following alttrees and give it a look from time to time - and have already submitted some improvements as far as its shaders are concerned.
    but adding translucent lighting would need diab1o to commit himself to a certain way to handle that.
    you may ask him if he is willing to do so. then we might see.
     
  9. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Already asked him in his topic, he said that as soon as he'll have access to Lux he might try to integrate

    Currently I have my own integration, but it's kinda ugly - I need to change all absolute paths to Lux Translucent Shaders path and copy all shaders there, change lighting model to LuxTranslucentSpecular and then everything works

    Also, while you are here :)
    I'm having troubles with SpeedTree shader integration - copied them to Lux Translucent Shaders folder and changed shader in a way how I did with other Translucent shaders, but now I'm having weird issues - sometimes compiler says about missing 'Shadow', sometimes about duplicate 'surf' declaration. Maybe you have your own integration of SpeedTree?

    Thanks!

    EDIT: I've simplified SpeedTree shader to just one surface shader, but I'm still having this issue (renamed 'surf' to 'surfaceShader' just to check that it doesn't conflict with some internal name/variable):
    Code (csharp):
    1.  
    2. Shader error in 'Nature/SpeedTree': redefinition of 'surfaceShader' at line 43 (on d3d11)
    3.  
    4. Compiling Vertex program with DIRECTIONAL GEOM_TYPE_BRANCH
    5. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP
    6.  
    7.  
    EDIT2: found issue - this lines are causing issue:
    Code (csharp):
    1.  
    2. //#pragma multi_compile __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE
    3.  
     
    Last edited: Apr 15, 2017
  10. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello lars I noticed when i Set object with your lux shader as lightmapo static, and put lightprobes, it gives less globbali illumination effect than normal standar material, Also I wouls to use mixed light to put realtime shadow on baked lightmap surfaces, And on standard material there is realtime shadow on baked static object but if I use Lux shader there isnt realtime shadow on it when I use mixed light and bake lightmap on object with lux shader/ Why is like that? Is Lux supporting lightprobes and global Gi? bAlso how I could heck my actual lux shader version? In unity is there any info about that?
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    lux has been written using unity 5.3.5 and the mixed light mode is new since 5.6. but you should be able to use one of the lux surface shaders. those might support mixed lighting.
    yes.
     
  12. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    I'm using Unity 5.5
    lux surface shaders What do you mean? Which group it is? i cant fint it in Lux Shaders.

    OK thank you I noticed that lux is supporting global gi and light probes, but I see some difference beetween it and standard unity shader Standard shader gives more bounced light than lux shader wit hthe same settings? is it your attention or it shouldnt be like that?
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i am not aware of this...
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    during the last 2 days i had a look at lux and unity 5.6.
    it turned out that the new lighting modes like "mixed mode" need some more love.
    but due to the fact that i have rewritten the lux standard shader to do mostly sampler free texture lookups i managed to keep all features when using e.g. a "distance shadowmask" – at least on dx11 or openglcore on win. openglcore on mac unfortunately complains about "too many texture samplers used"...

    not nice but just a proof of concept: the plane in the foreground uses the lux standard shader, 2 fully pbr texture sets (albedo, spec, smoothnes, normal), mixmapping, pom, snow and full wetness – and renders nicely on dx11 even if you use baked distance shadows.
    on mac however you have to skip some of the detail textures.

    lux_56.PNG

    translucent lighting however is a totally different story and will most likely change a bit to make it work with 5.6.
    so stay tuned.
     
    Alverik likes this.
  15. ChayChay

    ChayChay

    Joined:
    Sep 10, 2014
    Posts:
    12
    I am working on trying to use Lux to cover some roads with snow, only problem is the roads are generated in Unity and the UVs are not laid out. I can generate a secondary UV set for lightmapping that works well but I cannot seem to figure out how to make the snow and wetness show up using the secondary set. Any help would be appreciated. Should I try using a different approach (such as a snow mask) or can I just generate it on the second UV set?
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    if your roads do not have proper uvs how do you texture them?
    but i can see your problem. unfortunately it is not that easy to solve as you would have to edit the "LuxDynamicWeather" cginc and most likely make all snow texcoords being sampled in world space (using a top down projection).
    i may have a look into this but can not guarantee anything.
     
  17. jayimagination

    jayimagination

    Joined:
    Dec 20, 2012
    Posts:
    89
    I'm new to this shader package and I have two verison of unity on my computer 5.4 and 5.6. I have no issues in 5.4. The package works great but in 5.6 and even after using the above scripts. Some of the shaders still seem not to work in 5.6. One in particular the skins shaders.

    When I put the skin shader on the model, the model's material become purple. This is the console error that I get:


    Shader error in 'Lux/Human/Skin': unrecognized identifier 'UNITY_SHADOW_COORDS' at line 166 (on d3d11)
    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP

    I have no idea what's going on. Wondering if anyone could help?

    Thanks
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    Alverik and ekergraphics like this.
  19. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    That's amazing! I got really confused when the Asset Store page said that the latest version was from January this year, while a review said to get the latest from Github, meanwhile the Github version seems 3 years old? Either way, seems we can all look forward to a dedicated 5.6 version now, which will be really nice.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    world mapped snow is coming!
    it should give you pretty seamless transitions between adjacent objects (as far as snow is concerned).
    and works pretty well even on pom extruded surfaces which was the most difficult part as the shader has to transform the extrusion from tangent to world space.

    snow.png

    snow details.png
     
    Alverik, ChayChay and Baldinoboy like this.
  21. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi~A quick question: does LUX support unity terrain ? can I use it as a custom terrain shader for unity's terrain?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    lux comes with an example terrain shader that supports dynamic water and snow accumulation.
     
    Alverik likes this.
  23. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Thanks, and does Lux have any height blend or uv mix features for the terrain?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    nope. these feature are only provided by the color map ultra shader, rtp or megasplat.
     
  25. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    ah, ok, I checked the other terrain shader works, those doesn't seem to have the dynamic weather feature.
    still, thank you for the replies! :)
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i just added another feature to the upcoming update: specular anti aliasing.
    left: enabled. right: disabled.
    specualr_antialiasing.png
     
    Alverik and Baldinoboy like this.
  27. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Nice! That will help with artifacts on shiny surfaces that screw with bloom.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i haven't tested it with bloom yet – but it stabilizes the final image a lot even if you do not use any image effects at all.
    btw: how is the tropical forest package update coming along?
     
  29. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That is awesome. This is going to be the 5.6 release? This and world mapped snow will be an amazing update!

    Have not been able to work on it for a couple weeks but should be able to get a few things that have be haunting me done this weekend. Re-worked the palms some so they look and bend much nicer. Will hopefully be able to showoff the new banana and young palms by next week.
     
    Alverik likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    Lux 2.02 for Unity 5.6. has been published on github
    https://github.com/larsbertram69/Lux-2.02-Personal

    Improvements
    • Support for Unity 5.6. added.
    • Support for Mixed Mode Lighting and baked far shadows added.
    • Lux now lets you mix baked and real time shadows. However – as this feature might involve a lot of texture lookups – complex shaders using dynamic snow, water and e.g. mix mapping might break on platforms which do not support sampler free texture lookups (as openglcore on mac!?) when using forward rendering. dx11 should have no problems though. Adding support for mixed mode lighting meant to rework the way "shadow strength" for point and spot lights is handled as far as translucent lighting is concerned. It is a bit hacky now but still should you give nice results.
    • Globally mapped snow added which now lets you add structures like roads covered by snow without snow following the road's geometry. So roads simply blend much nicer with the surroundings.
    • Rain ripples are calculated off screen, so we can have a much higher density and better texture filtering. They also are placed much more accurately now when it comes to parallax occlusion mapping.
    • Parallax mapping slightly improved: It now does 2 lookups and should show less pan caking artifacts. It has become a bit more expensive though.
    • Parallax Occlusion Mapping slightly improved:
      • UVRatio parameter added so now you can use none squared textures. Geometry however should still be scaled evenly along all three axes.
      • Final secant search added which smoothes the overall result.
      • You may choose between tex2Dgrad (more accurate but slower) and tex2Dlod (faster but less accurate) by editing the "Lux Config.cginc" file.
    • Anisotropic lighting improved which now gives you better fitting specular highlights.
    • Specular anti aliasing added for deferred shaders.

    Changes

    Parallax Mapping and POM:

    • UV Ratio added which lets you use POM even with none squared textures.
    • Scale added to let you use World Space mapped snow.
    • Lux Config.cginc lets you choose between tex2Dgrad (default – smoother but more expensive) and tex2Dlod (faster)
    • Deprecated: Parallax Tiling: Renamed to "Mask Tiling": If set to >1 or < 1 the shader will do an extra texture lookup to sample the blend mask. This gives you much more flexibility – but of course costs something...
    • When using Lux's parallax function in custom surface shaders you should to declare: "#define _PARALLAXMAP" – otherwise it might not work properly.
    Snow:
    • Snow might be sampled in world space. ALWAYS check UV Ratio and Size when using POM and world mapped snow.
    • Snow color changed to HDR.
    Rain:
    • Ripples are now calculated off screen and sampled from a generated render texture which allows us to add much more density (x2).
    • Ripples get properly distorted by POM.
    Specular anti aliasing:
    • New lighting feature added to the deferred shading pipeline. You may deactivate specular anti aliasing by editing the "Lux Config.cginc" file.

    Custom surface shaders:

    Most important:
    Due to the vast amount of internal textures Unity 5.6 uses (Light Probe Proxy Volumes, baked shadow maps, ...) i changed all surface shaders using mix mapping to use sampler free texture lookups which – at least on dx 11 – allows you to use more than 16 textures. So please have a look at the provided exmple shaders to find out how to modify your shader code like the "Standard FullFeatures" shader.

    struct Input:
    • "float3 worldPos" added
    • "float2 lux_DistanceScale" added
    • "float4 lux_worldPosDistance" removed
    Vertex Shader:
    • o.lux_DistanceScale.x = distance(_WorldSpaceCameraPos, worldPosition);
      o.lux_DistanceScale.y = length( mul(unity_ObjectToWorld, float4(1.0, 0.0, 0.0, 0.0)) );

      added
    LUX_SETUP:
    This macro now needs 8 instead of 7 inputs.
    • Deprecated: "IN.lux_worldPosDistance"
    • Added: "IN.lux_DistanceScale.x" and "IN.lux_DistanceScale.y"
    LUX_DIFFUSESCATTERING_METALLIC(o.Albedo, o.Normal, IN.viewDir, o.Metallic, lux):
    • now needs 4 inputs: you have to add the "lux" struct as last parameter.
    When using the lux parallax function in custom surface shaders you should declare: "#define _PARALLAXMAP" – otherwise it might not work properly.


    Known Issues
    • Mixed mode: baked shadows and directional cookie light are broken – even in standard shader.
      Bug reported (case 905727).
    • Mixed mode: We may run out of samplers on certain platforms.
    • By default the Lux standard shader does not support light probe proxy volumes (by hacked Unity.cginc).
     
  31. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Awesome! Thanks for the work on this Lars! Can not wait to test it out. Will the Asset Store version be updated with the same?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    yes, when i have collected some feedback and maybe wiped out some bugs :)
     
    Baldinoboy likes this.
  33. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    If I only want to use skin shader, after adding the component "Lux Setup.cs", will it affect my scene lighting and gameobjects other than face?
     
  34. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    I was thinking, has anyone used Lux in VR? Anyone knows if it's performant enough for it? (I mean, mostly Vive and Rift, but maybe google VR, though that one's a long shot?).
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    no, only lux shaders will be affected by the "Lux Setup" script.
     
  36. ywj7931

    ywj7931

    Joined:
    Jun 24, 2015
    Posts:
    41
    Thanks for replying, is Lux 2.02 compatible with 5.4? or only with 5.6?
     
  37. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Hi

    We do have rather weird issue with specular and transmission in our game
    It looks like on double sided polygons lighting is calculated on both sides of polygon identically (both sides are lit, but backface which doesn't "look" to sun is lit without normal mapping, just flat lit)
    We've had this issue with Unity shaders too, but we found solution that setting Specular in Specular Pipeline to 0 fixes the issue

    Now we've switch to Lux and everything worked fine until we've turned Specular on (or Skin/Translucency)

    We use Skin/Translucent shader on our foliage and it gives us pretty bad results due to this issue
    Is there a way to take face side (front/back, not by normal but by VFACE) in lighting calculations?

    Image of the issue:
    upload_2017-5-25_8-8-47.png

    PS: as soon as I disable Specular or Translucency everything works fine and back facing polygons are looking fine

    Thanks and sorry for a bit messy description
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it is 5.6. only right now. you would have to merge 2.02 and 2.01 manually to make 2.02 work in 5.4. properly i guess.
    you may try to:
    - get 2.02 into a new project.
    - then replace all AutoLight.cginc files with those from version 2.01.
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i tested single sided geometry using the "Lux Translucent (Specular Setup)" shader which works fine.

    as you can see there are no specular reflections on backfaces:

    backfaces.png

    i have just added a custom translucent shader example which supports single sided geometry.
    you can grab it from github:
    https://github.com/larsbertram69/Lux-2.02-Personal
    it is located in the "Lux custom Translucent Shaders" folder.
     
  40. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    We're using Lux Plus and deferred pipeline, I haven't tested it on non-deferred rendering, but on deferred we can't achieve results shown on screenshot. Also, we're flipping normal for VFACE

    PS: Is update coming to Asset Store for Plus version?
     
    Last edited: May 25, 2017
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i see. so i just slammed the new shader mentioned above into lux plus and it simply worked (unity 5.4.)

    deferred translucent lighting on single sided geometry. the upper plane shows ambient reflections – but no direct specular ones.

    backfaces_plus.png


    yes, but that might take some more time, sorry.
     
  42. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    This may have been mentioned before, but I notice that fog color still affects the skin shader (objects turn into the color of the fog), is there a way to solve that?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    well, it should pick up fog as it is a forward shader (personal version only).
    if you do not want any fog simply disable it "fog" globally in the lighting tab or add "nofog" to the first #pragma of the skin shader – although i do not know what this should be good for...
     
  44. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    That's how Translucent DoubleSided and Standard Double Sided looks on my side:
    upload_2017-5-25_15-20-8.png
    (left - translucent shader from GitHub, right - regular double sided shader)

    I've added red point light to show that no light transmission happens

    PS: just in case - we've set all shaders in Graphics properly and Skin shader work as intended
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    very strange... so this is lux plus in unity version ???
     
  46. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Lux plus from asset store, unity3d 5.6.1
    Weird thing that Skin works fine, but Transmission works in a weird way - if I add transmission mask it blacks our ambient lighting but doesn't change anything related to the actual lighting (putting point light in front of a plane and looking "through" plane to see it)
     
  47. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    upload_2017-5-25_15-31-46.png

    Skin shader on the right side and you can definitely see lighting which comes through the plane
     
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i just checked the "standard shader demo scene" which contains a fern using single sided geometry and translucent lighting in unity 5.4.2 on dx11: everything looks as expected and translucency shows up.
    maybe you have forgotten to configure the "lux setup" script? i has a section dedicated to translucent lighting.

    but i will check it in 5.6. as well.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    same in 5.6.: the fern just looks fine.

    deferred_trans1.PNG
     
  50. rsklnkv

    rsklnkv

    Joined:
    Sep 8, 2012
    Posts:
    62
    Triple-facepalm-combo. My fault. It was LuxSetup.cs

    Thanks!
     
    Last edited: May 25, 2017