Search Unity

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

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

  1. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Hi Lars,

    looked through your shaders to study and learn.. I had my own PBR already but for IBL I admit I preferred studying your source to reading paper after paper :D it seems like a simple technique behind the scenes but resulting in much improved visuals, real neat. I notice both DIFFCUBE_ON and SPECCUBE_ON use the cubemap.a to multiply with the cubemap.rgb. I'm wondering whether this is a common use-case and what's the need? ;) I have typically dynamically rendered cubemaps so alpha will be 1 so I'm not particularly concerned, but I'm kind of wondering what the intended uses (and possible new effects) are with this in a "typical" IBL workflow.

    (The other thing I'm wondering, but I'm soon gonna find out myself, is whether spec-IBL really adds much when one has diff-IBL, normal fresnel reflections and PBR-specular.. it already looks so freaking cool as-is :D but then I initially also doubted the usefulness of diff-IBL over complementary-sky+ground-ambient until I saw the results....)

    So the simple question is, what's the point of a cubemap-alphachannel ...
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi metaleap,

    multiplying rgb by a is what rgbm decoding looks like: if you use high dynamic range encoded cubemaps (they are stored in rgbm) the shader has to decode the final color.
    if you have only ldr cubemaps you can simply skip it.
    see: http://graphicrants.blogspot.de/2009/04/rgbm-color-encoding.html
    for further details.

    spec ibl is needed to simulate any kind of reflections. metal just won’t look like metal without it.

    lars
     
  3. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Managed to get some time to test out new Quixel stuff and is very nice.
    Decided to make a sci fi panel since they're quick and easy to make and with my limited time thats perfect.

    Dont hate using a black render background lol xD I've already learnt not to use that but I couldnt be bothered making it grey for such an insignificant render
     
    SememeS likes this.
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    wow, quixel’s textures really make lux shine!
     
  5. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    What the hell is Quixel :D thanks Lars for explaining, OK since RGBM isn't a RenderTextureFormat I guess I have to continue rendering my realtime cubemaps into ARGBHalf for HDR and can skip that multiply.

    One thing I haven't really figured out from your code yet is whether spec-IBL replaces normal reflections, or replaces spec-CT/BP, or is added on top of both as just-another-additional-contribution.. will have to do some research. At some point near the end of LuxLightingAmbient you do this:

    Code (csharp):
    1.  
    2. o.Emission = (1 - spec_ibl.rgb) * o.Emission + spec_ibl.rgb;
    3.  
    So this gets included in the surf frag-shaders before they are lit, and then as far as I know Unity's SS lighting model they do something like:

    Code (csharp):
    1. albedo * LightingLuxDirect_xyz() + o.Emission
    or similar. OK so this looks as if, if one already has fresnel reflections in all shaders, then spec-IBL would replace those? Or blend both? I guess? Or maybe not... heck I'm lost now :D
     
  6. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    @metaleap where da hell have you been? :O. They got 4 main programs, DDO is pretty much its a PBR texturing solution that is based around their dyna-mask, which allows amazing details to be created. NDO is a normal map creation tool. 3DO is a PBR rendering software integrated with photoshop and finally the standout I think of the bunch, Quixel Megascan. It provides a library of 8k, tileable, PBR ready textures.
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi metaleap,
    spec ibl comes from ambient or indirect lighting and is added on top of the direct specular lighting (blinn phong or cook torrance).
    fresnel is taken into account on both.

    quixel: www.qixel.se

    lars
     
  8. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813


    THAT is Quixel.
     
    SememeS likes this.
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Dude....!!!!! o_O
     
  10. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Beat me to it! Glad they work as well as hoped, its good stuff

    An alternative for texture sets that can cater for pbr is gametextures.com, its been a great mainstay and now i cant wait to chuck megascans in there as well
     
  11. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    OK Quixel looks insanely cool once I progress from shader coding to creating/editing art, thanks for your patience folks :D

    Lars, so if I understand this correctly this is basically like the bog-standard "cubemap-reflections with fresnel falloff", except you're using roughness for mip-level selection. This would explain why you don't have any specific "reflective" shaders in Lux, the need is served by "spec-IBL". Am I finally understanding this correctly? ;)
     
  12. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Pretty much from what I understand
     
  13. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    hahahaha

    nice @Tiny Man you were able to get some time! really good results.
     
  14. larsbertram1

    larsbertram1

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

    i think you understand it correctly.
    any (specular) shader is reflective. the sharpness and the amount of the reflection depends on roughness and specular color and can be controlled per texel.

    lars
     
  15. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Got half a day break after my maths exam which was really easy (silly old mainstream)
    Did more tiles thinking of ideas for my environment i'm gonna make, practicing with DDO and NDO etc.


    In unity with lux and marmoset skyshop skyboxes.

    I like this design for the tile so I might continue with it, make a tile set, some walls etc.
     
  16. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    gotta move away from lux sadly ;(, cant use all the goodies new skyshop brings, so I made a simple pbr shader in shaderforge, stuff still looks good though except gloss seems slightly less spread out (i.e gloss has increased) all ok though.
     
  17. VicToMeyeZR

    VicToMeyeZR

    Joined:
    Jun 3, 2012
    Posts:
    427
    I am getting some compile errors in LuxCubePorcessor.cs
    after you call class :
    Code (CSharp):
    1. public class LuxCubeProcessor {
    2.  
    3.     public Cubemap cubeMap;
    4.     public bool TakeNewProbe;
    5.     public GameObject probe;
    6.  
    7.     public ConvoModes ConvolutionMode;
    8.     public bool HighestMipIsReflection = true;
    9.     public bool PullHDR;
    10.  
    11.     private Color[] CubeMapColors;
    12.    
    13.     public float SpecularPower = 2048; // Matches Lux SpecPower
    14.  
    15.  
    16. #if UNITY_EDITOR
    you have if unity editor check, but at the end of the file, you have the endif behind the closing } for the class.
    When I fix that and put it in the } then other files fail to compile
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi vic,

    i am not sure which version you refer to.
    please make sure that you use the latest version from the github repository. that should work fine.

    lars
     
  19. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    This looks incredible! Never thought the robot scene could look this good!
     
  20. cadviz

    cadviz

    Joined:
    Jan 17, 2012
    Posts:
    28
    Hi; Quixel users
    I tried to download the (beta Quixel Suite) from the official website... but unforunately No way..:(
    I hope somebody may push an advice how to get it... :)
    Best regards
     
  21. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  22. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    OK, I have a potentially stupid question.
    I imported Lux from Github, which didn't have any environment maps included. So I'm trying to import one of my own. I've got an HDR file, which I tried importing into Photoshop and exporting an OpenEXR file which Unity can import, but when I try to turn it into a cubemap the colors go completely wrong.

    Given a panoramic HDR file, how do I get this imported into Unity and working with Lux?
     
  23. cadviz

    cadviz

    Joined:
    Jan 17, 2012
    Posts:
    28
    Thanks for trying to help...
    in fact it was the same link I had tried several times and failed... here is the message I got
    Unable to connect
    Firefox can't establish a connection to the server at d85clmw03d1co.cloudfront.net.
    Same problem with Opera OR Microsoft Internet explorer

    I hope there would be another link :)
    <<<<< EDIT >>>>>
    OR; May be someone upload the zip file to any website, so I can download it...:)
    It seems I'm requesting something in the wrong place...;)
    sorry for bothering
     
    Last edited: Jun 16, 2014
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    lux is not skyshop – so it does not allow you to convert panoramic pictures into cubemaps.
    but lux allows you to capture and convolve hdr or ldr cubemaps or use any prepared one.

    nevertheless i have updated the repo and added some base cubemaps to get you started.

    lars
     
  25. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    So, could I use Skyshop to convert the panorama, and then use that with Lux?
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes, you can.
     
  27. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Can someone point me at an article or something that can tell me what parameters I should input for concrete, wood, and brick? Basically for any surface. I grasp the basic concept and know how to work with metal but nothing else. What are you guys using for inputs? Will look at lots of sample scenes when I get a chance
     
  28. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Lux comes with the Dontnod Entertainment PBR chart, which should help.
    There's also Quixel, which has a lot of built-in materials that you can sort of paint in the rough color inputs and then overlay your own images on top.
     
  29. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Good point.
    Actually, i try to solve the problem with Substance Painter. Maybe someone with this same tool will be teaching us how to do..
     
  30. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    I could. Make a megascan material chart wih all their new textures from the beta if you would like
     
  31. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Huh, I thought bout signing up for that. Will have to take a look
     
  32. mster50-2

    mster50-2

    Joined:
    May 28, 2013
    Posts:
    20
    Hi there Lars,

    I did some testing with Lux this evening, and when attempting to build to Android, the editor (v. 4.5) kept hanging on "Building Assets for Scene X" - this only happened when I had any shader from Lux set on a material that was being rendered in the scene. Do you know what might be going wrong?

    I have the latest version of Lux off Github.

    Thanks a bunch!

    Edit - after some testing, this is happening on every platform I try and build to, and only when a Lux shader is present in the scene. This tells me it's a config problem somewhere... hopefully this helps nail it down a little.
     
    Last edited: Jun 17, 2014
  33. larsbertram1

    larsbertram1

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

    unfortunately i have to confirm this.
    but i can only guess what is going wrong: on building a player all shaders get recompiled for the selected platform – even if i work on osx and built for osx.
    it looks as if unity’s new shader compiler in 4.5 hangs up during this process due to the complexity of lux shaders.
    commenting all #pragma multi_compile directives and replacing them with #define "solves" this issue…

    so i think it is a bug in unity 4.5

    lars
     
  34. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Are you both on 4.5.0 or 4.5.1? If you're sure this is reproducably a new shader-compilation bug in 4.5, you should definitely first submit it and then send @Aras the ticket ID

    When building only for platform X, it certainly shouldn't compile all other platform versions on build.
     
  35. mster50-2

    mster50-2

    Joined:
    May 28, 2013
    Posts:
    20
    Thanks for the reply Lars. That's a bummer - we should submit a bug report for sure.

    Also, thanks for Lux. Truly stunning.
     
  36. mster50-2

    mster50-2

    Joined:
    May 28, 2013
    Posts:
    20

    Good call. Will get on that.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i am using 4.5 – is 4.5.1 already out?

    at least it should not crash! ;-)
     
  38. mster50-2

    mster50-2

    Joined:
    May 28, 2013
    Posts:
    20
    Yes, 4.5.1 has been released.
     
  39. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    I was wondering, I am using shader forge is there a way to add lux functionality to shader forge shaders?
     
  40. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    Yeah. I just tested it today, I'm using 4.5.1 and It's also hanging on build.

    I don't know much about shaders. I was wondering:
    what does #define do different than #pragma multi_compile directive?
     
  41. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    Ah , I see. I just noticed there was DIFFCUBE_On as default so I just changed it with DIFFCUBE_OFF and it did exactly that, ok I think I'm understanding the difference. So basically I have to specify instead of leaving all options.

    Well, using #define is really simple and in the meantime it definitely solves the hanging problem when building with 4.5 and 4.5.1
     
    Last edited: Jun 17, 2014
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    not only that. it also reduces the size of the shader dramatically.
    so using #define instead of #pragma multi_compile should always be your choice if it comes to preparing the built.

    lars
     
  43. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    That's perfect, I'll definitely keep using this in the future then.

    Thanks lars
     
  44. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    hey lars, is it possible to use lux in a shaderforge shader using skyshop IBL cubemaps? As I would love to have this combo.
    If you could reply with an answer that would be great! Or at least lux working with shaderforge
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    unfortunately lux is not supported by shader forge.
    however tweaking the existing lux shaders is pretty simple as far as you have some expericnecs writing surface shaders.

    lars
     
  46. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Ok lets see what my 0 surface shader experience can do ;), ill just muck around until it works
     
  47. PartyD0nut

    PartyD0nut

    Joined:
    Mar 24, 2014
    Posts:
    17
    I have a question about the ease of use with the env probe cube script.
    The guy in this video has a find close mesh button, is this already in the script or did i miss out on something? If it's not i think this would be great addition.
     
  48. maxwood

    maxwood

    Joined:
    Mar 28, 2012
    Posts:
    30
    Hi all,

    Just been checking out Lux - some really fantastic results even in the demo scene :D

    We're thinking about using it for an architectural apartment demo. Has anyone tested the performance on a larger scale? How does it compare to regular materials?

    Thanks,

    Max
     
  49. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Here is an older post.

     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    PBS of course is more expensive in the pixelshader. But it should absolutely be no problem on modern hardware – the number of drawcalls, post processing effects and other properties of your scene will most likely slow down rendering much more.
    so if you pay attention to all common optimization opportunities like proper textures atlases, dynamic and static batching or even lod or occlusion culling lux should not have much impact on the rendering time.
     
    Last edited: Jun 21, 2014