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

Question Preventing additive blending of transparent objects with shader graphs

Discussion in 'Shader Graph' started by FOXAcemond, Oct 13, 2020.

  1. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    Hello,

    I wrote a shader for transparent objects using this guide: https://mispy.me/unity-alpha-blending-overlap/

    I was wondering if something similar was possible with Shader Graph?

    The main idea is to prevent alpha overlap of objects with a given material:
     
    tonytopper and FunFreighterGames like this.
  2. Sukirii

    Sukirii

    Joined:
    Oct 14, 2020
    Posts:
    15
    I also look for this but can't find anything...
     
    tonytopper likes this.
  3. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    Hi, Has anyone found a solution? My line render lines with transparency additive look unappealing
     
    tonytopper likes this.
  4. chrisheld

    chrisheld

    Joined:
    Apr 15, 2013
    Posts:
    8
    I too am looking for a solution for this.

    Thank you,
    Chris
     
  5. zacharyaghaizu

    zacharyaghaizu

    Joined:
    Aug 14, 2020
    Posts:
    65
    I found a semi solution by using Scene Color instead of plugging in alpha. The only issue is that it obscures other transparent objects. At least it fixes the self overlapping transparency.
     
  6. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
    Same issue here. Have been avoiding learning HLSL cause I have too much to do. Would love a Shader Graph solution.

    TT_Screenshot 2023-01-13 205322.png
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    I'm going to try to put an end to this thread with some bad news.

    It's not possible.
     
    arkano22 likes this.
  8. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
    That's what I was beginning to feel was the case. :( Aka, it's not possible to do ... yet.

    It would be nice if Unity expanded Shader Graph to make this possible.

    As an aside, please send me any good book recommendations for learning HLSL.
     
  9. CptFlyAway

    CptFlyAway

    Joined:
    Sep 2, 2021
    Posts:
    2
  10. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
  11. AlphaLulz

    AlphaLulz

    Joined:
    Sep 2, 2019
    Posts:
    51
    Does anyone have access to the original shader? The link doesn't work anymore.
     
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Usual approach for this is to render all transparent objects to a render texture, then blend the render texture itself.
    Another way to do it is using the stencil buffer to ignore fragments that have already been rendered to the screen.

    Neither can be done using ShaderGraph alone.
     
  13. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
    StrangeWays777 likes this.
  14. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
    arkano22 likes this.
  15. renobozo

    renobozo

    Joined:
    Nov 22, 2021
    Posts:
    1
    Use Lerp node instead?
     
  16. GandalfGreyham

    GandalfGreyham

    Joined:
    Oct 25, 2021
    Posts:
    5
    I'm looking for this too.. I came up with a bad work around with a lot of limitations. I combined some different nodes mainly adding a blend node set to "negation" and then putting the opacity to 0.75 seems to work. The main issue is that if a third shape overlaps it creates uneven sections. There's also a faint edge visible in this example, but I bet that could be ironed out with some more fiddling.

    But in either case, there should be an easier solution!
     

    Attached Files: