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
    Lux has been updated for Unity 5 — so please start form page 23 in case you are using untiy 5.

    If you are looking for a Hotfix for Unity 5.6. please go to page 28.


    Hi there,

    welcome to Lux – an open source physically based shader framework.

    Why physically based Shading?
    First of all physically based shading will give you much more convincing results than traditional lambert or blinnphong shading: No more fights with washed out specular highlights or boring dark areas as everything is shiny.
    Second: psb will help you to get much more constant and predictable results under varying lighting conditions: Author once, use everywhere!

    Lux and Unity 5
    Unity 5 is right around the corner bringing built in psb shaders. So why should you use Lux?
    Hardly anybody really knows about the capabilities of the upcoming built in shaders and hardly anybody knows when they will be available.
    So Lux just enables you to get familiar with pbs today and author your materials properly as both use the same approach which is a specular reflectivity workflow. For this reason switching to Unity 5’s native shaders should just be a simple step. And who knows: May be Lux even competes with the new shaders…

    Why open source?
    There are already some commercial solutions out there available at the asset store, but none of those is free, some even break other shaders. So it might be rather difficult for the community to develop and improve unity’s rendering capabilities. But that is the whole idea behind this framework.


    Test the webplayer
    https://googledrive.com/host/0B7wuYyJnwF9ddHY5Ul9pbk9RZmM/lux01_standarddemo.html

    Read the old development thread

    http://forum.unity3d.com/threads/221985-Lux-%96-an-open-source-physically-based-shading-framework

    Download Lux form the asset store

    https://www.assetstore.unity3d.com/#/content/16000

    Get the latest updates directly from the GitHub Repo

    https://github.com/larsbertram69/Lux


    Framework Features
    · Normalized BlinnPhong or CookTorrance lighting
    · Schlick-Smith or GGX Visibility Term
    · Fresnel
    · Image based ambient diffuse and specular lighting
    · Box projected environment probes
    · Forward and deferred lighting
    · Gamma and linear color space
    · HDR and LDR rendering
    · Lightmaps and Lightprobes
    · DX9, DX11 and OpenGL
    · Specular reflectivity or metalness workflow

    Included Base Shaders
    Although it it pretty easy to write your own Lux shaders the package ships with a wide range of basic shaders to just let you get started:
    · Bumped Diffuse
    · Bumped Specular
    · Box Projected Bumped Specular
    · Detail Bumped Specular
    · Alpha Test Bumped Specular
    · Transparent Bumped Specular
    · Self Illum Alpha Test Bumped Specular
    · Parallax Bumped Specular
    · Vertex Blended Bumped Specular
    · Vertex Blended Parallax Bumped Specular
    · Bumped Specular Translucent
    · Dedicated skin, eye and hair shaders
    · Physically based wetness including water accumulation and water flow

    Advanced Terrain Shaders
    Supporting a global color map, global normal map, a detail normal map and advanced blending between the different passes.
    · Terrain first pass
    · Terrain add pass
    · Far Terrain
    · Waving Grass
    · Waving Grass Billboard
    · Vertex Lit

    Advanced Tree Shaders
    Fixing most problems you might run into using linear lighting.
    · Tree Creator Leaves (optimized)
    · Tree Creator Bark (optimized)
    · Tree Billboard

    Editor Features
    Lux lets you capture and convolve ambient probes based on ATI’s Cubemapgen directly within Unity.
    · Capture Probes (Unity Indie & Pro)
    · Convolve diffuse cube maps
    · Convolve mipchained specular cube maps
    Lux also supports cubemaps created with Skyshop or Jove.

    Lars
     
    Last edited: Apr 1, 2017
    konsnos likes this.
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Some images showing the feature.















     
    Last edited: Apr 12, 2014
  3. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Awesome! Congrats on your release and getting it onto the store. So I had 2 more questions.

    1. Do I require a vertex painting plugin from the asset store to use the Lux vertex blend shader.
    2. Mind giving a breakdown of how you achieved that delicious looking water/wet look in your last screenshot? :D

    Tyler
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    1. you can use any (even free) vertex painter from the asset store or your 3d app like maya, modo or blender.
    2. i took one texture from the stones (diffuse, specular color, roughness, normal) "painted" a heightmap and assigned it as 2nd texture to the vertex blend parallax shader. the 1st texture is just a darkened version of the diffuse map and a very smooth (more or less white) roughness texture. no normal map needed as the wet surface it more or less flat. blending is controlled by vertex colors.
    everything else is done by lux.
    it is a bit heavy for a wet shader – but i did not have the time to write a special shader.
    but all you would need is diffuse map, spec map, roughness map, blend map or vertex colors, color which determines how much the wet parts get darkened, a height map and 2 normal maps: one for the dry parts and one for the wet parts. the last one even could be animated: think of raindrops!

    i might have a deeper look into this later.

    lars
     
  5. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Here's a quick Kitbashing of Stealth Scene And Lux Latest version :)


    and Yes...the floor is shiny...it's on purpose :p
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi rea,

    thanks for posting the image – although i liked your the one you sent me better...
    so i am just pasting it here (i hope you do not mind).

    lars


    Lux Box Projected Shader (floor)

     
  7. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Lol...no problem :p
    it's just i did some light rebake that's why it's bit different :D
     
  8. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well done rea! another epic Lux contribution! I will hopefully have an image too sooner or later to showcase...

    For those who have more knowledge than me: does anyone know of any plugins to generate specular maps in Photoshop or GIMP?
     
  9. larsbertram1

    larsbertram1

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

    just a preview on lux box projected capabilities: not as accurate as i would like it them be but that will probably change in future releases.
    and as soon as you add some normal maps to the reflecting surfaces it looks quite convincing i think.

     
    Last edited: Mar 19, 2014
  10. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I have not found one. I use insanebump plugin for gimp. It makes specular maps but all it does is make a grey scale and raise the contrast.

    lars that screenshot is amazing.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks,

    and as far as specular maps are concerned: you won’t find a plugin for that.
    but first of all you have to get the wording clear:
    specular means specular reflectivity – not gloss or roughness nor smoothness.
    and specular reflectivity depends on the material you have. it is just a single color value for a given material like wood or copper.
    there are look up tables available for those.
    so you probably mean gloss or roughness.
    you could use e.g. crazy bump for this although i highly recommend to author or finish your roughness maps manually.
    or use advanced terxturing tools like ddo.

    find out more about a pbs texturing workfow here:
    http://www.marmoset.co/toolbag/learn/pbr-practice

    lars
     
  12. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Wow, you really did fix the billboard trees with HDR linear lighting! I can actually make outdoor HDR scenes now! I'm doing a happy dance in my chair right now. I don't do my happy dance for just anyone, lars. You should feel honored. ;)
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks, i am glad that trees and billboards now work for you.

    lars
     
  14. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Awesome work and thanks for the reply on creating the wet puddles. I'll definitely be using that on the ship my friend has shown you :)

    I do have one question that comes to mind. That being environments with time of day or dynamic weather. How is it possible to use this properly with IBL? Would there have to be some sort of system which blends/automatically changes the cube maps by detecting the current type of weather active?

    One example is that I have created a cubemap of a sunny clear sky and I'd like it to change to storm once the dynamic weather system changes to it. If I recall realtime cubemaps are very expensive to render.

    Cheers!
     
  15. Botanika

    Botanika

    Joined:
    Nov 2, 2013
    Posts:
    60
    Yes there is DDO pluguin for Photoshop, the old version is free, but it does a great job when it comes to spec/gloss maps creation.

    you can get it for free her : http://quixel.se/dDo/dDo_release.exe

    or spend 200$ for the Quixel suite if you want.



    I made this image with reflectance values from DDO, for a friend who use GIMP, you can use it to author your textures :
    https://www.dropbox.com/s/os4ukv0deaxiz4l/full doccument.jpg
     
  16. Botanika

    Botanika

    Joined:
    Nov 2, 2013
    Posts:
    60
    Thank you Larsbertram1 , Cant wait to try this.
     
  17. larsbertram1

    larsbertram1

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

    for those you would like to be up to date i have just created a repo:
    https://github.com/larsbertram69/Lux

    it already contans the box projection shader and the lux cubemapper scripts (next to an updated version of the core)

    lars
     
  18. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,663
    Is it normal that compiling each single shader takes ages? o_O
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Yep...
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    yes due to the fact that each shader has to be compiled multiple times:
    - blinnphong / cooktorrance
    - linear lighting / gamma
    - using spec cube / not using spec cube
    - using diff cube / not using diff cube
    - ao / no ao

    you find those instructions here:

    #pragma multi_compile LUX_LIGHTING_BP LUX_LIGHTING_CT
    #pragma multi_compile LUX_LINEAR LUX_GAMMA
    #pragma multi_compile DIFFCUBE_ON DIFFCUBE_OFF
    #pragma multi_compile SPECCUBE_ON SPECCUBE_OFF
    #pragma multi_compile LUX_AO_OFF LUX_AO_ON

    when using the git you have direct access to the code before import.
    so if you now what you want or need you can just comment those lines and replace them by e.g.:

    #define LUX_LIGHTING_BP // use blinnphong direct lighting
    #define LUX_LINEAR // compile for linear lighting
    #define DIFFCUBE_ON // use diffuse ambient image based lighting
    #define SPECCUBE_ON // use specular ambient image based lighting
    #define LUX_AO_OFF // do not add an extra ambient occlusion texture

    that will speed up compiling time dramatically!

    lars
     
  21. jzela

    jzela

    Joined:
    Mar 2, 2013
    Posts:
    68
    This is awesome stuff, Lars. Great job!
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks!
     
  23. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
  24. larsbertram1

    larsbertram1

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

    today i have had a look at skin shading which is nothing i have ever been into before.
    but i found a good point to start from to add pre-integrated skin shading to Lux.

    the image attached shows lux’s standrd bumped specular and the first version of the pre-integrated skin shader.
    at a first glance you might not really see any difference. i guess the diffuse texture is just too good.
    but if you look closer you will see:
    - bump mapping is smoother using the pre-integrated skin shader.
    - you will notice the smoother lighting (which is wrapped around diffuse or half lambert lighting) and even more important: the subtle color shift at the chin caused by the subsurface scattering.

    But even if you choose the cheaper standard shader i guess it should be possible to create some great looking skin using lux.

    lars

    $lux_skin.jpg
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Lol....i was working on this, but since you already made it so i guess i drop mine since it's not finished yet :p
    awesome work lars
     
  26. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    This stuff is awesome, I want this stuff in UMA! Now!
    Just kidding I already have this stuff in UMA, it required exactly 0 lines of code!

    The Roughness channel makes the bumped specular suitable for everything from clothes to armor. Now to convince everyone else we should create specular maps for all UMA assets, it wont do lux proper justice to show my wip screenshots without proper specular maps.

    Does this pre-integrated skin shader need more inputs than the normal bumped specular one? I guess for most usages people would prefer the bumped specular because it could give them the 1 draw call advantage. But I guess others wont mind that it's 2 draw calls. :)

    If any artist could hook up with me on skype tonight for an hour, I'm sure that's all we need to speed paint some quick specular maps for UMA, so we can get some real wip screenshots. Send me a pm if you're that artist.

    Awesome work Lars!
    Joen Joensen, UnLogick
     
  27. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I could tell right away. The other face looks great but the Skin shader face looks incredible. What texture inputs does it use?
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi joen,
    the pre-integrated skin shader right now uses:
    - Albedo or Diffuse map (rgb)
    - Normal Map
    - SpecRoughnessSSS: Specular color is stored in the red channel (just a simple shade of gray as skin does not color the specular highlight), Roughness is stored in green, Subsurface Scattering (SSS) is stored in blue – and blocks sss at certain areas.

    so thats what the 3 channels look like:

    $lux_skin_tex.jpg

    lars
     
    Last edited: Mar 22, 2014
  29. larsbertram1

    larsbertram1

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

    i am pretty happy about having mentioned that this is the first time i work on a skin shader ;-)
    well, if i had set up the brdf lookup texture correctly translucency would have already be handled by the shader…
    so the sss mask is needed!

    left: lux pre-integrated skin shader — right: lux specular bump




    lars
     
    Last edited: Mar 22, 2014
  30. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Would it make sense to add a little AO to one of the unused channels? In a large scene my shadows rarely look as good as on your close up.
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you are right:
    the shader will sample ao from the alpha channel of the SpecRoughnessSSS = SpecRoughnessSSSAO texture.
    and i hope to get its first version into the repo within the next few hours.

    lars
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
  33. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788


    That was unity + Lux btw....:D



    okay okay...i'll stop.... :p
     
    Last edited: Mar 23, 2014
    florianalexandru05 likes this.
  34. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    This is getting more epic by the second! And thanks for the link to the dDo tool! can this tool do metalness maps too?

    @rea: I can't see your screenies! the images are blank...
     
    Last edited: Mar 23, 2014
  35. larsbertram1

    larsbertram1

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

    today i had a look into eye rendering and found some info in the docs of cryengine.
    so this is what i have come up so far:



    (please do not judge the model or the texturing)

    right now each eye consists of 3 parts:
    - the eyball (rendered using the parallax bumped specular shader in order to give some depth to the iris and cornea).
    - overlay geometry that add the ambient occlusion to the eyeball (using a transparent blend shader with offset to deal with z-issues)
    - the lashes (rendered using a 2 sided transparent shader which could be the same as for the hair)

    lars
     
  36. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    NICE! Proves Cryengine has some things that Unity can take advantage of. And eye rendering can be a complex subject, so well done!
     
  37. Botanika

    Botanika

    Joined:
    Nov 2, 2013
    Posts:
    60


    The values on this chart, seem to work great with Lux, testing few of them, right now.
     
  38. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    weird, it showed up here....
    try this
    http://i.imgur.com/8UPazVl.png
    http://i.imgur.com/JV7SEda.png
     
  39. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    So ... is there anything Lux doesn't do?

    It's getting hard for me to figure out the essential differences between the various image enhancement products that have become available in the last year, from Skyshop to Candela.

    Does any knowledgeable person here feel like giving a summary?
     
  40. Botanika

    Botanika

    Joined:
    Nov 2, 2013
    Posts:
    60
  41. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788

    Uhh...stuff that is not in Lux (yet)
    - Realtime cubemap Convolution
    - Automatic cubemap switch/assign
    - Cubemaps Zone
    And since you include Candela so there's no SSR and SSGI
     
  42. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    What I mean is, on a practical level, when do you want to use this Unity product or that one? That's what I'm not sure I understand.

    It seems that Lux probably does about all an indie developer would want. (Except maybe hair?) I'm not very clear on why someone would want some of the other products in addition to Lux, except maybe in the case of Skyshop, which is moving on to include cubemap blending and rapid GPU-generated cubemaps, I believe (assuming that's what you want).

    Now that Lux has spherical harmonics it is better suited for use with dynamic lighting, and now that it has its own cubemapping it is taking advantage of indirect lighting, which adds a lot of realism ... at least in static situations, or dynamic ones where you can get away with using a pre-generated cubemap to approximate your desired scene lighting. (For example, Quantum Theories sells a Skyshop Skies pack intended to provide indirect lighting for common situations without making your own cubemaps.)

    Is there a situation where you would add Candela to Lux? I suppose it would give you accurate short range reflections without having to generate cubemaps.

    I imagine Lux would be an ideal pairing for UMA, btw.
     
  43. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Oh i'm not sure about that, i guess those were mostly personal taste and people can decide which tools that suit their workflow etc
    and you might want to ask candela about integration with lux
     
    Last edited: Mar 24, 2014
  44. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Sorry rea. i.imgur.com isn't working for me... perhaps a google drive link? I do this when things don't go as they should.

    EDIT: I think my school network is the problem, as squid server often does weird things...

    Anyway, i would prefer a google drive link from you if possible, as GD works at school just fine. Of course, i can give this a try at home and see if, by some amazing law of physics, your images still don't load... :)
     
    Last edited: Mar 24, 2014
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    Hi there,

    i have just added the Lux eye shaders to the repo.

    They might look pretty unspectacular but add a nice parallax distortion to the iris and let you dynamically adjust the pupil’s size.
    Not to mention that there is also an ambient occlusion shader which makes the eyes fit perfectly with the the faces and surrounding geometry.

    Get them here: https://github.com/larsbertram69/Lux

    Lars





     
    Last edited: Mar 25, 2014
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    when do you want to use lux?

    you can claim me not being objective but whenever you think of getting into physically based shading you may consider taking lux because:
    - it offers most features you would get from commercial packages.
    - it is free
    - it is open source and you might expect a lot of other shader driven solutions to built upon lux or at least work with it (like the upcoming rtp 3.1.).
    - it supports a specular reflectivity workflow (like skyshop or jove) and a metallness workflow (like alloy) – so it is up to you to choose the path you prefer.
    - writing shaders it pretty easy as long as you are familiar with writing surface shaders.
    - but if not: lux develops much faster than any other framework and comes with a git to always keep you in sync. which package offers a dedicated eye shader for example? or ships with enhanced terrain and really working tree shaders? not to mention correctly working forward shaders in case your camera is set to deferred lighting...

    those are the reasons why i have decided to develop an open source psb framework. i might be wrong however.
    unity 5 seems to incorporate a lot of lix’s features. so now you have got the possibility to get familiar with psb.

    lars
     
    Last edited: Mar 25, 2014
  47. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Lars, Lux does sound great. I'm in agreement with you on that. I'm trying to figure out what Lux doesn't do, and what other products might logically go with Lux for this or that situation. RTP is a good recommendation.

    And thank you for the eye shader addition! I know some of the UMA guys were interested in being able to adjust pupils. The parallax effect is also nice ... good to have for high-resolution character close-ups.
     
  48. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    RTP uses PBR rendering pipeline that agrees with Lux (we discussed it with Lars). Moreover - installing Lux over RTP gives possibility to get good PBR in deferred, too. The only difference is I treat IBL more "Skyshop" way (esp. fresnel).

    Tom
     
  49. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @rea: Yep, the images loaded at home! Curse you Squid Server... Anyway, nice screenshots! and is that depth of field I see there?
     
  50. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Lars just asked me for a status update on using lux in uma. So here comes.

    The short version is that we don't have all the right specular/roughness channels for the uma slots. (And without those it looks a bit bland, tbh)

    I'm still waiting on one of the graphics guys to have time to sit down with me and do some speed paints of the uma specular maps. The speed paint probably wont be final for a while but I'm positive it will still look awesome.

    One of my personal favorites will be the ability to set a roughness multiplier (as well as pure additive) on a per slot basis, to simulate various cloth materials. Silk vs Cotton, etc. This is already supported by UMA through code, but we need to improve the UI to make this possible without coding. Latest git version have some hacks in our crowd generator that can do the multiplier part. But at this point the ui is becoming so clumsy we need to do a proper inspector for it.

    So in short, it's still in the works but delayed by "lack of time(tm)"