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

The Better Lit Shader : Replacement Lit Shader for URP/HDRP/Standard

Discussion in 'Assets and Asset Store' started by jbooth, Apr 7, 2021.

  1. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Besides, when I try to use it as transparent glass shader, I find that I must use albedo texture's alpha channel. Can I just use the alpha value of the color set in the material inspector like standard shader?
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    windows shader compiler!!! Grrr..

    fixed..
     
  3. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Updated to 1.2.22. Still get the same error. Please check. I am using the standard pipeline on 2019.4.31f1.
     
    Last edited: Jan 6, 2022
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Did you clear your asset store cache before downloading? A ton of Unity versions have a broken package manager and say they download the latest, but give you an old version. You can verify that this is the new version by opening StackableTextureLayer and verifying that like 385 has _LAYEREMISSION at the end:

    #elif _LAYERNORMAL || _LAYERMASK || _LAYEREMISSION
     
  5. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Just deleted the cahce and re-download again, but the problem still persist.
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Does the code look like that though?
     
  7. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Yeah, it contains that line. I created an empty project to test and it did not work.
     
    Last edited: Jan 7, 2022
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, I'll have to poke around on my windows box and get it to throw the error - that should have fixed it, but clearly not..
     
    ght1875 likes this.
  9. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    I updated to Unity 2021.2.7 with BetterLit 1.2.22

    The checkbox flags are still reseted (to off) after scene and project save.

    - BetterLit says that amaterialproperty block is in use when i activate the Bakery checkbox.
    - The first scene play works fine.
    - The checkbox flag is then turned to off after scene save and project save.

    Could it be that the material propertyblock is responsible for switching the checkbox off?
     
  10. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Moving this over here, since your question is about BLS and not Bakery (and wanted to make sure it got caught

    As the page for BLS states:
    Since you're on Unity 2021.2.7, you're on an unsupported version.
     
  11. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Just wanted to know if someone has an quickfix for this behaviour.
    Only the Bakery checkbox is switched off after scene save and project save.

    Other checkboxes like Texture Layer 0 or others are not effected or switched off.

    I needed to port my project to Unity 2021.2.x and i could not wait if the LTS becomes available.

    Does the Better Shader 2021 version has the same issues?
    When not? Why is it not possible to generate the BetterLit Asset from the Better Shader 2021?

    Everything else i use from the BetterLit is working fine in 2021.2.7.
    Texture LAyers and all Baker features after bake.
    Only the switching of the bakery checkbox during scene and project save is the problem.

    Could someone give me some tips to generate a script with a list of materials who is switching on the Bakery checkbox on scene start. This would help to till the LTS support becomes available.
     
    Last edited: Jan 12, 2022
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I don't use material property blocks, so that would be something in your project doing that.

    The 2021 version of Better Lit Shader is available from my website- UAS version should be out in the next few days.
     
    keeponshading likes this.
  13. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Is it possible to install the new BetterLit 2021 1.0.0 package
    in the Unity 2021.2.7 project and overwrite the old
    BetterLit 1.2.22 integration without hassle?

    Because I have over 150+ BetterLit materials inside this would be really important.
     
    Last edited: Jan 14, 2022
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You can just remove the old one and install the new one- your materials should link up with the new version fine. Note that there is a converter to help with some of the settings changes, as the new keyword limit allowed me to do a lot of things as keywords instead of branches.
     
  15. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi Jason.
    in Unity 2021.2.8, Better Lit 2021 1.0
    • i removed the BetterLit 1.2.22 package
    • imported the BetterLit 2021 1.0.0 package
    • upgraded all BetterLit materials

    update_2021_BL_03.jpg


    -> after this i get same behaviour as mentioned before

    The Bakery checkbox flags are still reseted (to off) after scene and project save.

    - The first scene play works fine when i enable the Bakery checkbox in the BetterLit
    - The checkbox flag is then turned to off after every scene save and project save.
     
    Last edited: Jan 17, 2022
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I fixed this and uploaded a new build - it's available on my site, but I suspect unity will release it this week.
     
  17. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    I encountered another problem. I find that better lit shader does not work with realtime gi. Just create an empty scene with a plane, a cube and a spotlight. Assign the 3d objects with better lit material, realtime gi does not work. Switching back to standard shader material, then it works. It can be verified with viewport Lit Clustering mode. I am using 2019.4.31f1. This is an urgent problem for me. Please help.
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    What render pipeline? And can you PM me a repro scene as I have no idea what light/project settings you're using?
     
  19. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    I have PM the scene to you. I am using the built-in pipeline. About the previous problem on texture layer blending for emission, I test again and it works now. Thank you.
     
  20. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    Hello

    I have a bug to report.

    I am currently getting this error :

    Code (CSharp):
    1. Maximum number (64) of shader local keywords exceeded, keyword GEOM_TYPE_FROND will be ignored.
    2. You will have to delete some shaders or make them use less keywords.
    3. Keywords used in project now: _SNOWMASKMAP _WIND_ON _LAYERTRIPLANAR_DEF_2 _DISSOLVE _LAYERNORMAL_DEF_1 _LAYERMASK_DEF_2 GEOM_TYPE_LEAF _NOISEWORLEY _DETAILTRIPLANAR _NOISEWORLD _LAYERTRIPLANAR _SIMPLELIT _LAYERANGLEFILTER_DEF_2 _PARALLAX _NOISETEXTURE _PUDDLENOISE _LAYERANGLEFILTER _LAYERNORMAL _SNOWSTOCHASTIC _RAINDROPS _NORMALMAP _MASKMAP _LAYERALBEDO_DEF_2 _LAYERNOISE_DEF_2 _DETAILSTOCHASTIC _LAYERANGLEFILTER_DEF_1 _NOISEHQ _LAYERTRIPLANAR_DEF_1 LOD_FADE_CROSSFADE _USELAYER_DEF_2 _LAYEREMISSION _SNOW _PACKEDFAST _EMISSION _SPECULAR _LAYERALBEDO _FLATSHADE _PUDDLES _TRIPLANAR _DEBUG_SAMPLECOUNT _LAYERSTOCHASTIC_DEF_1 _LAYERTEXTUREMASK _SNOWNOISE _NOISELOCAL _DETAIL _LAYERNOISE _LAYERSTOCHASTIC_DEF_2 _USELAYER _SURFACEGRADIENT _LAYEREMISSION_DEF_1 _TINTMASK _USELAYER_DEF_1 _LAYERNORMAL_DEF_2 _AUTONORMAL _LAYERALBEDO_DEF_1 _LAYERMASK_DEF_1 _LAYERSTOCHASTIC _TRAX_ON _LAYERVERTEXMASK _WETNESS _LAYERMASK _LAYERNOISE_DEF_1 _STOCHASTIC _LAYEREMISSION_DEF_2
    4.  

    I've had the issue for a while, so today I decided to pull my project apart and try to pin down the cause. I only get the error when the Better Lit Shader asset is installed.

    I think the error only began after I updated the asset. It seemed fine before.

    The main consequence of this error is that my lightmaps won't bake.

    I'm using 2020.2 URP.
     
    Last edited: Jan 25, 2022
  21. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Better Lit Shader only supports URP in 2019.4 or 2020.3 (and 2021.2 if using the 2021 version). If your in 2020.2, it would fall back to the 2019.4 version, but if Unity added an additional keyword in 2020.2, that could push it over the keyword limit..
     
  22. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    I have a 2020.3 copy of the project as well, but I still get the error in that one too.

    Update : I also converted the project to another release of 2020.3 just to see if it was just an issue with the latest LTS, but I still get the error.
     
    Last edited: Jan 26, 2022
  23. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ok, I'll see if can repro it - likely need to remove a keyword from the shader somehow.
     
  24. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    OK. Thank you.
     
  25. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    I find that tesellation does not work with relatime gi. It can be reproduced by enabling tesellation and rebake the scene. Please check.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    This is a unity issue- if you use Unity's example tessellation surface shader, it will exhibit the same issue.
     
  27. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    No pressure intended, but have you had time to look at reducing the shaders local keywords?
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Shipped like a week ago.
     
  29. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    Thanks! It looks like it just got added today (Version 1.2.26 - February 08, 2022).

    Frustratingly, I still get the error though.

    I even created a blank project in 2020.3 URP, added nothing but the Better Lit Shader. Changed one of the sample scene materials to use it ; the console gives me the same error when I try to bake the light map.

    I may just have to wait for 2021 LTS. I don't get the error when using the current 2021, though I get a bunch of other issues with it still just being in Alpha.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So I just repro'd this- what is really odd is that it's saying the keyword GEOM_TYPE_LEAF is used, but that keyword doesn't appear anywhere in the shader or in any of the materials. Further, the shader is using 63 keywords in total, not including the GEOM_TYPE_LEAF one.

    So further investigation, I find that if I delete the puddles object in the scene, the issue goes away. If I delete and recreate its material and put it on the cube that shows off puddles, it comes back. If I delete the cube and the material, and recreate them both, then it doesn't come back.

    So this seems like some kind of Unity error. For now, try deleting the puddles object and it's material from your project and see if it suddenly works fine?
     
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Ah, so it's the static flag that's doing it. Pretty sure this is a Unity bug, or it's a bug with the wrong error information getting displayed at least. I filed it with Unity, we'll see what they say.
     
  32. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    Well, hurray for it not just being me at least. I was getting concerned that my project had just become warped somehow. :)

    Yep, can confirm that if I unmark everything as static, the problem goes away.
     
  33. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Thanks for the update adding dynamic gi support for tesellation in builtin rendering pipeline. I do not need to have dummy mesh for gi calculation now.

    I would like to make another feature request about transparent material:
    1. Tint color alpha affetcts transparency
    2. Supporting shadow sampling for transparent material in builtin rendering pipeline
    reference:
    https://forum.unity.com/threads/no-shadows-visible-on-transparency-shaders.9909/page-3#post-4778408
    https://forum.unity.com/threads/no-shadows-visible-on-transparency-shaders.9909/page-3#post-4914971
     
    Last edited: Feb 10, 2022
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    1. Yeah, tint has an alpha channel, which gets multiplied against your texture. So set it to 1 if you don't want it to effect the alpha.
    2. I'm not going to modify built in to support features Unity doesn't support (though in the last case I fixed a bug they had)
     
  35. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    I see. Thank you.
     
  36. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    HI.
    Do you have some compatibilty infos for Unity 2021 and Better Lit 2021 after switching Editor to DX12 and using common HDRP Raytracing AO, Reflections, Shadows, RT GI ....

    In the way what is supported and what not when i compare the BetterLit with the HDRP Lit.

    e.g. in the office sample from
    https://github.com/Unity-Technologies/HDRPRayTracingScenes
     
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Better Lit supports everything but raytracing..
     
  38. rockin

    rockin

    Joined:
    Dec 11, 2013
    Posts:
    26
    Hello! Thank you for the awesome shaders!
    I've got two issues to report with Unity 2021.2.10, URP Forward:

    1) After upgrading to Better Lit 2021, "Alpha Clip Threshold" doesn't seem to work anymore with Opacity set to "Opaque".
    The non-2021 of the shaders work fine. I did delete the old version and I did press "Do it!" in the upgrader script.

    These are the keywords extracted from debug mode, if it helps:
    BAKERY_SHNONLINEAR _ALPHACUT _LAYERBLENDMULT2X _LIGHTMAPMODE_STANDARD _NORMALMAP _SNOW _WETNESS

    RenderType is set to TransparentCutout.

    I deleted my ShaderCache folder just to be sure, but it hasn't affected the result.

    2) This is happening with both the 2021 and non-2021 shaders. At a certain rotation, point lights cast a square shadow onto flat surfaces. It's almost like two of the 6 sides of the point light cube are casting a shadow. If I rotate the light, the shadow can disappear. It doesn't happen with the standard URP lit shader. Here's a picture:

    upload_2022-2-13_23-38-4.png

    If I rotate the spot light, the shadow moves on the other wall:

    upload_2022-2-13_23-38-55.png

    I've fiddled with all shadow settings on the light, but only disabling the shadows completely will get rid of the artifact: upload_2022-2-13_23-41-15.png

    Both issues happen with old and newly created materials.
    Hope this helps!
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    First one is fixed - could you PM me a repro of the second?
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    BTW- direct GitHub access is now available for Better Shaders and Better Lit Shader (both versions) via the discord server (register your invoice, get access)
     
    keeponshading likes this.
  41. rockin

    rockin

    Joined:
    Dec 11, 2013
    Posts:
    26
    Hi,
    I attached a sample project exhibiting the issue, Unity 2021.2.10.

    What I did:
    1) Create a project with the URP template.
    2) Import BLS.
    3) Hit re-import all (clear library cache) because for some reason the shaders were pink.
    4) Add two boxes and a light in SampleScene.

    Re: GitHub, I messed up with the bot :) I'll write more details on Discord.
     

    Attached Files:

  42. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Unbenannt2.JPG Hi,

    is there a way to speed up

    Unbenannt.JPG



    Tthe compiling of the Better Lit Shader variants takes around 2h 15min on an HighEnd workstation with 2x RTX3090?
    e.g. the Better Lit/Forward runs for around 20min.

    in Unity 2021.2.11f1
    and
    Unity 2020.3.17f1

    I use the latest BetterLit and BetterLit 2021.
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yeah, wait until Unity fixes the bugs in 2021.2 (it's logged, the shader compiler is broken, and another example of why doing production on tech releases is not a great idea). Also your graphics card has no part in compiling shaders.
     
    rockin likes this.
  44. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Thanks. You are so right.

    I am still in Unity 2020.3.17 LTS but
    i try to get everthing work in 2021. Thought it is a good time to start.
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    This thread is now effectively closed. Support for my products will no longer be provided through Unity's forums.
     
  46. ndtmivn123

    ndtmivn123

    Joined:
    Aug 2, 2021
    Posts:
    1
    upload_2022-11-8_18-21-43.png
    When I building to mobile (android)
    All the shaders that use Better Lit are Blue like it.
    I don't know why ??
     
  47. colin_young

    colin_young

    Joined:
    Jun 1, 2017
    Posts:
    243
    You will have better luck getting support on Discord. The link is on the asset store product page for Better Lit Shaders.
     
    ndtmivn123 likes this.
  48. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    It would be great if changing from LayeredLit or LayaredLitTessellation would not remove all textures assignments. Or provide an automated way to convert existing materials to BetterLit. Otherwise it's quite unusable on existing projects.

    Also, just so you know:
    • Tesselation renders black on URP (Unity 2021.3.23)
    • Ticking more than two layers spams the following error in the console
    Code (CSharp):
    1. Enabling local keyword '_LAYERBLENDMULT2X_DEF_2' for Material 'MM_Terrain_EV_C3' has been skipped. This keyword cannot be enabled directly.
    2. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    3. JBooth.BetterLit.LitBaseStub:DoTextureLayer (UnityEditor.MaterialEditor,UnityEditor.MaterialProperty[],JBooth.BetterLit.LitBaseStub/Packing,int) (at Packages/com.jbooth.better-lit-shader/Scripts/Editor/EditorStub.cs:1657)
    4. JBooth.BetterLit.LitBaseMaterialEditor:OnGUI (UnityEditor.MaterialEditor,UnityEditor.MaterialProperty[]) (at Packages/com.jbooth.better-lit-shader/Scripts/Editor/LitBaseMaterialEditor.cs:66)
    5. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    6.  
     
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It doesn't remove anything - Unity just has no standardization across their shaders, which are different in all render pipelines, including requiring different texture packing formats, different parameterizations, etc. And writing a converter from all their different shaders to any standardized one would be nightmarish - they don't even upgrade from their own shaders correctly between the pipelines, and they've been working on that for several years. So why people expect a solo dev to do what Unity cannot even do with all their resources is beyond me. The SRP nightmare is entirely of their creation.

    The spew is a new unity bug they introduced in the LTS branch, reported, repro'd, fixed, then bounced because the fix didn't work.
     
  50. andreyefimov2010

    andreyefimov2010

    Joined:
    Oct 29, 2017
    Posts:
    44
    Would be nice to have the ability to change ZTest on the material. That would be helpful for the first-person items to avoid clipping by setting ZTest to Always in the pass block.
     
    Last edited: Jun 11, 2023