Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

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

  1. jammer42777

    jammer42777

    Joined:
    Apr 21, 2014
    Posts:
    116
    It seems to work with no frills at least

    I imported the substance using lux free, set the shader to the metallic setup and had no trouble. after adding some post processing effects I came up with this:
    screen1.jpg screen2.jpg
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    nice
     
    jammer42777 likes this.
  3. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    I'm having a problem again when I try to use "Lux Plus Internal-DeferredShading" instead of CTI-Deferred Shading on Baldinoboy's Tropical Forest Pack:

    With CTI:
    cti.png

    With Lux Plus:
    luxplus.png

    This is the material of the grass:
    shader1.png

    The grass appears like it glows in the dark.

    I've applied all tweaks (Adding "Lux Setup", changing "CTI_TranslucentLighting") that you told me about.

    What else could I try / check?
     
    Last edited: Dec 14, 2017
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    that in fact looks odd.
    but i guess that you have forgotten to set up lux lighting properly.
    unlike cti lux may reduce the shadow strength on translucent objects. and taht is what i guess is happening here: the grass and ferns simply get some directional light although it should be fully occluded by the terrain.

    fix this by setting the "shadow strength" in "translucent lighting" in the lux setup script to 1.0.
     
    hopeful likes this.
  5. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    Great, that fixed it, thank you!

    But 0.7 is the default setting when I add Lux Setup to any component.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    you are welcome.
    and yes: 0.7 is the default setting. i might change it though.
     
    OfficialHermie likes this.
  7. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Is there optin to make smooth transtion of LOD with lux shader? Thank you
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    currently: no.
     
  9. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    OK thank you, But by NO you mean that you have no time to do that, or that it is overall hard to do? Cause we could give this job to our programmer.

    Also i ahve a question because lux has decal shader too. Is there any system of adding decals with your shader to game? For example can you recomend any decal system from asset store that could work with your decal shader?

    I'm asking about it https://forum.unity.com/attachments/08_lux_decals-jpg.184948/

    i see ther some projector system that helps to put decal on any geometry, What kind of system did you used?
     
    Last edited: Dec 24, 2017
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    depends on which shader you would need this feature: lux standard or custom surface shader and which version of unity you are using. things changed with unity 2017.
    no. lux decals are "only" geometry based decals – no so called "deferred" decals where you just add a cube to your scene and the decal would automatically adapt to the given surface.
    you may use lux deferred decals to add some smoothly blending details to your geometry like posters on a wall, cracks and things like that and would most likely add them in you 3d app.
     
  11. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Hi, can you please combine wrinkle maps offered by unity with Lux plus skin? a skin shader without wrinkle maps can't be good enough.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    adding wrinkle maps to the lux skin shader is sraight forward in case you use the base tec provided by unity:
    https://assetstore.unity.com/packages/essentials/the-blacksmith-wrinkle-maps-39924

    with just a littele work on the included textures it looks like this:

    wrinkle_maps_lux.jpg

    you find the tweaked lux skin shader (tested in unity 5.6.3. using lux personal 2.02) as attachment.
    unfortunately the render texture created by the unity script does not let us sample blurred diffuse normals – so changing the corresponding values in the shader does not have any effect. but the result looks fine – even without that feature.
     

    Attached Files:

  13. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Excellent cool job you've done. I really like Lux more than other shader packages.
    Thanks a lot.
    Just there is a problem. It removes main bump map when no blend shape's running.
     
    Last edited: Jan 28, 2018
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    oh, the wrinkle map replacement shader needs a _BumpScale property – which the lux skin shader does not support.
    you will find a fixed shader as attachment which adds _BumpScale as hidden property and sets it to 1.0.
    and as far as 2017.3. is concerned: it just runs fine.

    wrinkles_2017.3.jpg
     

    Attached Files:

    Crossway, hopeful and ksam2 like this.
  15. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    511
    I'm going to use Lux cause it's cool and free. Just skin shader doesn't work with some assets like segi cause it's a forward shader :(
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    that needs lux plus – which unfortunately is not free but rather cheap :)
     
  17. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Does wrinkle map shader also work with deferred version of lux? Lux plus?
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    it should.
     
  19. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Hi
    I've upgraded to Lux Plus and it's cool but I have a big problem.
    Skin shader looks purple like below pic when I use segi!


    I can't ignore segi, not either Lux skin shader. Please solve this thanks.
     

    Attached Files:

    Last edited: Feb 17, 2018
    EvilFox likes this.
  20. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Why Lux Plus doesn't support deferred lighting with same method as Uber or Alloy?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    as they need extra buffers – lux does not as it packs the needed information. the reason why skin turn into purple when using segi.
    as segi has become open source i might take a look into it when i find some time...
     
    Flurgle, EvilFox and ksam2 like this.
  22. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Thanks.
    Also I wonder why there's no parameter to increase normal map and micro map intensity. I always increase those parameters to 1.8 or even more. Is that possible to add intensity parameter for normal maps? It can be really useful.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    because whatever you can do in photoshop, you should do there. and not per pixel in your shaders.
     
    ksam2 and one_one like this.
  24. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Is there a way to kill specular on a specific light? There was an option with Alloy we could remove specular on a specific light and that was really useful. As I don't use alloy anymore that would be useful if Lux support this too.
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    lux supports diffuse only lights. right out of my head you have to simply change alpha of the light color. maybe you have to add an area light script.
     
  26. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Didn't work this way. anyway is that possible for Lux to support Stochastic ScreenSpaceReflection?
    https://github.com/cCharkes/StochasticScreenSpaceReflection
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    ?
    same as with segi: lux's specular gbuffer has to be encoded properly by the ssr shader.
    you may have a look at the included ssr shader from the the old post processing stack.
     
  28. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    I did what you said and still It can't remove specular from my second directional light.

    Are you saying I should chose between SEGI and Lux? :(
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    you are using 2 directional lights? that is a killeras unity will perform a 2nd full screen lighting pass.
    never do this.
    and i do not really know why one even should do this. so what do you try to achieve?

    no, what i say is in case you want to use a certain plugin you have to make it compatible yourself picking up the code examples provided with the tweaked post processing stack shaders or wait until i find some time to do it.
    lux plus is designed to give you very fast rendering results by safing bandwith, thus it is not designed to support such expensive extensions like segi.
     
    ksam2 likes this.
  30. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Any progress with SEGI?:rolleyes:

    Also for SSR should I use old post processing stack or it work with new post processing stack too?

    Why? It's a better looking skin shader than other skin shaders. I've tested all skin shaders and still Lux is better.
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    not so far. i am totally busy, sorry.

    as far as i know there are no chnages to ssr in the new version of the stack. correct me if i am wrong.

    that is fine. but my first statement still describes what lux is all about: being a very cheap extension for the current deferred rendering pipeline.
     
  32. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    Hi, I wanted to evaluate the free version of Lux for use with Unity 2017.4, but one thing seems to be particularly broken:

    The Fullfeatures LOD Dither shader refuses to compile. It gives the following error: "Shader error in 'Lux/Standard Lighting/Full Features LOD Dither': Unexpected token usertype. Expected one of: ',' ';' at line 235" I can see nothing wrong with the line.

    Everything else as far as I can tell works. I tried the asset store version and the GitHub version.

    Edit: After doing some research and messing around, I kind of got it to work, but I don't think it's quite right. It seems the "UNITY_DITHER_CROSSFADE_COORDS" define is no longer supported, so defining that gives you nothing. also it's the line above the line specified in the error message. I changed it to this:

    UNITY_APPLY_DITHER_CROSSFADE(IN.worldPos.xy);

    Adding the semicolon, and feeding it the worldPos vector, and it compiles and seems to work. but it seems kind of 'clunky'.
     
    Last edited: Apr 1, 2018
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    that is caused by a nasty change in UnityCG.cginc introduced with 2017.

    in order to make it work properly you should add "dithercrossfade" to the initial #pragma directive:
    #pragma surface surf LuxStandardSpecular fullforwardshadows vertex:vert nolightmap addshadow dithercrossfade

    then you can remove:
    UNITY_DITHER_CROSSFADE_COORDS
    and
    UNITY_APPLY_DITHER_CROSSFADE(IN)
     
    ceebeee likes this.
  34. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    hah, yes, your way works much better. Thanks for the reply.

    I was reading about Lux Plus breaking image effects. How difficult is it to convert such an effect to work with Lux Plus? There's one effect I use I'm particularly concerned about:

    https://github.com/cCharkes/StochasticScreenSpaceReflection

    Would Lux Plus break that, and could it be made compatible?
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    actually you might not even have to change anything as lux plus' gbuffer layout mainly effects materials like skin and foliage which are not that much reflective. another thing would be ansiotropic materials of course.
    in that case you would have to study the provided example code and integrate it into the effect.
     
  36. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    I see. Then I think I'll buy Lux Plus as It really looks like an amazing Package. Thanks for making it. :)

    Edit: yes, turns out Stochastic SSR worked fine with no modifications.
     
    Last edited: Apr 2, 2018
  37. ryanflees

    ryanflees

    Joined:
    Nov 15, 2014
    Posts:
    59
    Hi , I've been reading your shader code in Lux Plus.
    I notice that you've used a lot (relatively) if-statements in "Lux Plus Internal-DeferredShading.shader" like
    Code (CSharp):
    1. if (isSkinMat)
    Code (CSharp):
    1. if (isTransMat)
    I'm still a noob to shader I don't know if these would be too much taxing for GPU to render the lights? And if I want to write my own custom deferred shaders by your implementations, should I use workarounds like lerp function to replace the if-statements?
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hey,
    of course conditions may be expensive - just like lerps which expand to:
    return a + w*(b-a);
    so the best thing is to do intensiv gpu profiling.
    next to that you have to check different target apis like opengl, openglcore, dx11 and metal: while writing lux i had a lot of issues with openglcore e.g. so some constructions may be a little bit to complicated in case you just target dx11.
    after all lux plus' lighting pass is pretty fast :)
     
    ryanflees likes this.
  39. VIRNECT_unity

    VIRNECT_unity

    Joined:
    Jul 20, 2015
    Posts:
    4
    Hi, I build Dynamic Weather scene. In editor, waterflow animation worked well. However it didn't work in android phone.
    I want to play animation in android phone. Is it possible?
    thank you :)
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    i never tested it on mobile...
     
  41. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    Hi there, are there any plans to port Lux to Unity 2018? thank you for this excellent asset.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    2018 comes with the HD SRP – which makes Lux some kind of obsolet (apart from the dynamic weather features).
    but as most new features are flagged as "preview" i will have to look how things develop.
     
  43. m506

    m506

    Joined:
    Dec 21, 2015
    Posts:
    93
    thanks.
    I am trying to port Lux to 2018 and I managed to get most things I needed working, except heightmapping (which dynamic weather relies on). The error I am having is on the LuxParallax.cginc, function: Lux_Parallax():
    "'Lux_Parallax': output parameter 'lux' not completely initialized"
    I tried to add: UNITY_INITIALIZE_OUTPUT(LuxFragment, lux); at the beggining of the function but it doesnt work.

    Any ideas on how I can fix this? I appreciate your time.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    that looks like the right idea...
    unfortunately i am very short on time right now. so do not expect me to come up with 2018 support soon.
    sorry.
     
  45. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    How did you fix all the shaders missing "UNITY_TRANSFER_LIGHTING" ?
     
  46. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    Ok I figured out how to fix the missing Macros. You just have to paste from Unity's copy of Autolight.cginc into Lux's copies of Autolight.cginc.

    As for the Initialization problem it's because LuxFragment is a custom type and Unity's Macro "UNITY_UNITY_INITIALIZE_OUTPUT" doesn't really support custom types.

    To fix that problem, edit LuxStructs.cginc and change the struct init under LUX_SETUP to LuxFragment lux = (LuxFragment)0; \ instead of declaring it and then using unity's macro. Then reimport everything.

    Now nearly everything works, except a couple shaders that report using too many interpolators (11 out of 10). Terrain AddPass and Terrain FirstPass are the shaders. I don't have a solve for that yet.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi there,
    Lux Plus now officially supports Unity 2018.1.
    so go and get the update or buy it now as it is on sale.
     
    ksam2, osss, Baldinoboy and 1 other person like this.
  48. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    What are you talking about? Stochastic SSR or even unity SSR doesn't work with Lux Plus skin!!! how it worked for you without any modifications?
     
    Last edited: May 25, 2018
  49. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    Funny I don't see where I said a single word about skin.

    I bought it because of the LOD shader and other effects. Stochastic SSR works perfectly fine with them.

    But since you brought it up, I did check to see with skin, there does seem to be a conflict, (not that I care about that, but if one day I do, i'm sure I can solve it. I'm pretty handy with shaders.).

    So that's what I'm talking about. Problem?
     
    ksam2 likes this.
  50. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    You right. Cause I bought it only because of skin shader I thought you did the same.

    Anyway I'm wondering where should I place my skin specular map because it seems shader only needs smoothness map.