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

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    I can achieve the desired results other ways, such as using a TIF with no alpha but with transparency,

    upload_2021-8-7_15-25-31.png

    and with these map settings

    upload_2021-8-7_15-26-2.png

    and with these tint settings

    upload_2021-8-7_15-26-24.png

    But, again, the dark fringe can't seem to be avoided:

    upload_2021-8-7_15-26-44.png
     
  2. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Just to troubleshoot further, I've tried a 1bit image (back to 8bit to get the RGB channels) and even when there are no semi-transparent pixels, or grey pixels between white & black, the dark edges are still occuring.

    upload_2021-8-7_15-34-23.png

    upload_2021-8-7_15-34-38.png
     

    Attached Files:

  3. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Ok, here's a better way to frame this problem: I can achieve the desired result either by using a PNG with import alpha set to greyscale, or using a TIF with transparency and import set to Texture Alpha ... however, in any case, I'm finding that the mask needs to be white or black, no greys between, and the dark fringe doesn't seem to be avoidable, though it is a bit less with the TIF

    PNG:
    upload_2021-8-7_15-45-9.png

    TIF
    upload_2021-8-7_15-45-23.png

    So, I'm wondering if it's possible to achieve entirely smooth tinting, or partial tinting with greyscale in the channel rather than hard black / white.

    Thanks!
     
  4. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    I think the solution would be to get the opacity of the tint mask colors working. Currently, it seems semi transparent (grey) pixels of whatever channel we are using (R for example) are being darkened by the black of the other channels.
     
  5. abond-sd

    abond-sd

    Joined:
    Aug 4, 2021
    Posts:
    3
    I integrated the BetterLit shader into an existing project using 2021.2.0b4 and URP but the demo scene is all black in scene + game view and material previews are absent. It seems to be okay in a standalone project. I'm guessing there's some sort of shader error but I'm not seeing anything appear in the console or logs. There aren't any other custom shaders in the project. Any suggestions on how to debug this?

    P.S. the support link for the BetterLit package asset store page goes to the MicroSplat thread, not this one.
     
    Last edited: Aug 16, 2021
  6. abond-sd

    abond-sd

    Joined:
    Aug 4, 2021
    Posts:
    3
    It looks like the shader doesn't work with the Deferred Renderer option in URP. The materials are actually all invisible normally, they were only turning black when I had SSAO on.
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    as listed on the asset store, I only support LTS versions of SRP pipelines. If you want to use buggy beta versions your on your own, the SRPs are fundamentally unstable.
     
    hippocoder likes this.
  8. abond-sd

    abond-sd

    Joined:
    Aug 4, 2021
    Posts:
    3
    Understood, thanks Jason.
     
  9. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Hello Jason. I'm not sure if this is something you have control over, or whether it's a unity issue. FYI, when you select multiple materials and try to adjust their sliders, such as Smoothness Remap, Metallic Remap, etc ... it only effects the first material in the selected group.

    Further, since these values can't be entered manually or copy / pasted, it's quite a pain to try to get consistency between many materials.

    Example below: six materials selected, top two sliders adjusted, only first material changed.

    Cheers,
    Paul

    upload_2021-8-17_12-20-5.png
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    A bit clunky, but would likely work by adjust them in the debug inspector..
     
  11. sas67uss

    sas67uss

    Joined:
    Feb 8, 2020
    Posts:
    81
    Is better shader useful for mobile projects ? if yes , Do you have any recommendations and optimize settings for that ?
     
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820

    Hi Jason,

    could you please check the shadowmask problem on dynamic objects with BetterLit from quoted post.

    I tried to understand the issue but without sucess.
    However here some infos about shadowmask in general.
    Probably it helps
    https://catlikecoding.com/unity/tutorials/custom-srp/shadow-masks/
     
  13. RobertDAS

    RobertDAS

    Joined:
    Aug 19, 2021
    Posts:
    2
    EDIT 2: Nevermind, I had my materials mixed up :D Sorry for the confusion.
    -End Edit 2-

    EDIT: Looks like the property I want to set is _Tint. However, material.HasColor("_Tint") returns false at runtime on instance materials and material.SetColor( but returns true on the shared material.

    -End Edit-

    Hi Jason, I'm trying to change color at runtime, but I can't seem to find which shader property to modify. I'm looking for this:
    upload_2021-8-18_19-15-16.png
     
    Last edited: Aug 19, 2021
  14. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Yeah, I figured there might be a workaround or two like that. If you release an updated version and are able to add numeric value fields there, that'd allow copy & paste also, which would be an easier workaround.
     
  15. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi Jason,

    in addtion to Legacy and L1 probes in Bakery Shadowmask Mode i have the same problem with
    Bakery Volumes.

    Dynamic capsules have Better Lit with Volume enabled.
    There is the same tanline on dynamic objects i mentioned before.

    Posted it here in detail:

    https://forum.unity.com/threads/bak...preview-released.536008/page-110#post-7448906

    I would really need a fix here because all my dynamic objects with
    Better Lit
    and
    Unity Legacy Probes, Bakery L1 probes or Bakery volumes

    a rendered with this issue.
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    I really have no idea what this could be- there's no light probe code in any of my stuff, it's all inside HDRP include files (or inside the bakery code, which Frank wrote).
     
  17. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    I sent all the TestScenes in a clean project to Frank.
    When i switch from Better Lit to the HDRP Lit or the Bakery Graphs it is gone.
    It also happens without Bakery bake. PLM bake has same issues.
    2
    Frank said he has had an idea and gave you an hint what it "could" be.

    I can sent the Bakery test scenes to you, too.
    There is Better Lit and Bakery Asset integrated. Same i sent to Frank.

    Probably you can find and understand it when you fast toggle the scenes and shaders?
    These scenes and more are inside
    https://forum.unity.com/threads/the...urp-hdrp-standard.1088851/page-2#post-7372919

    These are the scenes
    Bakery and PLM variants with HDRP Lit or Better Lits from the same scene shown on the screenshots
    Unbenannt.JPG


    I could also show you the problem live with any desk connection if you have 5min of time these days.
     
    Last edited: Aug 27, 2021
  18. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    I love the "fast" texture packing and use it on all my assets. Only thing that sucks is it does not support metal maps. id be a nice option to have the blue channel be metal instead of AO. i'm doing more of a stylized game and its not as important.
     
  19. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    That's a possibility once I do the version for Unity 2021, which allows for more keywords. I could compute an AO approximation from the normal map.
     
  20. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
  21. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    606
    From reading the documentation it is not fully clear to me - maybe an oversight of me: is it possible to blend between a layer that uses UV coordinates and a layer that uses say world space coordinates with these shaders? I suppose so... but would like clarification before buying.
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Yes, each layer gets it's own settings for triplanar, world space, etc..
     
    Marco-Sperling likes this.
  23. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi Jason.

    In latest BetterLit 1.2.11 the tanline behaviour from dynamic capsules in shadowmask

    changed in rotation.


    1.2.10 -> tanline to the right

    BL_1_2_10.JPG

    1.2.11 -> tanline rotation around 90 degrees cw. Now facing to the viewer

    BL_1_2_11.JPG


    Does this probably help?

    As reference the same with HDRP Lit Shader as reference. No tanline at all.

    hdrplitt.JPG
     
    guycalledfrank likes this.
  24. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    additional some sideviews with different BetterLit Smoothness values.

    BetterLit Smoothness 0 -> tanline

    0.JPG

    BetterLit Smoothness 0.5 -> no tanline

    0.5.JPG

    BetterLit Smoothness 1 -> tanline visible again

    1.JPG



    vs HDRP Lit references with same smoothness values

    smoothness 0

    r.JPG

    HDRP Lit reference, smoothness 0.5

    l0.5.JPG
     
  25. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    HDRP Lit reference, smoothness 1

    l1.JPG
     
  26. passeridaepc

    passeridaepc

    Joined:
    Jun 16, 2019
    Posts:
    283
    Hi!
    Can someone please confirm or deny that the combination of HDRP + Bakery Volume + Shadowmasks do properly work and are supported?
    Thanks!
     
  27. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    No. It sholuld be supported but the Better Lit is not working with

    Shadowmask PLM Legacy Probes
    Shadowmask Bakery Legacy Probes
    Shadowmask Bakery L1 Probes
    Shadowmask Bakery Volumes

    I did around 20 simple test standard scenes for Frank and Jason
    but there seems to be no interest or posibility to solve this .)

    like
    https://forum.unity.com/threads/bak...preview-released.536008/page-110#post-7448906
    or all the posts in this thread.
     
  28. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    Ok this is a weird issue. After the recent update, when I go into playmode the tiling on the texter layer 0 gets multiplied by like a 1000. at first it looked like a shadow bias issue but with closer inspection i could see the texture was being tiled so much it was creating tiny details. When I stop playmode, the tiling goes back to the way it was set in the inspector.

    also im using triplaner UVs

    im on unity 2020.3.3 f1 URP 10.4 betterlit 1.2.11
     
  29. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    i think I have a theory. The object is scaled up, it looks like the object scale is not taken into account until runtime with triplanar.
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Is it local or world space triplanar?
     
  31. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi,

    Tracked it down to BakedDiffuseLighting.
    BetterLit with Shadowmask.and Volume ->not ok
    This line rotated 90 degrees CW on the capsule after update to latest BetterLit.
    When you reverse to older BetterLit versions the line rotatates back CCW to this position.
    So at least this rotation should be reproducable with your lates code changes. (1.2.10 <-> 1.2.11)

    3.JPG

    Arthurs BakeryVolumeSpecGraph ->ok
    4.JPG

    Excactly same issue in BetterLit for

    PLM Shadowmask with Legacy Probes,
    Bakery Shadowmask with L1 Probes
    Bakery Shadowmask with Legacy Probes
    and
    Bakery Shadowmask with Volumes

    Posted it here because it happens also with Unity Progressive Lightmapper.
     
    Last edited: Sep 4, 2021
  32. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    Yeah it's local. I should just apply the scale on the object, its minor really.
     
  33. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi Jason,

    Here s another BetterLit Baker question i posted in the Bakery Forum.

    The car interior is complete baked with the BetterLit, Shadowmask and Directional SH.

    When i enable Lightmap specular i get an strong overblow in specular. Shown at the steering wheel leather here.

    So, when this not a bug it would be cool to have an Lightmap specular intensity slider in the BetterLit.


    https://forum.unity.com/threads/bak...preview-released.536008/page-111#post-7481408

    to bring this specular intensity down
    https://forum.unity.com/threads/bak...preview-released.536008/page-111#post-7481471
     
    Last edited: Sep 11, 2021
  34. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    No idea, guy called frank does the bakery side..
     
  35. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Following up on this, I've also found that it's not possible to toggle on or off Tint Mask on multiple materials at once.

    We're working on a project which will involve hundreds of material variants with common values and not being able to modify groups of them in various ways together is actually enough of a problem that we'll need to re-assess whether we can use Better Lit. Any chance you can indicate whether these are issues you'll be able to address in a near-future update? Improving the ability for values to be modified / unified between multiple selected materials?

    Thanks!
     
    Last edited: Sep 17, 2021
  36. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    I don’t think unity’s editors even support multi material keyword editing, so no, not looking into it any time soon as it would add a ton of editor code. You can easily copy the keyword list between materials using the debug editor or via scripting.
     
  37. bluebrain

    bluebrain

    Joined:
    Jun 18, 2014
    Posts:
    29
    Thanks for the reply. I'm not sure what "keyword editing" refers to, but with other shaders I've not experienced these limitations of not being able to toggle or change settings on multiple materials at once. I'm experience these limitations to be unique to Better Lit, so far.
     
  38. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi. I have some problems mit Motion Blur.
    In my driven car innterior i get some trails on geometrys with the Better Lit.
    The HDRP Lit Standard renders ok.

    Are there some hidden or special motion vector settings?
    The effect is mostly visible with the Standard HDRP Motion Blur settings.​
     
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    I believe the standard lit shader enabled/disabled the motion buffer pass in some cases, and that setting would persist on the material if it was switched between shaders. You can see this in the disabled shader passes property using the debug inspector on your material.
     
    keeponshading likes this.
  40. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Hi Jason. Do you have an idea for a quick fix
    Hi Jason. Do you have an idea for an quick fix or enabling the motion buffer pass on the BetterLit again.

    I stated with HDPR Lit shaders in the interior and switched later to the Better Lit because of the Bakery features. I have an important presentation on monday and cannot switch back to the HDRP Lit without loosing lots of quality. A dirty hack would help me.
     
  41. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Yeah, go into the debug inspector and look at the disabled shader pass list and modify it for whatever you want..
     
  42. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
  44. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Thanks. I was able to repair it several minutes before show off.

    I removed the MotionVectors string in all BetterLit Remove Shader Passes..

    Is it ok to leave the fields empty or should i remove the field complete?
    Sometimes it is not at last position what requires some work.
    However it works in Player and Build with these empty fields.

    MV.JPG
     
  45. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Yeah, the HDRP Lit shader sets these for various reasons- I likely need to dig into it more and see why, since none of it is documented, then setup better lit to do the same or expose options for it. Don't think it matters if you remove the empty fields or not..
     
  46. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    • I imported the model which comes with default HDRP Lits.

    • Then i switched to to static to test bake the car.

    • Then i switched all my car interior material to better lit and rebaked with bakery options to get more quality.
    After that i switched to non static.

    I think therefore the MotionVector STRING is set up in the DisableShaderPasses.
    Because at the moment i converted the HDRP Lit to Better Lit it was static.


    For now think (not know) there a two reasons Unity is seting up the MotionVector Disable Shader Pass:

    1. static and non static setups toggles of the HDRP Lit. Not sure about that because static objects need motion vectors too.. Need more testing time.
    2. setup Precomputed Velocity flag the end of the HDRP Lit
      Indicates whether to use precomputed velocity information stored in an Alembic file.
      But i did not touch this one in HDRP Lit mode before converting to BetterLit.
     
    Last edited: Oct 4, 2021
  47. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    820
    Is it somehow possible to enable or to add the

    Standard HDRP Lit Geometric Specular AA in the Better Lit.
    It s very useful for all materials with low rougness.

    SAA.JPG
     
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Added, but uses the last possible shader keyword until 2021 becomes standard..
     
    keeponshading likes this.
  49. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    Yes, but they don't need to be rendered into the buffer based on the current and old vertex positions, which makes the shader more expensive. Only the old and new camera matrix's need to be used, because we know the current vertex positions haven't changed. This saves a lot of extra data being used in the shader.
     
    keeponshading likes this.
  50. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,118
    In Unity 2021, the shader keyword limit has been effectively removed, which is a primary limitation I have on feature counts in Better Lit Shader (and why MicroSplat is a shader generation system instead of just a simple shader). While I'll have to wait until 2021.3LTS to ship before I can do the SRP part of the upgrade, I'm starting work on some features ahead of time using the beta versions and built in pipeline. So far:

    - Converted MicroShadows, Fuzzy Shading, Alpha Threshold, and Layer Blend Modes (in the texture layers) to use keywords instead of static branches. While this type of branch is not costly on most GPUs, this will save some cycles on low end hardware or hardware which might execute the code in both copies of the branch.
    - Added support for a "Packed Metal" packing mode, which packs Metal into the normal texture where AO would normally be. I will also add an option to calculate AO from the normal analytically along with a strength slider, so you can still have some AO in this packing mode, just not one from a texture.
    - I'm experimenting with a 6 sided tint gradient mode, which is useful for stylized worlds (think Monument Valley on iOS). Essentially you can define a gradient (with a texture or gradient editor) for each axis as a Tint.
    - A set of unlit variants

    Any requests?
     
    hippocoder likes this.
unityunity