Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

How to remove show-through textures in URP?

Discussion in 'Universal Render Pipeline' started by Krabicz, Apr 12, 2021.

  1. Krabicz

    Krabicz

    Joined:
    Oct 5, 2016
    Posts:
    5
    Unity 2020.3.3f1,

    How to get rid of this show-through on material? I have already tried all shader graph settings and of course opaque works but it's not good for me here because then I can't get character oclussion for characters. Also checked "is front face" on shader graph - didn't worked. I have tried removing UV nodes, played with alfa channel - nothing. Any ideas? problemTextures.jpg
     
  2. AzurySimon

    AzurySimon

    Joined:
    Jul 16, 2018
    Posts:
    34
    You are using a transparent shader (in your graph settings, "Surface" is set to "Transparent"). Transparent shaders to not write to the Z-Buffer, and since the individual triangles in a mesh can render in any order. You get the effect you can see here, because some faces get rendered after some other faces, even when they are behind.
    Try setting your shader to "Opaque", especially if your mesh does not need transparency. If you want transparency on some parts of your mesh, you could either try to use alpha clipping on an opaque shader, or split your mesh into transparent and opaque parts and assign transparent and opaque shaders/materials respecively.
     
    Krabicz likes this.
  3. Krabicz

    Krabicz

    Joined:
    Oct 5, 2016
    Posts:
    5
    Thank you for replying! Changing shader to opaque helps partially but then creates different problem - once shader is opaque it always renders in front of transparent background and changing rendering priority doesn't matter because opaque is rendered later anyway. I will try to post later some additional image setup with frame rendering screenshot. Currently I'm fooling around shader graph to make it work with different depth based on object position but it feels like a hack (not that i care that much, as long as performance is good).
     
  4. AzurySimon

    AzurySimon

    Joined:
    Jul 16, 2018
    Posts:
    34
    I don't really know the context of your game here.. Transparent objects are rendered later in the pipeline, but they still test against the depth buffer (even thought they do not write to it), so this kind of sorting should still work properly unless you are somehow not arranging objects from near to far.
     
  5. Krabicz

    Krabicz

    Joined:
    Oct 5, 2016
    Posts:
    5
    Rendering order -> pr4, pr3, pr2 (setup by trial and error, probably messed up. Idea was to render Height Map first, then compare with character shader with contain height for character what should be clipped and what not, and also render "final scene environment").

    pr5 pr6 - materials for Height Map (simple shader graph) and Final map.

    Changing player to opaque causes rendering character on top so it doesn't work for me now.

    There's most likely something fundamentaly wrong with the way am rendering but I don't know how to exactly think about it and what to change.
     

    Attached Files:

    • pr2.png
      pr2.png
      File size:
      776.9 KB
      Views:
      12
    • pr3.png
      pr3.png
      File size:
      705 KB
      Views:
      13
    • pr4.png
      pr4.png
      File size:
      453.3 KB
      Views:
      13
    • pr5.png
      pr5.png
      File size:
      447.3 KB
      Views:
      13
    • pr6.png
      pr6.png
      File size:
      435.7 KB
      Views:
      12
  6. AzurySimon

    AzurySimon

    Joined:
    Jul 16, 2018
    Posts:
    34
    A bit hard to tell, but to me it looks like an issue with the spatial arrangement of what you want to render.
    Did you make sure your materials are using the correct render queue value (2000 for opaque, 3000 for transparents)? I had some trouble with that in the past, where shader graph materials did not properly update their queue value after switching between opaque and transparent.
    Other than that you could try to play around with sorting groups, sorting layers, althrough I do not know if those will work correctly outside the 2D sprite/UI context.
     
unityunity