Search Unity

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,900
    hi rea,

    thanks for posting the update!

    grass wil be updated in the next version: openGL will use an optimized version while dx9 and dx11 will have to go the long way and calculate the worldnormal…

    fog, terrain and forward in dx9 / dx11: it seems to be a known problem on complex terrain shaders. because – if i remember correctly – tom had the same problem with his rtp package. so i am going to ask him.
    another possibility might be to simply drop the additional detail normal map in forward dx9 / dx11.

    lars
     
  2. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    You might want to change the diffuse and specular inputs to their proper naming conventions, albedo and reflectance.

    So will there ever be support for a metallic workflow? It is much faster then reflectance.
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @rea: now that is unusual... The red cube has a very obvious difference!
     
  4. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    So I made a new project from scratch and imported Lux. I'm not seeing any of the materials properly everything is coming up as black. Any ideas?
    $yc5X4Lv.jpg
     
  5. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Oh that caused by dual forward as i used dual lightmapping...
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi tynew,

    at the first glance it looks as if the diffuse and specular ambient lighting is missing.
    the "black" spheres and cubes usually should show some metal materials so their diffuse color is set to black.
    color would come from specular reflections.

    but i can also notice that the specular highlights do not conserve energy nor do they show up as i would expect them (sharpness, size, color).

    it is rather strange: the shaders seem to not use the Lux lighting functions but just the built in ones.
    but they are not the built in shaders as they do not render any ambient lighting: neither from the ambient cubemaps like they should if they were lux shaders nor from the overall ambient lighting settings (like you have on the first person controller).

    so what is going on here? i don’t know.

    please manually recompile the "Lux Bumped Specular" shader (right mouse button click --> reimport) and see if anything changes.
    you might have to restart unity as well.

    lars


    $no_lux.jpg
     
    Last edited: Mar 2, 2014
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    naming… that is a big issue.
    having a look at sebastien lagarde’s original post he calls the inputs as follows:

    Our physically based shading model requires four inputs:

    • Diffuse color RGB (named diffuse albedo or diffuse reflectance or directionnal-hemispherical reflectance)
    • Specular color RGB (named specular albedo or specular reflectance)
    • Normal and gloss monochrome
    so it would be "diffuse albedo" and "specular albedo".
    whereas "diffuse albedo" and "specular reflectance" would make the difference between those more clear.

    what i have called "roughness" he calls "gloss" which might fit better.


    what exactly do you mean by "metallic workflow"?
    lux lets you combine metals and dielectrics in one single material (defined per texel). and personally i would not change this as i suppose most surfaces to have both: metal and dielectric parts.

    lars
     
  8. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @rea: interesting...

    @tynew: that is strange! it worked first pop on my machine! I don't know how to fix this though, other than what lars said, which is a reimport.
     
  9. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Hello lars,

    I've recreated a new project, and reimported Lux. It took a good 30+ minutes to import the package. Is this normal? Unity will keep switching to not responding in task manager on an off.

    Anyway, upon reimporting I now stumble across another problem:

    dx9:
    $gSn2sQv.jpg

    dx11:
    $mkQ4F3U.jpg

    I also tried reinstalling dx9 from June 2010. I'm not sure why it's looking like this, I'm pretty bummed. I am doing a lot of PBR work outside of Unity so I'd really like to get this working.

    My computer specs:
    Intel i5 2500k 3.3ghz
    8GB Ram
    HD6950
    Windows 7 64-bit

    I'll try another re-import.



    A metalness workflow allows the artist to use a texture sheet which sort of "toggles" whether a material on the texture sheet is metal using a white/black 0-1 value. In the workflow it replaces the reflectance map.
    For example for gold in a reflectance workflow you would have the albedo be almost black while the reflectance having that gold value. In a metalness workflow the albedo would contain the gold value and in the metalness map the parts you want gold in the UV would be all white as a value of 1.
    $Cerberus_M.jpg

    You can find more info on that, here, specifically under the physically based texturing tutorial he linked:
    http://www.polycount.com/forum/showthread.php?t=130641

    And a detailed write up here:
    http://artisaverb.info/PBT.html
     
    Last edited: Mar 3, 2014
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi tynew,

    i not going into the metal thing this time – but probably later.

    as far as the import is concerned: 30 min is not that outstanding i have to admit for each shader has to be compile multiple times.
    but once the package is imported you should not reimport all shaders.

    just try to reimport the base shader wich is the "Lux Bumped Specular" shader.
    it will take several minutes.
    please check the console if it throws any errors.

    usually it just should compile fine. and your scene should look definitely different (as most spheres just use this shader).

    lars
     
  11. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Hello,

    So it does seem to sort of be random bug wise. I reimported into a fresh project and recieved the same problem. Then for some reason going back and forth between playing the game tab and back to scene tab that washed out lighting didn't appear anymore it just suddenly stopped. It also seemed to fix itself if i toggled the sunlight off. Although the main problem still stands that materials still do not appear correctly lit.

    $6XhXs8S.jpg

    My game tab scene also goes black if I choose the deferred option like so:

    $4lckU2l.jpg

    Maybe it has something to do with my graphics card I do not know. Other PBR shaders and tools like Marmoset toolbag work perfectly fine on my system.
     
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @tynew: what's your system specs? that could help me help you solve this weird problem. I have it running fine on my system and i only have an Intel HD 3000!
     
  13. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    My computer specs:
    Intel i5 2500k 3.3ghz
    8GB Ram
    HD6950
    Windows 7 64-bit

    Not sure why it wouldn't run on mine!
     
  14. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @tynew : That's weird since energy conservation seems to work in you place except IBL
    hmm, sorry if maybe this is a long shot but can you post a screenshot of your player settings and quality settings?? just curious..

    meanwhile.... i gonna be honest on this, trying to get the same result is little bit hard especially without the same cubemap, and since i'm still trying to understand pbl workflow with lux so i do a lot of tempering with SpecMap...
    but well here you go... My first try
     
  15. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Sure, rea

    May I ask, how did you get Andrew's model working in Unity with a metalness map?
     

    Attached Files:

    Last edited: Mar 3, 2014
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi tynew,

    at least the first image from the scene view looks much better now:
    correct specular color, correct specular highlights.
    all that is missing here is the diffuse and specular image based ambient lighting.

    so please have a look at the setup lux script and find out if the cubemaps are assigned properly.
    next try to raise the exposure values.
    also check the hdr settings (camera, cubemaps). you must not use anti aliasing in forward (quality settings) if you want to use hdr.
    alternatively you can switch your camera to ldr and choose the ldr cube maps and look what happens.

    but there are still 2 shades that do absolutely not show up correctly:
    - Lux Bumped Specular Detail: it is pink, so do yo get any error messages?
    - Lux Illumin AlphaTest Bumped Specular: it is much too bright... have you changed anything here?

    deferred:
    lux overwrites the built in internal prepass lighting shader (unlike skyshop e.g.).
    you will have to restart unity to make it work.

    lars
     
  17. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Thanks for the reply lars, I'm really glad your taking the time to try and figure the problem out with me. It's not working so well for me though!

    So that huge bright white shading glitch happened again in Unity. I found out it was related to having shadows turned on! I had to turn the shadows off in the screenshots below since it was so bad. Maybe this has something to do with why it's not working.

    Here is the errors I recieved:
    $LhmRi1w.jpg

    I also have not tampered with the settings in the Lux setup, but I did do what you recommended and it did not work out at all.
    $Ay0rZoV.jpg

    I'm not sure if this is related, but I launched the Lux terrain demo and looking around the scene/game tab gives me visual artifacts.
    $Tzx3izQ.jpg

    Maybe I should try different graphics drivers? I've never had a problem with artifacts in any video games/software for 2 years now. Even now I launched a few games and they are running fine. I have loaded Lux into 3 new projects from scratch now with default/stock settings and also adjusting what you recommended and I'm still getting the same issue.
     
    Last edited: Mar 3, 2014
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi tynew,

    the error messages are from a or the tree. so not related to any shader.
    lux setup looks fine.
    and the artifacts you get when you open the terrain demo look really crazy.

    so it might be that either the package you have downloaded is corrupt.
    or your unity installation...

    i have just uploaded a minimal package that only contains the 3 base shaders, some textures and materials.
    please set up a new project and import this little package (17,7 mb). as most of the shaders are missing it should import much faster.

    here is the link:
    https://drive.google.com/file/d/0B7wuYyJnwF9dZFlVSEdBdzVIVVU/edit?usp=sharing

    and this is what you should get:

    $Bildschirmfoto 2014-03-03 um 15.46.39.png

    lars
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @tynew wait...what unity version did you use??
    @lars what unity version did you use to create the package???

    @tynew about Andrew's model you can't just use the metalness directly, you need to adapt it to Lux, basically what i did is combining Specular and Metalness map into one and adjusting it to fit Lux Workflow.
    If i'm not wrong, in Lux Metalness is SpecularMap (RGB) and Gloss/Roughness is SpecularMap (Alpha).
    you can also add a color into specular RGB to achieve metallic reflection color
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    4.3.4

    right.
     
  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @lars
    4.3.4..... Now is it possible that maybe he used earlier version of unity that break Lux???
     
    Last edited: Mar 3, 2014
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    version below 4.3 will propably not support the custom material editor.
    lars
     
  23. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Unity 4.2.1f4

    Do you mind showing me what the texture map looks like adjusting it to fit lux workflow?

    Looks like I'll try a fresh download/installation of unity.
    $12312321.jpg
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    ups!
    yes it should a least be unity > 4.3

    lars
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    There you go.....we find the culprit....:p
    @tynew i'll post it tomorrow (or at least 12 hours from now) since i left the file at my office :p

    Let's get some zombies...:p



    Man i really need to continued working on my own stuff, but lux is so fun :p

    @lars Oh and btw i made simple bumpSpec emissive, basically it's just simplified version of your BumpSpecEmissiveCutout, since i don't need cutout effect for the lamps. Do you need me to sending it to you??
     
    Last edited: Mar 3, 2014
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi rea,
    just do so.
    thanks.

    lars
     
  27. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Great success it works now, thanks guys for sticking with me to troubleshoot! :D

    I know both reflectance and metalness workflow but in terms of production for texturing metalness is at least twice as fast. I'm keen to see how rea adjusted the metalness maps to work with Lux.

    Good work with the project lars, I'm very impressed and I'm very excited to start creating art assets with PBR workflow for my game!
     
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hey lars,since i am usually answering peoples questions on this thread, let's have a little change for once! Here is what I am doing with Lux at the moment:
    $Starship_Game.png

    Of course, this is very barebones, but it will mature!

    -FuzzyQuills
     
  29. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    While physically based shading is a great approach, you won't learn anything from seeing it as an answer to a lack of the needed art. The image you posted shows no evidence of any of the assets relevant for pbr, fuzzyquills, and anyone looking at the thread might see it as as somewhat demeaning to lux's capacity as a decent answer for those wanting to use pbr in their creations, some might even consider you slightly trollish. If you get a basic membership to www.gametextures.com you can get textures that will also come with all the required maps needed for shaders like Lux's, when your above image uses none of them. Then you could create entire environments before even approaching the idea of creating such maps yourself. Rea's contribution show's a situation where Lux is relevant

    If you use google you can find several good treatments on physically based shading, including why it is used, what it does and what it requires
     
  30. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @lazygunn: sorry, just though it might be good... :(
     
  31. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well I think you need to know WHY you'd use Lux, and then when you post your work it will be a credit to the project, you'd learn from feedback and Lux may benefit from your contribution. You need to probably start at the beginning, with Unity's shaders, learn about textures and how they are used in materials, from diffuse to normal maps and why many games use this approach, then read about what Lux, Skyshop, Alloy etc. do, that they are simulating realistic surfaces, what the significance of gloss maps is, what 'specular' actually is and the importance of reflections and why everyone likes skyshop's ability to make environment maps (Imagine a cube surrounding the object with the pbr material with the image of the objects surroundings on it, this supplies the reflections - in Skyshop you could often assume this is the sky and the things the sky illuminates reflect it)

    It needn't take you that long and you don't need to read reams of information, but you'd learn a lot with a few objects and textures that have a set of maps that can be used with these shaders (diffuse, normal, specular, gloss generally at least) and then you can play around with the settings and see what is happening. This is why I suggest you get a sub to gametextures.com, lots of nice textures for you to play around with that work nicely for environments as generally its environments where you can use tiling materials and not have to model your own models and texture them, which can be very time consuming if you want to get decent normal/gloss/etc maps

    In addition i suppose, i wasn't even aware the intel 3000 chips had full support of shader model 3, which I thought was needed for these materials
     
  32. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @Lars May i ask why you choose to use Butterfly Effect Normal Map Blending for BumpSpecDetail???
    and why we unable to edit lux setup while in play mode??
    @Tynew Here you go.....
    I separate the rgb and alpha channel since imgur can't accept TGA..
    you might want to pack it again in photoshop

     
    Last edited: Mar 4, 2014
  33. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Hey rea, the images are not displaying in the thread but I was able to view them with an image hover plugin.

    So from what I'm looking at, it looks like you've pretty much adjusted the maps to make a proper reflectance map from the albedo and you combined the metalness map with the roughness?

    It is a bit of work adjusting something like that, it would be much easier to have an additional input being metalness map :D

    Awesome though, thanks for showing me.
     
    Last edited: Mar 4, 2014
  34. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    weird it's showed up in my place??

    Edit:
    @tynew by doing that it's mean additional texture asset and texture call, for model showcasing maybe it's good. but for final game product that's would mean bigger file size (since additional metalness textures) and heavier shader.
    try to see all of it from optimisation view, workflow can be adapted.
     
    Last edited: Mar 4, 2014
  35. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    I was not meaning for him to add the input to the current shader. He could have a separate one for reflectance(which is what we have now) and another one that supports the metalness workflow. Where you put the Metalness in one slot and the roughness in it's alpha possibly.

    About workflow being adapted technically does not really make sense with a metalness workflow. Technically what you have done by tweaking the textures is just making them read like a reflectance and roughness map.

    Now from a proper workflow point of view. Creation of textures from scratch for an object, the metalness workflow is much faster. Basically it could take me 5 hours doing a reflectance workflow whereas a metalness workflow I could accomplish in 2-3 hours. In a game production environment it is always about efficiency.

    He doesn't need to create a metalness input, all I'm saying is that it would be a nice addition to support that workflow even with a separate shader since more and more studios are now using that workflow now instead of reflectance. I have a couple of custom made metalness PBR shaders but having it in Lux would be even nicer. I'll talk to lars about that though in pm. Maybe he could pull it apart.

    If you guys need a 3D artist for asset creation to test with Lux let me know :) You can find my portfolio here: http://tynewart.weebly.com/
    Pretty outdated but I've been doing a lot of PBR work for studios that is under NDA so a little bit swamped at the moment :/
     
    Last edited: Mar 4, 2014
  36. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    That's a good point, since it's lars decision might as well we just wait from lars :)
     
    Last edited: Mar 4, 2014
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi rea,
    it is a very advanced method for blending normals giving you nice and crispy results whereas most other methods just flatten both normals...
    you can enable it be commenting:
    if(!Application.isPlaying)
    in the update function.

    lars
     
  38. larsbertram1

    larsbertram1

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

    to metalness or not to metalness...

    well, it is pretty easy to make lux support a metalness workflow by just tweaking the surface function.
    so this is how the example posted by tynew would look like using "Lux Specular Bumped Metalness" shader:

    $lux_metalness.jpg

    the inputs are:
    - albedo (rgb)
    - combined material tex:
    - - metalness (grayscale) (R)
    - - ao (grayscale) (G)
    - - specular "color" (grayscale) (B)
    - - gloss (grayscale) (A)

    i took the albedo and metalness textures as they were provided.
    i had to raise the contrast of the gloss map and added ambient occlusion.
    i added a simply gray color as "specular color" of the dielectric parts of the model.

    that’s all.

    lars
     
  39. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Go with metalness....!!!:rolleyes:
    wait so how to define spec color now???
     
    Last edited: Mar 5, 2014
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi rea,
    spec color for metals is taken from "diffuse albedo".
    spec color for dielectrics is taken from a gray scale spec map (stored in blue channel of the combines metal, ao, spec, gloss texture).


    lars
     
  41. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    ah now it make sense :)
     
  42. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    What other features do you have planned for Lux?
     
    Last edited: Mar 6, 2014
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i hope we will have a simple cubemapper for lux.

    and as far as the core is concerned:
    - ambient occlusing using uv set 2 (in order to map large objects which might use tiling textures).
    - box projected cubemaps

    lars
     
  44. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    That sounds awesome. I was wondering, if there was a quick way for me to compile a copy of the current shader but have the roughness as its own input? It's faster for me to view texturing changes if I'm texturing my art inside Unity.

    I also don't know if this is related to Lux. I can see that the edges/ silhouette around my object have been anti aliased, but I'm getting aliasing on the edges of objects in front of another.
     
    Last edited: Mar 7, 2014
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
     
  46. Saberhagen_Industries

    Saberhagen_Industries

    Joined:
    Nov 6, 2012
    Posts:
    10
    Hello, I tested Lux out today with an asset I have been working on. I am really new to the workflow and maps used with PBS and the model surely is not top notch but I wanted to share it with you guys anyways and take this opportunity to thank Lars for all his hard work.

    $LuxTest.png

    I did read about the workflow with a metalness(?) texture that would take the spec color for metal out of the diffuse map, I cannot currently say if this would be better for the workflow or not but I surely would like to try that out too!
     
  47. tynew

    tynew

    Joined:
    Sep 25, 2013
    Posts:
    122
    Hey Salem,

    if you would like to find out more on how to texture for PBR workflows, you can find that here:
    http://www.marmoset.co/toolbag/learn/pbr-practice
    http://artisaverb.info/PBT.html

    Obviously if most of your object contains metal and very little dielectrics then you'd probably want to use a metalness map as that would be much faster.

    If you require precises reflectance colors of specific materials then you'd be better off using a reflectance map. Most of the time though there is visually very little difference, well the majority of people/players will see. I think working in parallel with both reflectance and metalness shaders would be good for production workflow.

    Some examples done with the metalness workflow:
    $mms_toolbag_03.jpg
    $Ross_1_Large.jpg
    $k03g.png
     
    Last edited: Mar 8, 2014
  48. larsbertram1

    larsbertram1

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

    we are coming close to version 0.1 – as i have just pushed version 0.07 which comes with some bug fixes but also some new features like the announced metalness shader.

    get v0.07 here:
    http://bit.ly/1gmApq1

    [edited: link updated]


    $lux_0_07.jpg


    changelog version 0.07
    Terrain detail shaders
    All errors fixed for dx9 and dx11.
    Terrain shaders
    Possible division by zero fixed.
    Lux Internal-PrePassLighting shader
    doubled "max(0, dotNL)" removed.
    LuxLightingAmbient.cginc
    "o.Emission = 0.0;" added to make SH lighting work with the Lux diffuse shaders (Lux diffuse shader or the terrain detail shaders e.g.)
    Metalness Shader
    added
    Dualforward lightmaps
    docu entry added – so easily find out how to enable dual lightmaps in forward lighting
    Deferred lighting
    Disabling specular ambient lighting won’t let the faked fresnel go crazy in deferred lighting mode anymore
    Treecreatorleaves shader
    fixed
     
    Last edited: Mar 11, 2014
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    but may be even more important might be the fact that lux will come with its own cubemap convolution tool soon!
    right now it looks rather good and performs pretty well.
    more optimization might come.
    and thanks to rea for jumping in.

    preview of specular convolution:

    $lux_cubemapper.jpg

    lars
     
    Last edited: Mar 10, 2014
  50. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,682
    Great news! :D
     
Thread Status:
Not open for further replies.