Search Unity

Use transparency on stencil

Discussion in 'Shaders' started by Rengifs, Apr 8, 2021.

  1. Rengifs

    Rengifs

    Joined:
    Apr 20, 2020
    Posts:
    2
    Hello!

    I have a problem with Stencil.
    I saw this blog and tried to do the same to use it on a 3D card . :D

    https://bdts.com.au/tips-and-resour...s-with-the-universal-render-pipeline-urp.html

    I create "Renderer Feature" that I attribute to layers. One for the items I want hidden and another for my window that will show them.

    *Renderer Features for Hidden Objects*
    Captudre.PNG

    *Renderer Features for windows*
    Capture.PNG


    Unfortunately, I have a problem because my "windows" to see hidden objetcs do not work on transparent elements. :confused:
    All the elements with transparency (particles or assets with transparent material) disappear.


    Stencil Problem.gif


    I guess the problem is with my "windows" shader


    I
    Code (CSharp):
    1. Shader "Custom/StencilMask"
    2. {
    3.  
    4. Properties{}
    5.  
    6. SubShader{
    7.  
    8. Tags {
    9. "RenderType" = "Opaque"
    10. }
    11. Pass{
    12. ZWrite Off
    13.  
    14. }
    15. }
    16. }
    I know that my render type is not transparent but the problem is that I am a beginner to shader and I don't know what to put ^^ '
    I tried to replace it with

    Code (CSharp):
    1. Tags {
    2. “Queue”=“Transparent”
    3. “RenderType” =“Transparent”
    4. }
    But that did not work :(

    If anyone has an idea ^^ '
     
    Last edited: Apr 8, 2021
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    I'm not a specialist but:
    It looks like you are rendering "Hidden Objects" AfterRenderingTransparent.
    This effectively overwrites your transparent particle. (Try not transparent they will probably be on top)

    BTW: If I were you I would probably try different approach than stenciling.
    Render to texture comes to my mind.
    The second idea I got is more complicated.
     
  3. Rengifs

    Rengifs

    Joined:
    Apr 20, 2020
    Posts:
    2
    Thank I will check ^^