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

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Also, here's a couple of screens in case you'd think artifacts also present in the standard because on the screenshot its black:

    Standard + baked:
    upload_2019-10-13_21-40-16.png |

    Lux + baked:
    upload_2019-10-13_21-41-49.png
    (Same place)

    Its probably shader issue I think.

    I've got no idea though how lightmapping works for the terrain engine and shader source for the standard wasn't really helpful. Forum folks probably doesn't know as well. (Due to 0 replies to the thread I've posted).

    If you've got any idea what can be causing this I'll gladly try, because I'm out of.

    Edit: I've modified lux shader source a bit, but it should break that hard (Added instancing & emission fix).
    If you want I can post those file changes to your pm.
     
    Last edited: Oct 13, 2019
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Okay, I think I've found what's messing around with it.
    Its this line in Lux TerrainSplatmapCommon.cginc:
    Code (CSharp):
    1. #if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
    2.         clip(weight - 0.0039 /*1/255*/);
    3.     #endif
    If I put there - 1 it works just fine. Soooooo why its 0.0039 or 1/255? And what's that for? @larsbertram1 ?
     
    Last edited: Oct 16, 2019
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Okay, so it seems now its incorrect in realtime mode with -1 and 0.0039 is correct for the realtime. Something is fooking wrong in the addpass shader, or Unity passes different values for different light types? (Baked vs Realtime)?
     
    Last edited: Oct 16, 2019
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    the lux terrian shader is a surface shader. so handling light maps is fully up to unity's shader complier: the shader itself does not do anything to light mapping at all.
    the lux terrain shader btw. does not support terrain instancing introduced with 2018.3.
    actually it is not meant to be used at all. it is just an example...
    that is to support alpha testing i guess.
     
    xVergilx likes this.
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    @xVergilx the provided lux terrian shader is no shader you actually want to use in your project.
    it just demonstrates how you could implement dynamic snow and wetness.
    if you are looking for a performant terrain shader which does so look out for the color map ultra shader or micro splat.
     
    xVergilx likes this.
  7. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    I'm using it for the PC, so its fine. Rest of the features can be cut down anytime in case they won't be used.
    I just need lux lighting and make it compatible with lightmapping.

    That part of the code also messes up the lightmaps. So I think I'll just wrap that constant in #if LIGHTMAP_ON and call it a day.

    Also instancing works just fine with the tweaks I've made.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    you mean area lights?
    do you use forward or deferred rendering? ah plus – so deferred.
    then i do not get the point about lighting here, as every pixel will use lux lighting.

    maybe we can start at the beginning: what do you try to achieve, where do your attempts fail, ... ?
     
  9. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Baked lights / shadows on the terrain is the thing that is not rendered correctly.
    Everything else works just fine. Its the add pass / lightmap thats get messed up.

    No worries, I've already found what's wrong with that.
    Fixed it like so:
    Code (CSharp):
    1. float minFract = 0.0039;
    2.  
    3.     #if LIGHTMAP_ON
    4.         minFract = 1;
    5.     #endif
    6.  
    7.     #if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
    8.         clip(weight - minFract /*1/255*/);
    9.     #endif
     
    Last edited: Oct 17, 2019
  10. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    NVM, its not fine. Splats that have way less opacity now isn't displayed correctly. Ugh
     
  11. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Ok, I gave up. Purchased CMU, it has correct lightmapping.
    Although 8 detail map limit is not nice.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    well, you have to balance visual fidelity and performance.
     
    xVergilx likes this.
  13. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    yes, as far as lux standard shaders are concerned.
    the rest of the shaders are surface shaders- so unity has to take care about light mapping.
     
    xVergilx likes this.
  15. T-Rocktopia

    T-Rocktopia

    Joined:
    Jul 16, 2014
    Posts:
    9
    Anyone know how to make the decals shaders in the Lux LWRP essentials work with orthographic cameras? I'm not a shader wizard... so I've been struggling to figure out how to make them work with not just perspective cameras. Any help is appreciated.
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    wrong thread :)
    but support will most likely come with the next update.
     
  17. Birdiesign

    Birdiesign

    Joined:
    Feb 13, 2019
    Posts:
    10
    I have to use Unity 5.2.3f. Should the Lux 2.01 still work with this Unity version?
     
  18. cineruss

    cineruss

    Joined:
    Mar 20, 2019
    Posts:
    27
    Does anyone know where I can find some basic configurations for bodies of water settings using Lux Water asset? Just looking for starting points
     
  19. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Anyone else not getting normal maps on their terrain from the terrain layers?
    Using 2019.1.14, same problem in unity 2018.4, 2018.3

    Works fine up to 2018.2

    Edit: So it most certainly broke because of the terrain revamp with the terrain layers in 2018.3

    Which seems odd cause a package has been submitted for 2018.3.
    Might have been an oversight, but I've not seen any comments on the terrain not working for 2018.3 till 2019.3
     
    Last edited: Dec 25, 2019
  20. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Ok, I found what the problem was.
    By looking for differences in the built in shaders, I saw this line in the TerrainSplatMapCommon.cginc

    Code (CSharp):
    1. #ifdef _NORMALMAP
    2.     // Since 2018.3 we changed from _TERRAIN_NORMAL_MAP to _NORMALMAP to save 1 keyword.
    3.     #define _TERRAIN_NORMAL_MAP
    4. #endif
    But lux forgot to change it I assume.
    So basically replace all instances of _TERRAIN_NORMAL_MAP to _NORMALMAP in the following files:
    Lux TerrainSplatMapCommon.cginc, Standard Terrain FirstPass.shader and Standard Terrain AddPass.shader

    I also added that snippet above to Lux TerrainSplatMapCommon.cginc as shown in the TerrainSplatMapCommon.cginc, but I'm not sure if that's actually needed.
     
  21. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Does anyone know how I could give the rain ripples a bit more color so that it's visible when the light isn't shining on it.

    lux pic.png

    Also can I reduce the shine on the terrain when it's wet.
    When I use it in my game there's this constant white blob following which is a bit annoying

    lux blob.png
     
  22. Chrux

    Chrux

    Joined:
    Feb 2, 2013
    Posts:
    6
    Question for Lux LWRP Essentials Decals:
    Is there any way to restrict the target for the decals? For example a decal shall be only visible on objects of the layer "Ground" but not on any other layer.
    Thanks for any hint!
     
  23. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I have a suggestion that I think would greatly add value to the Lux LWRP Essentials asset: nodes for standard PBR lit and unlit that replicate the built-in master nodes, but aren't actual master nodes so that you can modify the output color of them. This is sorely missing in the stock Shadergraph. There are lots of effects that only make sense to apply AFTER the rest of the lighting calculations, but since the master nodes have no output, there's no way to accomplish this aside from simply painstakingly reproducing all the lighting calculations node-by-node.
     
  24. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I'm getting inconsistent results with the flat shading node between the editor/desktop and Android (Quest):
    upload_2020-1-23_15-12-14.png
    This is in Editor/Desktop. The groundplane is using the shader in question, in this example, I'm only using the flat shaded node.


    This is on Quest. As you can see, it gets extremely bright toward the horizon. The only light in the scene is this:

    upload_2020-1-23_15-16-26.png

    But as you can see, the light color doesn't match the horizon color, so even though it's way too bright, it's also the wrong color if it were being caused by the light.

    Here's the setup of the shader:
    upload_2020-1-23_15-19-2.png

    And the material settings:
    upload_2020-1-23_15-21-41.png

    Any ideas why I'm getting such different results?
     
  25. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I just discovered three compiler errors when using URP/Shadergraph 7.1.7 compiling for Android GLES3:

    Lux LWRP Grass.shader:380 "IN" is undefined
    Lux LWRP Billboard.shader:415 "IN" is undefined
    Lux LWRP Billboard.shader:518 "IN" is undefined

    I resolved it by replacing "IN" with "input".
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    wrong forum...
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    do not combine lighting, meta albedo and meta spec. output color solely is lighting.
     
  28. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Sorry, what is the correct forum? I followed the support link on the Asset Store page, which goes here:
    https://lb69.jimdofree.com/support/

    And on that page, the only link that seems appropriate for Lux URP/LWRP Essentials is the link titled "Lux" which takes you here. If there is a different link for URP/LWRP Essentials, it should probably be on that page, otherwise, there's no obvious way to find it.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
  30. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Ah, thanks. You may want to update the support link then, as that's where a lot of people look first.
     
  31. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    134
    Any chance you can add a height blend version of the mesh terrain shader? Our team would be very grateful. Amazing job by the way, keep it up!
     
  32. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello guys! We want to invite you our new teaser of The End of the Sun game announcing Kickstarter campaign where we use Lux:)
    If you are interested in, add your email here. https://www.endofsun.com/crowdfunding/
     
    nirvanajie and xVergilx like this.
  33. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    It would be cool if the URP water shader would apply the scene fog
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    wrong thread - but it does.
     
  35. Pritchard

    Pritchard

    Joined:
    Aug 30, 2013
    Posts:
    5
    I have just purchased Lux Plus - amazing asset :)

    I currently have a grass renderer that I wrote using DrawMeshInstancedIndirect - it works well with the standard unity deferred shader, but of course that doesn't support translucent lighting.

    I've been reading the documentation but i'm honestly feeling a bit stumped on how to convert my shader to take advantage of Lux - specifically, with the deferred pipeline rather than forward rendering.
    Any advice on where I should be looking for information on how do this? Thank you!
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    in case it is a surface shader you can have a look into the provided example shaders like the "Translucent Base" one.

    you have to place your shader into the correct folder, declare the LuxTranslucentSpecular function in the "#pragma surface ..." directive and make sure you included all need lux files.

    then in your surface function you can write to: o.Translucency and o.ScatteringPower which are the 2 new output parameters added by the LuxTranslucentSpecular lighting function
     
    Last edited: Sep 11, 2020
  37. Pritchard

    Pritchard

    Joined:
    Aug 30, 2013
    Posts:
    5
    Thanks so much for the quick reply!

    Right now it is a vertex/fragment shader, but I'm not doing anything terribly fancy with that so I can probably convert it.

    I was a bit confused when I first looked at the Translucent Base shader, as that is included in the free version of Lux as well - with one of the advertised features of Plus being deferred translucent lighting, I figured that there would be a separate shader for that?
    Of course, I might be mistaken. I'm still learning my way around things, after all :)
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    the free version declares translucent lighting as always forward. lux plus contains a deferred definition as well.
    this is the strength of surface shaders: shader lab will generate all passes (forward, deferred, meta ...) depending on what is defined in the lighting function.
     
    Pritchard likes this.
  39. Pritchard

    Pritchard

    Joined:
    Aug 30, 2013
    Posts:
    5
    Thanks so much for clearing that up for me :D
    upload_2020-9-11_21-4-13.png
    Here's a little screenshot as thanks :)
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    fine!
     
  41. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    Hi Lars - I was wondering - is there an easy way to make the dynamic wetness work using local volumes as well as the global shader parameter? Do I just need to make wet variants of my materials - or is there something more complicated I could do using decals?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    right out of my head: no.
    you may try to use the local wetness settings to somehow override the globals on a per renderer basis using matrialpropertyblocks. but that needs you to write some scripts...
     
  43. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    roger that, thanks for responding!
     
  44. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    does area light has bug with the radius ? if i move it slightly the area light intensity wont change but if i slide it all way up its super bright ?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    i am not aware of any. please make sure that the point light radius is big enough to cover the area lit by the area light.
     
  46. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    Does area light works with unity standard shader? I want to only use the area light function and want to remove other files in lux is this possible ? using lux personal.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    depends. if you use forward it depends on the shader. so no.
    in deferred it depends on the lux deferred lighting shader. so it should work with the standard shader as well.
     
  48. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    i am using forward rendering.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    then you have to use the lux standard shader.
     
  50. Malkalypse

    Malkalypse

    Joined:
    Jan 13, 2017
    Posts:
    14
    Just downloaded this and when I open the example scenes I get the following error:

    Component GUI Layer in Main Camera for Scene Assets/Lux 2.02 Personal/Lux Demos/<Scene name>.unity is no longer available.
    It will be removed after you edit this GameObject and save the Scene.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Is there some setting or code I need to change, or extra files I need to download?