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. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Project Mysh: To be honest, I like the lux version better. ;) to me, the shader forge one looks a little... flat. o_O
     
  2. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Thanks lars :), this will be helpfull.
     
  3. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    Thanks for the totally awesome shaders! :)

    I was wondering if you guys know a good place to learn more about getting cubemaps right for IBL and reflections. I'm having a little trouble getting it right and my environment is not good enough to generate cubemaps from yet.
     
  4. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Dweep: I am by no means an expert, but making a basic diffuse map is really easy: just pre-blur your cubemap (this can be done in any program that has a blur tool) then import your diffuse cubemap into unity. then, for the diffuse map in the lux environment probe, assign this new cube to the diffuse slot. and just use the original for the specular one.

    I can also offer you a texture, of which a cubemap can be created from in Unity. this is an IBL texture I made for my racing game project:
    Sky_Blank.png
    This simple gradient actually makes a nice IBL texture, to use it as a cubemap:
    • Drop this texture into your project view.
    • select the newly imported texture. the inspector should show texture options. for texture type, go advanced, then on the cubemap generation drop-down, change it from "none" to "cylindrical"
    • Click apply. the inspector should grey ouit the texture options, and a new cubemap with the same filename as this texture should appear in the project window.
    • Drag 'n' drop the new cubemap into the diffuse IBL then hit play. you should now have a desert-style IBL map on your objects! :)
    And making a new one of these is easy: just use an image editing tool to make a gradient, then import that in place of above texture and do the same steps. do this for all your IBL gradients. You can also do this for sphere-mapped textures, such as a cityscape or something like that.
     
    Last edited: Oct 8, 2014
  5. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Which KIT is that?

     
  6. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    @FuzzyQuills I'm with you so far, the troubles I'm having is more of a tweaky nature: How blurred is a good blurr (in both maps), resolution, what elements should and shouldn't be in the maps etc.

    Im tweaking my materials with the standard cubemaps at the moment and everything looks good but when I try to switch cubemap, the result is no longer as good as I want it to be. It would be good to know the general dos and donts to help me trouble shoot :)
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, again, not an expert, but basically turn off all dynamic objects before doing a cubemap bake, as having random dots in your image is probably not the best idea... :D

    And resolution for a blurred cubemap can be as low as you want it: being a blurred cubemap, you can usually get away with a lower resolution! but don't try and simulate a blur by dropping the texture size: instead, blur your images before importing.

    And it might help if you post screenshots of what you're doing. Of course, if Lars could post a "dos and don'ts list" for us, that would help heaps! :)

    Oh, and sometimes, you could go cheap and use just a blurred version of your skymap! I do this for a game using IBL lighting I wrote myself.
     
  8. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    Thanks man! This helps a lot, I found surprisingly few examples when googling. The diffuse cube seems pretty straight forward. As for the specular cubemap, how high resolution do you usually go with?

    Things are getting better and better but I'll see if I'm able to post a screen if I get stuck again. Don't know what I can share though, super secret hush-hush unnanounced project and all that :/
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    usually you would just take your skybox and use the lux env probe script to create the diffuse and specular cubemaps.
    if you need some more local – especially reflection – just capture a probe at the given position.
     
    Dweep likes this.
  10. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    How can we do that ? (UT free user here)
     
  11. ontec

    ontec

    Joined:
    Oct 8, 2014
    Posts:
    1
    Hi Lars
    first Sorry my english :(

    i have a problem with box projection....
    step by step i'll try to explane...
    • i create empty for environment probe
    • create empty for setup script
    • resize probe for baking and bake probe,
    • attach created cubemaps to setup script.
    but reflection be very small , when i change probe size change nothing....
    what is the problem realy i dont understand ???
     
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    LuxProbe support cubemap capturing in unity free
     
    zenGarden likes this.
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    it works in unity free, too!
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    if you want to use box projection the cubmap does NOT have to be assigned to the setup script.

    instead you have to assign the object that shall use box projection to the probe.

    lars
     
  15. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    The skin shader seems not working a lot in last version from Git.
    I placed the three bitmaps on the material , and attached the script SetupLux to the camera; is there something else to do ?
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the skin shader needs "correct" geometry to work fine...
    (the geometry is needed to calculate the curvature which is responsible for sss)
    next to that geometry and textures have to fit of course too.
     
    Last edited: Oct 8, 2014
  17. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    It was better wwith the model, but it's hard to see the transulency.
    I also noticed tha having ambient lightening black and no lights the skin shader is self illuminated, it is also always brighter than the lightening and it has some high specular lighetning on the opposite side from where the light comes.
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i guess, you will have to investigate a little further.. ;-)
    right now your screenshoot does not show:
    - wrong specular highlights – at least i can’t see any which is good.
    - sss or redish colored lighting may be due to the position of the light and the camera.

    -->
    - play with the "Curvature scale" parameter
    - look at the model from different viewing angles


    here you can see how "curvature" effects rendering:

    curvature.jpg
     
    zenGarden likes this.
  19. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I simply use the example from last version on GIT and there is no curvature slider for the material (or it is somewhere else ?). I have tried many lightenings but the sub surface scattering is not visible, and the model is still emitting too much light on a level with no lights.
    I don't need that shader particulary, but i could have used it if the effect was as near what we can see in Marmoset toolbag.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    sorry, but this is taken from the github repository:

    Code (csharp):
    1.  
    2. Shader "Lux/Human/Skin" {
    3. Properties {
    4. _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
    5. _SpecTex ("Specular (R) Roughness (G) SSS Mask (B), AO (A)", 2D) = "gray" {}
    6. _BumpMap ("Normalmap", 2D) = "bump" {}
    7. // BRDF Lookup texture, light direction on x and curvature on y.
    8. _BRDFTex ("BRDF Lookup (RGB)", 2D) = "gray" {}
    9. // Curvature scale. Multiplier for the curvature - best to keep this very low - between 0.02 and 0.002.
    10. _CurvatureScale ("Curvature Scale", Float) = 0.02
    11. ...
    12.  
     
  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    it seems something wrong with you material setup for the skin, mind to share a screenshot of you material settings for the skin?
     
  22. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Ah ok i didn't thaught we had to modify the shader directly.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    you will have to replace the shaders from the package with those from the repository.
     
  24. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I'm already using the download from Git repository i just copid in my project "assets" folder.
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Weird....it's works fine in my place, latest version from Git
     
    Luckymouse likes this.
  26. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    That's strange i just added the three provided maps for each slot of the skin shader.
    The script Luxsetup is to place on camera right ? It is some adjustements to make to that script ?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    the lux setup script can be placed on any game object.
    and you do not have to make special adjustments at least not for the skin shader.

    but please check the import settings of the brdf lookup texture and the combined sss map.

    lars
     
  28. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    @lars:
    In the example provided there is three bitmaps : diffuse, normal map, and headSpecGlossSsao Map, and the brdf,
    i just put these on a skin shader material, it hsould work, but the effect is not visiblme and the specualr is too high.
     
  29. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Specular intensity can be adjusted from the texture.
    Make sure the BRFD texture import setting are meet the requirement, set the texture type to advanced, Read/Write Enabled is On, Wrap Mode are set to Clamp,
     
    larsbertram1 likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    headSpecGlossSsao has to be set to "bypass srgb sampling" in the import settings too.
     
  31. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I have choosen "bypass srgb sampling" when i choose "advanced" in import settigs, but the effect remains the same , no noticeable sss and too much specular.
     
  32. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    have you change the brdf texture?
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    please check all import settings and follow the docs carefully.
    just to test it:
    - disable spec cube
    - disable diff cube
    - lower curvature scale to 0.2
    if all this does not help there must be something wrong in your project.

    lars
     
  34. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    In the beginning, i got also very reflective surface, then finally i got it right.
    The rendering result is different with the different color space.

    In Gamma space lighting:
    The reason you got too much specular that the "Head_SpecGlossSSSAO.psd" file is not enough dark in Gamma space.
    Edit the "Head_SpecGlossSSSAO.psd" file, multiply by it-self once,
    Save as "Head_SpecGlossSSSAO_2.psd" and apply it.
    You should keep the import setting of "bypass sRGB sampling" uncheck

    In Linear space lighting:
    Original "Head_SpecGlossSSSAO.psd" works just fine with uncheck "bypass sRGB sampling"
    if you use the new "Head_SpecGlossSSSAO_2.psd", it need to check "bypass sRGB sampling"

    Here is my result in Linear Lighting.
    uSky_Lux_Head.jpg
    I set the curvature scale to 4 ( more SSS effects)

    Hope it help :)

    EDIT: Here is the "Head_SpecGlossSSSAO.psd" file that multiply by it-self.
    and keep the import setting of "bypass sRGB sampling" uncheck for gamma color space.
     

    Attached Files:

    Last edited: Dec 1, 2014
  35. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Thanks for the input i will try that :)
    It 's not easy as i'm not shader guru to understand what is going on or what to do. I hope the GitHub example will get update with the right bitmap also.
    Could you give us some dropbox link to your corrected bitmap ?
     
  36. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788


    Hi Guys,

    i made some extension for LuxTerrain grass waving motion. it's basically the same as built in waving grass, i only extending the default settings that came with it so you can get a better and natural waving motion.
    You just need to replace all the content in the "details" folder in the lux shaders, and recompile the details shader by right click and reimport the folder from unity.

    Note :
    - you gonna need to adjust the grass motion settings in the terrain preferences after applying the new shader, i recomend that you using a small value for "Speed" and "Bending" settings to get a natural looks :)

    Edit : just realize for some reason youtube screwing up my video compression :(

    Update
    10222014 - Latest
    Mainly Secondary breeze tweak
    10182014
    Added better secondary breeze
     

    Attached Files:

    Last edited: Oct 21, 2014
  37. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That is awesome rea. Will try it out.
     
  38. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    So I'm trying out the SSS-shader and I'm geting some amazing results! One problem I cant seem to shake though is that I get a band of red-ish noise where at the edge of where the light hits the face. Any ideas of what I might be doing wrong?
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    lower the curvature parameter.
     
  40. Dweep

    Dweep

    Joined:
    Oct 8, 2014
    Posts:
    28
    Lowered it from the standard 0.02 to 0.005 and its better but im still getting a little more red than i think i should have :/
    0.005 seems pretty low though?

    EDIT: Btw thanks a ton for the shader! I hope someone hugs you alot because you deserve it :D
     
  41. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    thanks, let me know how it turned out :)
     
  42. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Put this folder in a test project and it destroyed the Lux terrain shaders. Replaced with original details folder and the Lux terrain material was still pink. Then reinstalled Lux and still will not work. Fortunately it is just a test project. Really want to get it working. Will try with a clean project.
     
  43. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    have you tried recompile lux?? right click and reimport lux folder
     
  44. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That works. Thanks.

    It looks really nice. Especially on grass. Looks a little funny on larger plants like bushes. They probably should not be used as detail plants anyway. This would look amazing with water plants. Have a slow wind speed and the underwater experience will be made:).
     
  45. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Well true, for a large details plants it would look weird, but you can control it by using the vertex alpha of the mesh.
    Oh and i put an update for the details shader. it's mainly just a tweak that's why i keep the old version in case someone prefer the old one.
     
  46. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    85
    I'm getting an error with the cube mapper. It doesn't seem to be able to create the cubemap assets. I'm using the current lux from gethub and unity 4.5.4 Render mode Differed, dx11 if it matters. Thanks for any help.
    LuxProbeSmall.jpg
     
  47. ludiares

    ludiares

    Joined:
    Jul 14, 2011
    Posts:
    242
    You need to save your scene first. It seems you haven't done so
     
  48. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    85
    Tried it again making sure my scene was saved and I got the same error.
     
  49. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    @bluemoon
    I think you just need to save the scene first. When you bake new cubemaps, it need to read the saved scene file path.
     
  50. bluemoon

    bluemoon

    Joined:
    Dec 14, 2012
    Posts:
    85
    Ok its working now. I had saved the scene after getting the error the first time. Apparently that won't fix it once you've already tried to bake the cubemap the first time. It must not update the path after the first bake.

    Thanks for the Help