Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Having problems with Shader clipping

Discussion in 'Shaders' started by Disson4nce, Mar 2, 2020.

  1. Disson4nce

    Disson4nce

    Joined:
    Feb 21, 2019
    Posts:
    3
    So I made a shader for a project I'm working on.
    The shader is supposed to have a dissolving effect, where it uses clip() with a noise texture.
    This works perfectly, like shown here
    dissolve1.png

    But where my problem is, is that the project uses ambient occlusion. And with ambient occlusion, it creates a problem when the material is "fully dissolved". The game object doesn't become completely transparent and sort of removes shadows when viewed through the material
    dissolve2.png

    Is there a way to still make the shader fully transparent with ambient occlusion, or is that impossible?
     
  2. Adurnha

    Adurnha

    Joined:
    Feb 28, 2019
    Posts:
    7
    I had a similar issue and solved it by changing the render queue from "From Shader" to "Transparent" in the material the shader is applied to.

    You can also change it directly in the shader, and keep it to "From shader" in the material.
     
    Last edited: Mar 2, 2020
  3. Disson4nce

    Disson4nce

    Joined:
    Feb 21, 2019
    Posts:
    3
    Unfortunately that didn't seem to fix the problem
     
  4. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    If you have the same problem when using shadows, it might be the (default) shadow pass. Is this a surface shader? If so, add addshadow to the #pragma surface surf Standard fullforwardshadows line.
     
  5. Disson4nce

    Disson4nce

    Joined:
    Feb 21, 2019
    Posts:
    3
    I already had. But that didn't change anything sadly
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
    The problem is SSAO sometimes uses the camera normals texture. For deferred rendering that'll pull directly from the gbuffers and be perfect. But for forward rendering Unity uses a replacement shader pass, so you'd need to set the RenderType tag on your shader to something unique, then make a copy of the Internal-DepthNormalsTexture.shader and add a new pass that does the same cutout as your shader, and set that new shader to be what Unity uses in the Graphics settings.