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

    iano7

    Joined:
    May 9, 2017
    Posts:
    2
    Captur2e.JPG
    why i am getting too much reflation.
    how to increase roughness in lux skin shader ?
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    smoothness comes from the alpha of the main texture.
     
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    [Deleted post; issue was not caused by Lux]
     
    Last edited: Jan 4, 2019
  4. allornothingJM

    allornothingJM

    Joined:
    Feb 3, 2015
    Posts:
    20
    Just wondering about the Lux Area Lights - I switched to Lux Area Lights from the tube lights used in the Adam/volumetric demo a while back, but one feature I miss is the shadow planes the Adam lights came with (allowing rudimentary control of shadows - essentially limiting the angles of the point light, but not actually shadow casting lights). The Lux Lights look far superior, but in a set up of needing many on screen at a time, shadow casting is not an option. The shadow planes would have been very very useful here - is there any way to do such a thing?

    (From the Adam Docs https://github.com/Unity-Technologies/VolumetricLighting :
    • Tube lights don't have proper shadows, but each one can have two ShadowPlanes. Shadow planes cut off the light's influence and have a controllable feather. )
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    s nice feature indeed. but it is currently not on my list, sorry.
     
  6. LOCOrailroad

    LOCOrailroad

    Joined:
    Mar 3, 2019
    Posts:
    6
    How to combine skin with tesselation in one model?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    just try. never thought about this.
     
  8. LOCOrailroad

    LOCOrailroad

    Joined:
    Mar 3, 2019
    Posts:
    6
    any suggestions?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    look into the tess shader and combine it with the skin shader.
     
  10. LOCOrailroad

    LOCOrailroad

    Joined:
    Mar 3, 2019
    Posts:
    6
    If only any attempt didn't result in unhelpful error messages. Part of the problem is that there's no just tess shader, only a big tess+weather+diffuse-scattering, hard to isolate what exactly are necessary tess parts. Suggestions?
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    first of all: what do you need tessellation for?
    the only reason i could think of would be phong tessellation or smoothing. i do not see how displacement would help in any way...

    next: how would you deal with cracks?
    talking about skin i think of a head which most likely will have some uv seems.

    apart from this: you do not need any lux tessellation features to just do phong tessellation.
    so you may simply take the example from unity's documentation: https://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html

    then you would add the code from the surface function of the skin shader. the only thing that does not work oiut of the box should be using "IN.blendState" – as surface tessellation shaders does not allow to create custom input structures. either skip it or write it to eg. o.color.
     
  12. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    I have a small question about Lux Plus, and the usage of the Lux Plus DepthNormal internal shader replacement. I've tried with it installed and uninstalled, and I frankly can't see any visual difference. It looks like the shader just uses DecodeOctahedronNormal() in the case of skin normals. and another method for everything else.

    I guess what I'm asking is, what does this shader replacement do exactly, is it just faster than the internal shader, or is t adding some feature, or what? Other than telling you to install it, it's purpose really isn't explained.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    good question :)
    actually i did not know that i even included such a shader... it has a been a long time since the initial release.
    lux plus is all about deferred rendering. and the DepthNormal shader is only used when doing forward rendering.
    you need depth and normals e.g. when doing ssao.

    so i guess you can simply skip it.
     
    ceebeee likes this.
  14. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    LOL ok, well at least I know now :)
     
  15. Evgenius

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    21
    Is Lux working with Unity 2019 LWRP?
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    nope. lux only supports the "legacy" rendering pipeline.
     
  17. Evgenius

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    21
    Pity :(. Will there be any update to support it or not planned?
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    i have no plan to update it, sorry.
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    hi there,
    i started to add a customers' showcase. first entry is the upcoming "This land is my land". enjoy.

    s01.jpg

    01_showcase.jpg
     
    no00ob, ryschawy, TerraUnity and 6 others like this.
  20. marggob

    marggob

    Joined:
    Feb 24, 2013
    Posts:
    65
    Hey.
    In the description of the asset it is written that the translucency works in deferred mode. But when you try to enable deferre mode, we get this result.
    Forward 2019-05-24_09-58-13.png
    Deferred 2019-05-24_09-57-57.png
    Are we doing something wrong or is it supposed to be?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    you have to assign the lux plus deferred lighting and reflection shaders to make it look correctly.
     
    NeatWolf likes this.
  22. marggob

    marggob

    Joined:
    Feb 24, 2013
    Posts:
    65
    Thank you for your prompt response. Now everything works correctly. :)
     
  23. funbites

    funbites

    Joined:
    Oct 9, 2015
    Posts:
    17
    Is Unity 2019 supported?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    have not tested - but why not?
     
  25. funbites

    funbites

    Joined:
    Oct 9, 2015
    Posts:
    17
    I think they changed how #include works, but I'm not sure. It's giving an error that cginc files are not found.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    which one?
     
  27. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Hi, I want to add some extra of visual umph to my game, so I'd like to know if Lux will look better than Standard shaders (more on par with HDRP?).
    Also, I'm interested in commercial branch. Will Lux Plus, at some point in time, get upgraded to HDRP or its legacy forever?

    Also, will it break my decal system?
    I'm using gbuffer to draw those, and using data from it. (I guess I can test that with free version)
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    lux and lux plus are somewhere between legacy and hdrp.
    most features of lux plus are already in hdrp. so except for dynamic weather there is no need to bring lux to hdrp.
    the free version uses the regular gbuffers. so all should be fine.
    lux plus brings translucent, skin and anisotropic lighting to deferred and uses a custom gbuffer layout.
    if you limit your decals to only be placed on top of standard materials it should be fine as well. translucent, skin and anisotropic materials would need tweaks.
     
    xVergilx likes this.
  29. mashar80

    mashar80

    Joined:
    Oct 2, 2017
    Posts:
    6
    I am having a very strange error while assigning the First pass shader for terrain; iam using the free version download from GitHub in unity 2018.3.8, all of the errors i have fixed but cant seem to get rid of the following error:

    In short: Unexpected identifier "Lux". Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct or a user-defined type

    Full Context from console: Shader error in 'Lux/Standard Lighting/Nature/Terrain/Standard': Unexpected identifier "Lux". Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct or a user-defined type at .../Lux Core/Lux Features/LuxDynamicWeather.cginc

    This error is occuring on all the terrain shaders;

    Standard Terrain AddPass / Standard Terrain Base / Standard Terrain FirstPass, but is coming only on the shaders in the Lux custom Standard Shaders.

    Can you please help me out if possible to check what might be the reason and possible solution to get this fixed, i have tried almost everything possible under my little knowledge of shaders.

    Thanks in advance
    Reagrds,
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    answered via email already...
     
  31. mashar80

    mashar80

    Joined:
    Oct 2, 2017
    Posts:
    6
    Sorry to bother you on this so much. But i didn't got any email from your side.... i am still waiting :).

    Regards,
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    not sure what i did... but here we go:

    unity changed the shader compiler during the – i can’t remember x cycle.
    so to initialize a custom struct you have to use the hlsl syntax.
    attached you will find a new LuxStructs.cginc which should do the trick.
    best, lars

    (you have to download and then rename it from .zip to .cginc)
     

    Attached Files:

    mashar80 likes this.
  33. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Hey, there!

    Does your system work on Speedtree 8? I need this solution to work with Deferred render in order to make leaf translucent
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
  35. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    So about your Advanced Terrain Grass, can I use my own mesh and make them interact with my character?
    I do own your Advanced Foliage Shaders v.5 but it wasn't as expected yet still do some job for me. Need to be sure about this one too
     
    Last edited: Jul 14, 2019
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    yes. you have to bake proper bending information into vertex color alpha tho.
    this feature does not come out of the box and you will have to add it yourself. pleashave a look at the atg forum where this is discussed:
    https://forum.unity.com/threads/released-advanced-terrain-grass.494865/page-4#post-3333972
     
  37. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Okay I think I have a bit of faith in this asset
    By the way is it possible that your grass might look like this (optional need) and does it have better performance than Unity terrain grass.
    Spend money on several assets and always disappointed. I hope this is the last time I will appreciated
     

    Attached Files:

  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    atg supports some kind of approximated and faked speculr highlights. so: yes.
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    it removes the spikes on the cpu but usually is a bit heavier on the gpu.
    but when using all its optimizations (2 step culling, compute shaders) atg can catch up.
     
  40. coding_kyle

    coding_kyle

    Joined:
    Oct 5, 2015
    Posts:
    2
    I'm wondering if anyone can point me in the right direction. I'm using Lux Plus and want to customize the lighting so the brightness of multiple lights gets clamped to a certain level. So if one light is already bright enough, adding more lights will not cause the lighting to get blown out / become brighter and more white.

    If I could clamp the color values for each object to their texture albedo values, that could act as the top end for the lighting and then they would just fade out if lighting was dimmer. I've been diving into the Lux source for longer than I care to admit and can't seem to work my head around how to do this.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    i haven't tried, but i think it is impossible. in deffered lighting gets accumulated additively in the lighting buffer. and the light currently rendered does not know about the value already in the buffer. this would need the lighting shader read and write from and into the same buffer at the same time which is not supported on many platforms (like dx11).
    further more it would only read the final image and not only the lighting. so it would not be able to distinguish between:
    a) dark albedo and bright lighting and b) bright albedo and dark lighting. not to mention specular highlights...

    but using hdr and proper tone mapping settings should almost already prevent the final image from being blown out – doesn't it?
     
  42. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    Are the shaders lighter/faster than the unity standard ones in 2018+ versions? Using the built-in pipeline.
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    nope. they extend the built in features.
     
  44. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Have anyone figured out how to add terrain instancing to the Lux (Plus) shader version?

    Edit: Ok, literally 5 minutes later I've managed to get it working, in Lux TerrainSplatmapCommon.cginc you need to find and modify SplatmapVert like this:

    Code (CSharp):
    1. #if defined(UNITY_INSTANCING_ENABLED) && !defined(SHADER_API_D3D11_9X)
    2.     sampler2D _TerrainHeightmapTexture;
    3.     sampler2D _TerrainNormalmapTexture;
    4.     float4    _TerrainHeightmapRecipSize;   // float4(1.0f/width, 1.0f/height, 1.0f/(width-1), 1.0f/(height-1))
    5.     float4    _TerrainHeightmapScale;       // float4(hmScale.x, hmScale.y / (float)(kMaxHeight), hmScale.z, 0.0f)
    6. #endif
    7.  
    8. UNITY_INSTANCING_BUFFER_START(Terrain)
    9.     UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainPatchInstanceData) // float4(xBase, yBase, skipScale, ~)
    10. UNITY_INSTANCING_BUFFER_END(Terrain)
    11.  
    12. void SplatmapVert(inout appdata_full v, out Input data)
    13. {
    14.     UNITY_INITIALIZE_OUTPUT(Input, data);
    15.  
    16. #if defined(UNITY_INSTANCING_ENABLED) && !defined(SHADER_API_D3D11_9X)
    17.     float2 patchVertex = v.vertex.xy;
    18.     float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);
    19.  
    20.     float4 uvscale = instanceData.z * _TerrainHeightmapRecipSize;
    21.     float4 uvoffset = instanceData.xyxy * uvscale;
    22.     uvoffset.xy += 0.5f * _TerrainHeightmapRecipSize.xy;
    23.     float2 sampleCoords = (patchVertex.xy * uvscale.xy + uvoffset.xy);
    24.  
    25.     float hm = UnpackHeightmap(tex2Dlod(_TerrainHeightmapTexture, float4(sampleCoords, 0, 0)));
    26.     v.vertex.xz = (patchVertex.xy + instanceData.xy) * _TerrainHeightmapScale.xz * instanceData.z;  //(x + xBase) * hmScale.x * skipScale;
    27.     v.vertex.y = hm * _TerrainHeightmapScale.y;
    28.     v.vertex.w = 1.0f;
    29.  
    30.     v.texcoord.xy = (patchVertex.xy * uvscale.zw + uvoffset.zw);
    31.     v.texcoord3 = v.texcoord2 = v.texcoord1 = v.texcoord;
    32.  
    33.     #ifdef TERRAIN_INSTANCED_PERPIXEL_NORMAL
    34.         v.normal = float3(0, 1, 0); // TODO: reconstruct the tangent space in the pixel shader. Seems to be hard with surface shader especially when other attributes are packed together with tSpace.
    35.         data.tc.zw = sampleCoords;
    36.     #else
    37.         float3 nor = tex2Dlod(_TerrainNormalmapTexture, float4(sampleCoords, 0, 0)).xyz;
    38.         v.normal = 2.0f * nor - 1.0f;
    39.     #endif
    40. #endif
    41.  
    42.     data.tc_Control = TRANSFORM_TEX(v.texcoord, _Control);    // Need to manually transform uv here, as we choose not to use 'uv' prefix for this texcoord.
    43.     float4 pos = UnityObjectToClipPos (v.vertex);
    44.     UNITY_TRANSFER_FOG(data, pos);
    45.  
    46. //#ifdef _TERRAIN_NORMAL_MAP
    47.     v.tangent.xyz = cross(v.normal, float3(0,0,1));
    48.     v.tangent.w = -1;
    49. //#endif
    50.  
    51.     // Calc Tangent Space Rotation
    52.     //float3 binormal = cross( v.normal, v.tangent.xyz ) * v.tangent.w;
    53.     //float3x3 rotation = float3x3( v.tangent.xyz, binormal, v.normal.xyz );
    54.     // Store FlowDirection
    55.     //data.lux_flowDirection = ( mul(rotation, mul(_World2Object, float4(0,1,0,0)).xyz) ).xy;
    56.     // Store world position and distance to camera
    57.     float3 worldPosition = mul(unity_ObjectToWorld, v.vertex);
    58.     data.lux_worldPosDistance.xyz = worldPosition;
    59.     data.lux_worldPosDistance.w = distance(_WorldSpaceCameraPos, worldPosition);
    60. }
    And in Standard Terrain Base / Standard Terrain AddPass / Standard Terrain FirstPass you need to add instancing pragmas:
    Code (CSharp):
    1. #pragma multi_compile_instancing
    2. #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
    And also, its necessary to add instance id's to the appdata struct and vert functions.
     
    Last edited: Aug 31, 2019
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    xVergilx likes this.
  46. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Last edited: Oct 13, 2019
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    which version of unity?
     
  48. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    2019.2.0f1
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,911
    ah, it might be the terrain engine / lightmapper which does not set proper uvs... i had this in URP.
    have you checked the built in terrain shader?
     
    xVergilx likes this.
  50. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Yes, built-in maps those correctly.

    Here's a comparison:
    Lux Plus + Baked
    upload_2019-10-13_21-29-24.png

    Standard built-in baked (looks crappy, but no hard dark artifacts everywhere, those are just low settings):
    upload_2019-10-13_21-31-22.png

    Standard built-in realtime (Emission is caused by someone thinking emission is good for every game, which is a bug in SplatmapCommon.cginc that never got fixed. That one is also present in the Lux shader btw by default):
    upload_2019-10-13_21-33-29.png

    Standard one looks bad because its bad plus low res, but it doesn't have a seam / dark hard issue / baking artifacts.

    I think something is missing in the shader, or something probably has changed during version changes.