Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Help Wanted Question about transparency and rear faces

Discussion in 'Shader Graph' started by alanmthomas, Nov 8, 2019.

  1. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    I am working on a transparent shader and am coming across an issue I'm hoping there is an easy solution to that I am simply not aware of. I am fading an object, but would like to essentially take the opaque view of the object and fade that. The transparent view shows rear faces and other geometry that I'd prefer to be hidden. In the screen shot, you can see the orange bricks coming through. Some of them are on the back of the object. Does anyone have an ideas?
     

    Attached Files:

  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    396
    Sorry I'm not sure exactly what I'm looking at as it looks a bit abstract, but could you maybe use alpha clip to fade your objects? Then they would pretty much fade like opaque objects... Without sorting artifacts. But I'm not sure if that's the whole thing you are fading or what. It's usually better to show a clear example case.

    Could something like this work for you? (the fading object is the standard Unity sphere mesh)
    ditherfade_demo.PNG
     
  3. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    I think that is what I am talking about. Here are more clear example. First is the object rendered as opaque. Next the same view with transparency. In the transparent view, you can see the little rectangular shape showing through. This is what I'm hoping to avoid.
    Screen Shot 2019-11-08 at 1.19.09 PM.png Screen Shot 2019-11-08 at 1.19.23 PM.png
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    396
    Which renderer are you using? Standard, URP, HDRP? It would be good nowadays to tell that when posting graphics related issues as there's so many things done in different ways on different renderers.
     
  5. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    Good point. I'm using URP.
     
  6. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    396
    Try this graph, something similar should work. I just put it together quickly, so...
    Expose the parameter to interface. On HDRP you have to enable alpha clip in that gear (settings) menu of the Master node but I think URP had it by default visible, if I remember correctly.

    ditherfade.PNG
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,263
    if it is one single mesh you may try to enable depth write.
     
  8. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    Thanks for this. I'm thinking that I'm overcomplicating this. I eliminated the excess geometry and got something that is close to the effect I'm going for. Doing the alpha threshold dithering seems to work somewhat, but eliminating the geometry definitely gets the job done.
     
  9. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    How does one go about enabling that?
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,263
    when it comes to shader graph - hmm, get the shader code from the master node, create a new shader and paste it there.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,263
    but sorry, if it one mesh it won't work...
     
  12. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    160
    Okay. Thanks.