Search Unity

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

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

  1. Trideka

    Trideka

    Joined:
    Mar 24, 2013
    Posts:
    16
    I'm actually getting this error as well, and it doesn't seem to matter how when or where I save the scene. Before trying to ever bake the cubemap, after the error, before the error..
     
  2. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    Anyone tried Lux in Unity 5 beta yet? Just porting a whole scene worked fine but the problem I have now when converting to the U5 lighting is that the mesh dont respond to lightmaps.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi dweep,
    what do you mean with "converting to the U5 lighting"?
    lux will most likely not work with with the new deferred rendering mode as it does not fill all needed outputs.
    it may work with forward rendering but will probably give you dull specular highlights due to a missing normalize (either in lux or unity 5 – you can choose ;-) ).
    and to be honest: unity 5’s standard shader should replace the need for lux in most cases (although it is a bit more expensive to render).
    for other cases i think about implementing lux features on top of the new standard shader e.g.: wetness, texture blending according to vertex colors, skin...

    lars
     
    EddieLopes likes this.
  4. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    Sorry I was being unclear, meant something like "Using Lux shaded objects with Unity 5s new lighting system". My bad :p

    Yeah the standard shader is pretty neat (except that I miss the metalness workflow) but the advanced lux features are really nice. I got used to having the SSS around, would get excited to see it in Unity 5 as well :)

    Don't remember if the scene I imported was in deferred or forward but it looked ok so I guess it was in forward.
     
  5. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    There's gonna be metalness workflow built in support in unity 5 btw, and for the lighting system since unity 5 switching to enlighten i think it's better if we wait for it, also it seems(possibly) they keep changing something in rendering in the beta version.
     
    Dweep likes this.
  6. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hello,

    I am quite new to the whole PBR Shader stuff and want to get deeper into it. I bought Substance Indie package and wanted to create some PBR Models for Unity. Since I am not lucky to have Unity 5 or Marmoset or all that fancy stuff, and I know that Lars made some really good shaders (using ATS and I love it) I would like to try Lux (For models and maybe terrain).

    Right now I am digging myself into Substance Painter and it is very handy. Does anybody know what kind of channels I need for Lux? Is there maybe also a viewport shader for Painter (I know there is one for Designer)?

    These are the channels I can export from Painter:

    upload_2014-11-6_22-58-40.png


    I really would appreciate your help!

    Thanks a lot!
    Cheers!
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    what you need is:
    - diffuse
    - normal
    - unity5: specular (rgb) + glosiness (a)

    exact the same you will need for unity 5 ;-)

    lars
     
  8. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200

    Hi Lars,

    thanks a lot for the very quick answere. I will give it a try during the weekend. Hopefully this will work! I have one additional question regarding the Lux Terrain. Do I also need PBR textures for the terrain, or will it work with normal textures? If not, which software do you use to create PBR textures for a terrrain?

    And maybe a second question. I would love to use Terrain Composer for the landscape creation, do you know if it is compatible with Lux, or maybe your ATS (delux)?

    Thanks again!

    Cheers
    Ingo :)
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi ingo,
    what do you mean by "pbr texture" of the terrain?
    you need diffuse (including a few lighting information as possible), normal amd gloss/roughness/smoothness - just name it as you like. specular color is defines per splat using a color picker if i remember correctly: that should just be fine as regular terrain materials are dielectrics (0.02 - 0.04).

    and it should not be a problem to use terrain composer. it does not offer direct support for lux but that is not needed anyway.

    lars
     
  10. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi Lars,

    thanks again. I thought, that I had to create a specific specular map. I didn't know how to do that.
    I will give it a try. Hopefully everything will work the right way :)!

    Have a nice weekend!

    Cheers
    Ingo
     
  11. AthosK

    AthosK

    Joined:
    Jan 20, 2013
    Posts:
    428
    This is probably a dumb question but do you bake lightmaps with pbr shaders? I'm pretty new at all this stuff
     
  12. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Of what I remember you have to disable the IBL and AO settings in the material. Just check those three boxes at the bottom of each material. Then it should bake like normal. Will not look half as nice but will work.
     
  13. AthosK

    AthosK

    Joined:
    Jan 20, 2013
    Posts:
    428
    So I don't have to bake it if I don't want to, right? I'm more intrested in making them as nice as possible rather than be optimized to run on low end platforms, my focus is pc. So do I skip the lightmapping all together in a pbr approach?
     
  14. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    For best quality leave it in real-time. Especially if you are using Unity free. Besides getting rid of the normal texture you also disable IBL. Not sure about Unity 5 but for now if you want it to look great keep it in real-time.
     
  15. AthosK

    AthosK

    Joined:
    Jan 20, 2013
    Posts:
    428
    Ok got it! Thanks for the help!
     
  16. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Your welcome. Post a screenshot as it progresses. Love screenshots;).
     
    Last edited: Nov 19, 2014
  17. Dhialub

    Dhialub

    Joined:
    Nov 11, 2013
    Posts:
    41
    Hy!
    Not really relevant, but does anyone know how to set up post effects?
    Pbr looks really good with some proper bloom and tonemapping, but I couldn't achieve anything convincing.
     
  18. Trideka

    Trideka

    Joined:
    Mar 24, 2013
    Posts:
    16
    So I've been having a lot of fun with Substance Painter and Lux. Been working on this guy for the last couple of weeks. He'll be in the asset store soon, and thanks to Lux I can provide him with a PBR solution that just works out of the box. =) Thanks so much for your work Lars.


    Bomber Dude Robot Lab.jpg

    Screenshot 2014-11-19 12.11.30.jpg
     
    AthosK, EddieLopes and Baldinoboy like this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @ trideka: your screens look very nice!

    @Chanhy: i do not know what your problem is, sorry.
     
  20. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi,

    this looks really cool. I am also using Substance Painter to create content used by the Lux shader. Which shader are you using? I can only use the "Bump Specular Metalness" with base color, normal and Unity 5 output. Are you using the same?

    @ all / Lars

    I have a question regarding the "Lux Bumped Specular Parallax" shader. Is it possible to create also a "Metalness" variant of this shader? I looked at the shaders (Bump Specular, Bump Specular Metalness, Bump Specular Parallax) but can not figur out how to change the shader to also accept the metalness workflow.
    Could somebody please help me?

    I wrote in the normal Bump Specular Metalness shader, that it is darkend:

    Code (csharp):
    1.  
    2. // We have to "darken" diffuse albedo by metalness as it controls ambient diffuse lighting
    3.      o.Albedo = diff_albedo.rgb * _Color.rgb * (1.0 - spec_albedo.r);
    4.  
    Is it possible to expose the "darken" value to the inspector (slider, value) to adjust the darkening value?

    Thanks a lot to all!
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,
    it does not make any sense to expose any "darken" value.
    when using the metalness workflow you have to adjust the albedo according to the metalness value. that is how things work.
    lars
     
  22. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Thanks lars,

    i thought it would be possible to adjust the darkening value a little bit. But if it is not possible it's ok then ;)
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    nope, it is called "physically based shading" – so no magical sliders...
    if you want to darken the output, darken your albedo texture ;-)
     
  24. kebrus

    kebrus

    Joined:
    Oct 10, 2011
    Posts:
    415
    Could anyone explain me how do i use lux with rtp? no matter what i change i can't seem to turn on the cubemaps for the terrain
     
  25. Trideka

    Trideka

    Joined:
    Mar 24, 2013
    Posts:
    16

    Hi, and thanks!

    The Unity 5 output from Substance Painter shouldn't be used with the Metalness shader. It's for spec/roughness.

    I was using just the standard Lux/Bumped Specular shader. Plugging Painter's diffuse export into Lux's "Base (RGB) Alpha (a)", and . Unity5_specgloss into Lux's "Specular Color (RGB) Roughness (A)" slot.

    If you want to use the Lux's Metalness shader, use the Substance Painters "metallic" export.

    If your colors look off, be sure you have the latest version of Substance Painter. The last update fixed a bug where the Unity5 export wasn't being properly converted to sRGB.

    I actually now use a modified Bumped Specular shader that also has a self-illumination slot for glows and lights. Was easy as pie to alter, even for a non-shader-programmer like me. =)
     
  26. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi Trideka,

    many thanks for your answere. Thanks to your post, I went through my whole setup and found the error. It was not the wrong exports from substance painter, it was the cubemap setting in the Lux setup file. I checked, that the cubemaps are HDR. Therefore the specular bump models looked way to bright and the metalness shader seemed right (cause he is darker) but a little bit to dark ;).

    Long story short: Thanks for getting me to check everything again. Now it is looking fine! Yeah!!!

    Cheers
    Ingo

    P.S. Could you post a screen from your modified shader beside the normal shader? Would be interessting for me ;)
     
  27. OneWayRoad

    OneWayRoad

    Joined:
    Jul 27, 2013
    Posts:
    26
    hey guys, how do you get a double sided hair shader with soft edges?. I hope lux hair can achieve that.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    double sided: double geometry and flip the normals: there is no better way than that.
    soft edges would mean rendering hair as transparent object which would mean: no real time shadows on hair.
    so no support for this.
     
  29. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Hi OneWayRoad,

    To help: code to flip normals
    void vert (inout appdata_full v, out Input o) {
    o.uv_MainTex = v.texcoord.xy;

    float3 Normal = v.normal;
    float3 viewDir = ObjSpaceViewDir(v.vertex);

    float ret = dot (viewDir, Normal);

    if (ret<0)
    v.normal *=-1;
    }


    If alias in the alpha is hurting the hair, you could use a distance field shader to do the cutout:
    http://forum.unity3d.com/threads/unity-signed-distance-field-textures.61243/
     
    OneWayRoad likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi eddie,
    i did not check your code, but in all tests i have ever done flipping normals in the vertex shader i got pretty noticeable lighting artifacts at grazing angles, so it is no alternative.
    the only method that worked out was using a 2 pass shader – which in the end turned out to be more expensive than just doubling the faces.

    lars
     
  31. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    I had this problem too if I do not calculate the binormals of the mesh.
     
  32. VertexSoup

    VertexSoup

    Joined:
    Nov 25, 2014
    Posts:
    44
    Hi Lars,
    does button to get meshes in cube mode probe got discarded? I do not see it in my fork.. Only way to assign objects to use cube is manual now?
    Thank you
    Peter
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    and does calculating the binormals help?
    i thought it was an interpolation problem...
    how would the code look like?
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i never found the time to add it to the official repo. it is only present in a custom fork.

    lars
     
  35. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    With Transparent/Cutout/BumpedDiffuse shader:
    upload_2014-12-9_0-5-51.png
    With twoSided shader:
    upload_2014-12-9_0-7-41.png
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what happens when you slightly rotate the camera?
    don’t you get some strange popping in the lighting?
    or even artifacts regarding specular highlights?
     
  37. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Has I said, I don't know why, but the problem pops when I import the normals.
    I put the backface in red to acentuate the problem.
    upload_2014-12-9_7-51-32.png
    upload_2014-12-9_7-52-11.png
     
  38. OneWayRoad

    OneWayRoad

    Joined:
    Jul 27, 2013
    Posts:
    26
    ok, thx for the info.
    how do you get aniso like you did here



    I have already tweaked all the settings but all i get is rim. tried Aniso direction to (0,1,0,0) and (1,0,0,0). Still no aniso.
    Capture.PNG

    @ Eddie: thx
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    all hair strains have to be laid out parallel to each other e.g. parallel to the v-axis.
    this has to match your aniso direction.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it might be the smoothing angle: hard edges mean: vertices along those edges are doubled.
     
  41. OneWayRoad

    OneWayRoad

    Joined:
    Jul 27, 2013
    Posts:
    26
    trbtex003.jpg
    this is the map i use in the model. can you show me the map you used in your hair model?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi onewayroad,
    ALL strains have to be parallel like in the texture sheet below:

    Bildschirmfoto 2014-12-10 um 00.19.55.png
     
    OneWayRoad likes this.
  43. OneWayRoad

    OneWayRoad

    Joined:
    Jul 27, 2013
    Posts:
    26
    should it work if I test it on a plane?

    Edit:

    I tested your whole map in a single plane but still no good result.
    I dont know but in an experiment, I painted hair vertically as you said but still no aniso.
     
    Last edited: Dec 9, 2014
  44. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    If you can paint anisotropic direction on a texture, you can paint them in any direction and use the modified shader I shared some page before, however I have never find a solution to do the painting so lol
     
  45. youarebritish2

    youarebritish2

    Joined:
    Nov 7, 2013
    Posts:
    29
    I've also been struggling with getting the anisotropy looking good, even when the hair strands are all oriented vertically. Has anyone had any luck with this, and if so could you share some tips?
     
  46. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Show all the map channel you are using
     
  47. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    Hi lars i've been following this thread for awhile now and am considering finally making the jump to Lux. Before I do so I have a few questions of course! First off I am using your AFS shaders for all of my foilage and it has become an essential part of my project. I am wondering if these will work nicely with Lux and what changes I may need to make. Secondly I am wondering what the performance impact of using Lux will be. I am using Unity pro 4.6.

    One last question that maybe someone here might answer. I am also using RTP for my terrain shaders and mesh blending. I am wondering if anyone has used this successfully with Lux as well? Thanks.
     
  48. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Not sure about RTP but Lux and AFS get along pretty well. You can let the Setup AFS script control IBL but I usually use the Lux script to set up the IBL. Either way it works and looks great:).

    For me there is probably a 3-6 drop in the FPS using Lux. Nothing major. Considering the quality gained it is well worth it.
     
    Jaqal likes this.
  49. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    So I went ahead and took the plunge and installed Lux. A very big decision since my project is so far along but so far things worked out much better than expected. Worked great with RTP and everything else I am using. AFS as well but I have one simple problem someone might help me with. When using deferred(Unity Pro 4.5) I can see through my trees using the AFS shaders. I know this has something to do with the transparency and is easily fixed by switching to forward rendering but I get a slight performance boost in deferred as well as being able to use many lights which is important. Any help is greatly appreciated!
     
  50. larsbertram1

    larsbertram1

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

    i have just started to port some lux shader to unity 5 beta (v17).
    the first one is the lux pre integrated skin shader – which got a little update and now supports "deep subsurface scattering" or translucency.

    if you take part in the unity beta program you can grab the shader from the git repo:
    https://github.com/larsbertram69/Lux_2.0

    others might follow in the nearby future.

    lars


    Lux2_Skinshader_animgif.gif
     
    Last edited: Dec 22, 2014
    UnLogick, ksam2, red2blue and 4 others like this.