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 'Works In Progress - Archive' started by larsbertram1, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. larsbertram1

    larsbertram1

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

    the advanced foliage shaders have not been updated to support lux yet.
    but i am working on it.

    lars
     
  2. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Great to know, thanx!
     
  3. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    Hi amazing work on these shaders they look great, I have only one question though. The shaders are giving me different results in the editor then in the actuall game build, any idea what i might be doeing wrong?
     
  4. larsbertram1

    larsbertram1

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

    do you use deferred lighting?
    if so it might be caused by the fact that Lux's internal prepass lighting shader doe not get exported (although it is placed in a folder called "resources").
    so you could try to manually add the shader:
    project settings -> graphics -> always included shaders.
    here add the "Lux Internal-PrePassLighting" shader.

    if you use forward lighting there should not be any difference at all.

    please let me know if your problem is fixed.

    lars
     
  5. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    Unfortunatly that didn't fix the problem, here is an example of what happens when I build the game. $example.png This is with all image effects disabled using just a standard camera, just to be sure. Forgot to mention this in the previous post but it does seem to work it's just that the reflectivity and glossiness seem to be toned down.

    And yes I'm using deferred rendering.

    Edit: Works fine under forward rendering
     
    Last edited: Apr 1, 2014
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
     
  7. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
     
  9. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    Using unity 4.3.3f1, could maybe try to update to 4.3.4. But trying to keep the upgrading to a minimum as 4.3 already killed oclusion culling for our project. I'll report back when I finish some testing.

    Edit: Looks like the setuplux script is automatically telling the lux lighting switch to use CookTorrence instead of BlinnPhong. Adding this
    to void Start of your setup Lux script fixed the problem. So basically forcing him to use BlinnPhong.

    And again thanks for all the help, can't wait to see this project grow i'll try to help in any way possible.
     
    Last edited: Apr 1, 2014
  10. larsbertram1

    larsbertram1

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

    thanks a lot for pointing this out.
    but i guess it should be enough to just "limit the range" of the "#if UNITY_EDITOR" to the lighting mode testing (linear/gamma).
    So the void "UpdateLuxIBLSettings" should look like this:
    Code (csharp):
    1.  
    2. #if UNITY_EDITOR
    3. // LINEAR
    4. if (PlayerSettings.colorSpace == ColorSpace.Linear) {
    5.     isLinear = true;
    6. }
    7. // GAMMA
    8. else {
    9.     isLinear = false;
    10. }
    11. #endif
    12. if (LuxLighting == LuxLightingModels.CookTorrence) {   
    13.     Shader.EnableKeyword("LUX_LIGHTING_CT");
    14.     Shader.DisableKeyword("LUX_LIGHTING_BP");
    15. }
    16. else {
    17.     Shader.DisableKeyword("LUX_LIGHTING_CT");
    18.     Shader.EnableKeyword("LUX_LIGHTING_BP");
    19. }
    20.  
    Well, you could write a script to blend cube maps (in order to achieve dynamic time of day lighting), you could write a script that would make dynamic objects automatically pick up the nearest cube map or you could write a script that would "rotate" the cube maps: there are a lot of tasks that would help lux being more flexible i guess ;-)

    lars
     
  11. larsbertram1

    larsbertram1

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

    it took quite a while and i am a bit excited but now lux is available at the asset store:
    https://www.assetstore.unity3d.com/#/content/16000

    So please download and rate! it.
    Make it visible to the community so it will get much more feedback and attention.

    Lars
     
  12. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    hi lars,

    great plugin i'm having problem when i bake a probe it's throwing me this errors

    $errors.png
     
  13. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    Might this be what you're looking for? Simple skybox blend shader.

    Code (csharp):
    1. Shader "RenderFX/Skybox Blended" {
    2. Properties {
    3.     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
    4.     _Blend ("Blend", Range(0.0,1.0)) = 0.5
    5.     _FrontTex ("Front (+Z)", 2D) = "white" {}
    6.     _BackTex ("Back (-Z)", 2D) = "white" {}
    7.     _LeftTex ("Left (+X)", 2D) = "white" {}
    8.     _RightTex ("Right (-X)", 2D) = "white" {}
    9.     _UpTex ("Up (+Y)", 2D) = "white" {}
    10.     _DownTex ("Down (-Y)", 2D) = "white" {}
    11.     _FrontTex2("2 Front (+Z)", 2D) = "white" {}
    12.     _BackTex2("2 Back (-Z)", 2D) = "white" {}
    13.     _LeftTex2("2 Left (+X)", 2D) = "white" {}
    14.     _RightTex2("2 Right (-X)", 2D) = "white" {}
    15.     _UpTex2("2 Up (+Y)", 2D) = "white" {}
    16.     _DownTex2("2 Down (-Y)", 2D) = "white" {}
    17. }
    18.  
    19. SubShader {
    20.     Tags { "Queue" = "Background" }
    21.     Cull Off
    22.     Fog { Mode Off }
    23.     Lighting Off        
    24.     Color [_Tint]
    25.     Pass {
    26.         SetTexture [_FrontTex] { combine texture }
    27.         SetTexture [_FrontTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    28.         SetTexture [_FrontTex2] { combine previous +- primary, previous * primary }
    29.     }
    30.     Pass {
    31.         SetTexture [_BackTex] { combine texture }
    32.         SetTexture [_BackTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    33.         SetTexture [_BackTex2] { combine previous +- primary, previous * primary }
    34.     }
    35.     Pass {
    36.         SetTexture [_LeftTex] { combine texture }
    37.         SetTexture [_LeftTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    38.         SetTexture [_LeftTex2] { combine previous +- primary, previous * primary }
    39.     }
    40.     Pass {
    41.         SetTexture [_RightTex] { combine texture }
    42.         SetTexture [_RightTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    43.         SetTexture [_RightTex2] { combine previous +- primary, previous * primary }
    44.     }
    45.     Pass {
    46.         SetTexture [_UpTex] { combine texture }
    47.         SetTexture [_UpTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    48.         SetTexture [_UpTex2] { combine previous +- primary, previous * primary }
    49.     }
    50.     Pass {
    51.         SetTexture [_DownTex] { combine texture }
    52.         SetTexture [_DownTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
    53.         SetTexture [_DownTex2] { combine previous +- primary, previous * primary }
    54.     }
    55. }
    56.  
    57. Fallback "RenderFX/Skybox", 1
    58. }
     
  14. larsbertram1

    larsbertram1

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

    the script tries to create a cubemap in a folder that is named like your scene.
    so you will have to save the scene first.
    that should solve your problem.

    lars
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there and thanks for posting the shader – but that is not what i/you/we are looking for:
    skyboxes should be blended by script:
    lets say you want to create a day night cycle. so you have baked 4 x 2 cube maps (irradiance and radiance): night, morning, high noon, late afternoon.
    now the script should take 2 of those, blend them together based on the given time and then pass the blended cubemaps to the shaders.
    doing it within the shaders would be incredible expensive as blending would have to be done per pixel!

    lars
     
  16. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    Thanks for the quick response, that solved it, people like you who creates things like this makes unity a beast :D
     
  17. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Is there a step by step tutorial / checklist what have to been done to get all the stuff working ?
     
  18. ludiares

    ludiares

    Joined:
    Jul 14, 2011
    Posts:
    242
    The lux documentation and _LuxCubemap.txt (If I'm not wrong with the name), both on github and the asset store package, explain everything you need to do, except for setting the color space to linear under Player Settings
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i hope ludiares is right.
    or do you miss something special?

    lars
     
  20. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    oh, I thought I recognized this over from Allegorithmics' site... nice, would be so great to get seemless workflow between SD and Unity with this. Looking forward to trying it.
     
  21. ArvidBackman

    ArvidBackman

    Joined:
    Aug 8, 2013
    Posts:
    4
    I am getting weird errors when I'm trying to build a project which includes Lux..
    It's giving me the error:
    $LuxProblem.png
    When I am trying to fix that it just gives me other problems, which appears to be related to the #if UNITY_EDITOR macro

    Is there a way to fix this?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there you can grab the latest version from the repo.
    that should work.
    https://github.com/larsbertram69/Lux

    lars
     
  23. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Ahoy! You said you wanted some pictures and i was genuinely grateful for the translucency rundown so i set about making my for proper go at pbr, like, properly, by grabbing a decent model off daz, heavily reworking the maps and the model and actually getting a full understanding of how this stuff ticks. I'm getting the specular vs gloss/roughness relationship down, there's probs loads i'm missing out on but heres what i got going out of your translucency shader, eyes, and bumped specular for the rest i think - actually i used a parallax version for the armband cause why not eh!

    $Toady1.jpg

    Nothing special I guess for the pbr old timers, but my first step into a lovely looking sea of graphics fun things, and I do believe Lux is a very sound and valid framework to get stuck in with, lars responses are excellent and informative and sometimes result in really interesting new shaders being produced

    I have feature requests but they all refer to features or oncoming features from, well, you know who. Next step is find a home for mr toad, so that will be a great opportunity to create a very realistic home environment. So thats learning environment, but one that would require multiple arranged box sections to keep the box projections' reflections looking good throughout - I cannot see that being too hard really, to do a simple script to switch in appropriate envmaps based on the trigger your box section is based on. The reason i'm stressing such complex-ish box sections (and piles of hdrs) is because i want to get screen space reflection (re. candela) working dandy with the scene along with the box projected cubemaps

    Then i'm going to work with lux as much as i can - i am doing all this as workflow testing and seeing what gets what dones fast as i'm entering a competition which should be a good laugh, and ideally i'd like to use Lux with it rather than the alternatives i bought and own
     
    Last edited: Apr 18, 2014
  24. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    This is the most amazing asset I have seen for Unity! I am so grateful for all the work you have done Lars. Thank you.
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    thanks, but please come over to the new offical thread:
    http://forum.unity3d.com/threads/235027

    lars
     
  26. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    I am absolutely loving this shader tool, but I'm having the following problem when I try to export to a webplayer...

    Assets/Lux/Lux Scripts/Lux Cubemapper/Scripts/LuxCubeProcessor.cs(1038,8): error CS8025: Parsing error

    its just the #endif...

    Any ideas?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    please make sure you get the latest version from the github repo!

    lars
     
  28. generico

    generico

    Joined:
    Sep 17, 2014
    Posts:
    10
    Hi there, i was trying to play with your awesome asset.

    There is any "best practice" or "how to's for dummy" ??? i didn't see any how to, just a theory. I recently saw
    but i'm looking something more ... easy to start :D

    Anyways great product :D awesome product :D
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
  30. generico

    generico

    Joined:
    Sep 17, 2014
    Posts:
    10
    i already try to look into google and read theory of PBR.

    But i mean how to use in a simple scene in Unity.

    "create empty object" assign setup script.
    put a lux difusse shader in a objet.
    next create a empty object and assign lux environment..​

    i'm looking something like that, because i think that i'm doing something wrong in my scene :(
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there,
    that is pretty much everything you have to do ;-).
    one might add:
    - assign a proper global diffuse ambient probe to the set up script.
    - assign a proper global specular ambient probe to the set up script.
    - switch to linear color mode (if you have pro)
    - add tone mapping effect to the camera (if you have pro)
    lars
     
  32. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi Lars,

    Im a huge fan of all of your work (Lux, vegetation shaders, terrain...).
    Im working in some AAA PBL models to sell at the UnityStore, with LODs and all the original textures + compressed versions for optimal drawcalls and full customization. Im testing my models in Skyshop, creating custom shaders in Shader Forge and now working on Lux to give the users all the options without having to modify any Spec/Gloss/Rough/Metalnees textures.
    In Skyshop and Shaderforge there isnt much diference in Specular and Gloss values, but i have more work to do to get the same quality in Lux shaders.

    And here is my proposal: One of the things I noticed in quality impact is the full albedo specular support. There is any chance that u could do a modification of the "metalness" shader to work as :

    -(RGB)Diffuse(A)Metalness
    -(RGB)Specular(A)Roughness
    -Normal map.

    I normaly multiply AO in photoshop. Transparency 60% of cases is not used. Im still working to get the same Spec and Rought Values than Skyshop/ShaderForge, but for sure i will give support to this amazing project.

    Thank you very much for taking your time reading my ideas.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there,
    sound interesting and i guess it will sell like sliced bread if unity 5 is out.

    as far as changing the metalness shader: no, never! as that would simply break any regular metalness workflow and the whole idea behind it!
    • your textur layout would not allow cut out or transparent shaders without using an extra texture.
    • but more important: (A) metallness replaces (RGB)specular to free some texture channels (e.g. for ao). this is especially important in case you have a fully deferred rendering pipeline (like jove 2.0 or unreal engine 4) as all those values do not only have to be stored in textures (taking bandwidth while uploading those to the gpu) but they also have to be written to different g-buffers while rendering (taking a huuuuuge amount of bandwidth).
    so just before going into details: have you also checked lux’s regular specular reflectivity shaders?
    that should more or less work like skyshop...

    how doess metalness work?
    "When using a metalness map, insulative surfaces - pixels set to 0.0 (black) in the metalness map – are assigned a fixed reflectance value (linear: 0.04 sRGB: 0.06) and use the albedo map for the diffuse value. For metallic surfaces – pixels set to 1.0 (white) in the metalness map – the specular color and intensity is taken from the albedo map, and the diffuse value is set to 0 (black) in the shader. Gray values in the metalness map will be treated as partially metallic and will pull the reflectivity from the albedo and darken the diffuse proportionally to that value (partially metallic materials are uncommon)."
    taken from: http://www.marmoset.co/toolbag/learn/pbr-practice

    specular reflectivity(sr) vs. metalness(m)
    as you might have noticed textures for both workflows look a bit different:
    specular reflectivity
    metals are black in the albedo (as they do not have any diffuse reflection) but have a (colored) rgb value above 0.5 in the specular color map.
    dielectrics (or insulatives) have their "regular color" in the albedo and a pretty low gray tone in the specular color map (around 0.03).
    metalness
    dielectrics store their diffuse reflection color in the albedo, metals store their specular reflectivity in the albedo map.
    the metalness mask is used to separate between those.

    so what
    if you do not want to generate 2 different texture sets you do not have to support the metalness workflow in lux.
    most shaders in lux use the specular reflectivity workflow anyway.
    otherwise you could probably easily generate 2 different albedo maps if you have a metalness mask:
    use it to either set the albedo to black (sr) or the specular color (m).

    specular reflectivity is used by:
    unity 5 (at least in the current beta), skyshop, lux
    metalness is used by:
    alloy, jove 2.0, unreal engine

    ambient occlusion
    never bake any ao to the albedo! that would break one of the basic laws of pbr.
    in fact the albedo map should not contain any lighting information at all. so usually it looks pretty flat.

    you may have a look at the following video which shows pbr textures in "remember me":


    if you have any further questions please let me know.

    lars
     
  34. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    That's why i think developers should now offered on the Store models with textures in PSD (including an Albedo layer and an AO layer ). Of course, a flattened version of the texture would also be provided.

    Because, it is VERY difficult to 'PB-Resing' a flattened texture.
     
    Jaqal and Reanimate_L like this.
  35. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Thanks to explain me the metalness workflow! Really, I didnt noticed that the metalness is getting the diffuse from the albedo map. I have to tweak more the textures then, to get more variations. Here are a comparison example of my work:

    I cant build a web version from Lux cause i get this error: Assets/Lux/Lux Scripts/Lux Cubemapper/Scripts/LuxCubeProcessor.cs(1040,8): error CS8025: Parsing error (unity 4.5.2f1)
    But this is how it looks for now:
    Lux1.jpg

    And here it is with a custom PBL shader made in Shader Forge (this is a web player version):

    https://dl.dropboxusercontent.com/u/72551597/Builds/Builds.html

    How are the first impresions? This is a part of a complete old wagon model. In comparison Lux shader looks more realistic, but Shader Forge custom is more impressive. Lux is using Metalness shader and both are in Deferred.

    P.D: The texture seams in the lux version are normal, they are still not tweaked. The model its not 8k tris ofc, its 1k. Total 4k full wagon.
     
    Last edited: Sep 20, 2014
  36. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi ZJP,

    My plans are to include all original textures separately plus diferent folders with diferent tweaked textures configured to work in Shader Forge, Skyshop and Lux.
    The original textures will be: Albedo, Specular, Gloss/roughtness, Metalness, Emissive, AO and Normal.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi there,
    i just noticed that this is the old thread – please come to:
    http://forum.unity3d.com/threads/lux-an-open-source-physically-based-shading-framework.235027/
    there you will find much more information, great add ons and a lot of tips.
    so here are just some short answers:
    • the webplayer using the shader forge shader totally crashed my computer...
    • I didnt noticed that the metalness is getting the diffuse from the albedo map.
      it gets specular color from the albedo map – not diffuse ;-)
    • I cant build a web version from Lux
      Please make sure you get the leatest version from the github repository: then all errors should be gone.
    and please come over to the new thread... there your audience will be much ... larger(?).

    lars
     
Thread Status:
Not open for further replies.