Search Unity

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

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

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    **EDIT : So after right-clicking the shaders and reimported them, both the pink and srp batcher issues are gone. Kind of weird though but eh! **

    I just bought Better Lit and tried to assign the shader to an existing HDRP object and it turns out pink. I'm on Unity 2020 LTS with HDRP 10.6

    There are no errors in the console so I wonder what could be wrong?

    upload_2021-10-12_14-38-0.png

    It also seems like the shaders are not compatible with SRP Batcher, can you confirm?
     
    Last edited: Oct 12, 2021
    mikeohc likes this.
  2. Skyfly

    Skyfly

    Joined:
    Jan 25, 2014
    Posts:
    110
    I am looking for a performant shader (movile VR) that needs to support a texture map on the color channel, fake reflections (environment images on reflection probe or anything that gives a similar effect) and lighing from environment lighting (no actual shadows needed). Will Better Lit Shaders be suited for that? Thanks!
     
  3. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    I recently got better lit shader and is wondering if it can generate a better result for what I'm trying to attempt.
    I want to have a more natural noise like below, but the noise generate in better lit is very unnatural.
    Screenshot (383).png Screenshot (384).png
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    There are several noise types available, and you should play with the scale and contrast of the noise to get something softer (looks like your amplitude is cranked so that things transition from 0 to 1 very fast).
     
    mikeohc likes this.
  5. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    I assigned my own noise textured and it worked perfectly. Thank you.
     
  6. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Can I do the equivalent of the standard cutout shader with BetterLit? I have some materials that use the cutout feature for edges, etc. I've tried around with BetterLit, but I can't get it done. Setting opacity to alpha just creates a strange look-through effect (probably the alpha shader on the texture isn't set up the way the shader expects?)

    Here are two pictures to show that effect, one with alpha on and one with full opacity. The wooden beams show through when I set alpha:

     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    there’s an alpha cut slider in the main texture layer..
     
  8. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Yes, I tried that. It has no effect on the see-through issue.

    Here is another screenshot showing the issue more clearly - it only affects the same mesh. Other meshes are hidden, but parts of the same mesh that are actually behind the first part (here the inside of the other side of the roof) are rendered above the part that should be in front, hiding it:




    Zoomed-out view for context:





    This is the texture used there. No alpha on the roof part (the top), only on the edges (the bottom), so the roof should be opaque, and when using the standard shader, it is:

     
    Last edited: Nov 20, 2021
  9. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Ohhookay ! I got it. Sorry for not getting what you were saying there.

    For others who have a similar issue: Setting Opacity to Opaque AND lifting the Alpha Clip Threshold just the tiniest bit away from 0 gets me the proper cutout effect.

    I also had to set "Alpha is Transparency" on the texture import to eliminate ugly edges. And that's it, works perfectly. Thanks!
     
    hopeful likes this.
  10. colin_young

    colin_young

    Joined:
    Jun 1, 2017
    Posts:
    243
    Will Better Lit Shader work at all with the Hybrid Renderer V2 (DOTS/ECS)? I understand that DOTS/ECS is experimental and do not expect that scenario is officially supported, but curious if some features will work.

    I do know that certain features of MicroSplat are not compatible, although I still get my terrain looking good enough for me, so it seems reasonable to assume something similar may be the case for this tool.

    Thanks in advance for any experiences anyone can share.
     
  11. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    Is there a guide somewhere on how to get this shader working with URP?

    I've installed the package, all I get from the shader is purple error colour.
     
  12. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Try right-clicking on the package and do a reimport (not reimport all) on it.
     
    G_Trex likes this.
  13. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    I've just uncovered how powerful the shader is when you access its values through code. Dynamically setting the image on a flag, or the value of damage using the texture overlay and noise.

    I'd like to have better documentation on the various properties and keywords. I'm reading them out of the shader right now, guessing at their function. Most are named appropriately and I got everything so far with just a few tries, but it would be really cool to have this properly documented. Ideal (for me) would be to have it in the tooltips in the editor, so that I can always check the shader and directly see what property/keyword I would have to use to code this element.
     
  14. G_Trex

    G_Trex

    Joined:
    Apr 20, 2013
    Posts:
    98
    Thanks, that worked!

    Great looking shader, particularly when paired with Beautify.
     
  15. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. I upgraded my project to 2021.2.5 coming from 2020.3.22f1.

    Is there a BetterLit Version for Unity 2021.2.5+ on the horizon?
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Submitted over a month ago- Unity is taking 50+ days to review assets now, so it's completely impossible to properly service SRPs when the delay between asset submission and release is basically about the same amount of time before they release a new SRP version and break everything again. Plus the minimum version will be 2021.2.6+ since they have crashing bugs in 2020.5 and below with the shader compiler.
     
  17. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    The biggest issue i have in 2021.2.5 ist that when i enable the Bakery checkbox

    on.JPG


    the checkbox always jumps to "off"

    off.JPG

    after scene save or save project.
    Save scene and save project has no influence anymore.
    The rendering is correct when enabled but it jumps to off automatically.

    Any idea if this is already fixed in the new pending BetterLit release?
     
    Last edited: Dec 8, 2021
  18. randy_mod

    randy_mod

    Joined:
    Dec 30, 2019
    Posts:
    1
    Will you add Surface scattering in better lit shader?My character skin looks not so good in hdrp2020.
     
  19. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Last edited: Dec 13, 2021
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
  21. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    ok that's fair. Is there plans for a way to convert standard unity materials to better lit? It is a ton of work to have to manually map maps for every material I already have in my project.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    It's not really possible to do reliably, since all 3 render pipelines have different conventions for materials that are incompatible with each other. Both in terms of texture packing and parameters.
     
  23. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    [Edit] See my post below for the solution.

    I'm also struggling as I just bought the asset for the built-in workflow. As it is said the map packing is similar to the one with HDRP I thought I could ge the substance plugin to generate the HDRP maps and use them in my materials. Do you think its achievable ?
    This and exporting from painter. For other texture sets I'll have to convert them manually with the utility I guess.

    Also the Discord link is not working on your store page.
     
    Last edited: Dec 14, 2021
  24. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    upload_2021-12-14_13-19-49.png
    It tried to import all the HDRP Runtime + HDRP Config + RP Core. HDRP Lit shader gets compiled by replacing all references to hdrp path in shaders, but the substance plugin does not seem to be happy. That is unfortunate.
     
    Last edited: Dec 14, 2021
  25. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    I finally get it to work, we had to select the LitTesselation shader. So now we can generate HDRP maps in our built-in pipeline.
    upload_2021-12-14_13-32-32.png
     
    Last edited: Dec 14, 2021
  26. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    85
    I bought your Better Lit Shader just for displacement effects (Tesselation option). Now I am stuck, as I do not understand what it needs to get the tesselation work, as it does not show up. I also used the Crack Free Processor, but any time I add a game object form the project window (FBX/OBJ), it does not generate a second copy of it and it says "mesh has no normals".

    I understand, that the tesselation is generated. But what does it need to work? I added a texture to the material, but that does not seem to be all which is necessary (except using the existing value rulers for configuration). I saw a "packed" texture in your demo scene - there it works -, but how do I generate this, or is it just a normal texture which I would need?

    I could not find the needed information anywhere. Don't get what I am doing wrong... :(:rolleyes:

    I am using Unity 2020.3.24f1 with the included URP Version. Thanks for an answer in advance.
     
  27. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    you need to use the texture packer to generate the heightmap into the Alpha channel.
    Check the manual for details

    Screenshot 2021-12-14 at 18.49.16.png
     
    jbooth likes this.
  28. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
  29. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
  30. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
  31. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You could try adding:

    Code (CSharp):
    1. mesh = Instantiate(mesh);
    at the top of the Process function in CrackFreeProcessor.cs. I think it doesn't like that it's an asset on disk already, instead of like a mesh in a FBX file would be.
     
  32. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Thank you, this worked. I'm really enjoying this shader. I am using world-based procedural noise but having an effect I don't like https://gyazo.com/6bc06592f37e989c68fc5b5bbfd1b5eb I thought it was a fade setting but it isn't.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    What are your noise settings?
     
  34. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
  35. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Does it happen with texture based noise? Or texture based on UV noise mode as opposed to world? Care to PM me a repro?
     
  37. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    It only happens with world based noise, regardless of whether it is texture or procedural. I guess I should mention I am using 2021.2.5f1
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Which render pipeline is this on? Although 2021.2 is not supported with that version of Better Lit I highly doubt that's the problem. My only thought is that if this is HDRP, the world position is computed relative to the camera, and perhaps some rounding error is causing the noise to give different results based on that calculation. That said, a repro case would be very useful.
     
  39. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi,

    Better Lit 1.2.19 in Unity 2021.2.6f1

    Before updating in my main Unity 2021.2.6f1 project i imported BetterLit to an empty HDRP project.

    The shaders went pink after import.
    After reimporting i get this. (screenshot)

    BL.JPG


    Should we wait on a new better lit version.
    e.g. Wind example is not working
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    SRP's are only supported on LTS releases, Unity breaks them too often to support on anything else.
     
  41. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Ok.
    But please check the bakery checkbox behaviour.
    Simply enable it on one shader of your example scene.
    After saving scene or project it will be disabled automatically.
    Same auto disable on the wind checkbox.

    All other features are in a workable state.
     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    This does not repro on a supported version of Unity. The whole point of not supporting beta/alpha/tech versions of Unity is not to spend all my time chasing down all the bugs they create in those versions, so yeah, not even going to look at it.
     
  43. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Im using HDRP. I'll try and send you a repro tomorrow. Really frustrating that unity is taking so long to review assets.
     
  44. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Got it and understandable.
    2021 will enter LTS during first half of 2022.

    Meantime.
    If you or someone else has an idea what cause the checkbox flags like wind or bakery to switch of after scene or project save.
    Give me a message. A dirty fix would be helpul to go on with my project port to 2021.2.x.
     
  45. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    I sent you a repo. You can pan the camera around the ground object included to see the visual errors.
     
    jbooth likes this.
  46. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    Everything is working great in 2021.2 now except the previously mentioned checkbox flags by @keeponshading
     
    keeponshading likes this.
  47. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Hi, I am trying to use texture layers to add emission to base layer and encounter problem. Since my model only has small parts that emit light, I setup uv1 for emission to save texture space. My current setup:
    Texture layer 1: Use as detail map to tile pattern
    Texture layer 2: Use for emission
    Layer weights: Vertex
    Blend mode: Alpha blended

    My problem is that I could not add emission without adding an Albedo map in the same texture layer(2). When I try to workaround and add an abledo map for that, I find that it does not respect the base layer metallic map(maybe other maps too, but metallic reflection is obvious to spot).

    What I want to achieve is to add an emission map without adding an abledo map to the texture layer. Could you help me?
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Fixed..
     
  49. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    Thank you. Very fast response. I will wait for the update.
     
  50. ght1875

    ght1875

    Joined:
    Jul 29, 2016
    Posts:
    32
    After update and try the texture layer 1 for emission blending, I encountered following bug:
    Shader error in 'Better Lit/Lit': Fragment program 'Frag': Unrecognized sampler 'sampler_layeralbedomap_ext_1' - does not match any texture and is not a recognized inline name (should contain filter and wrap modes).
    (on d3d11)

    Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL LIGHTPROBE_SH _LIGHTMAPMODE_STANDARD BAKERY_SHNONLINEAR _MASKMAP _LAYERVERTEXMASK _USELAYER_DEF_1 _LAYEREMISSION_DEF_1
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR