QingYu Mu
QingYu Mu

Reputation: 11

How to Achieve See-Through Effect in Unity URP

I am using Unity 2022.3.16f with the URP, and I want to create an effect where you can see through object A to object B, as shown in the attached image:

img1

img2

Here is the shader code for object A:

Shader "Custom/Mask"
{
    Properties{}
 
    SubShader{
        Tags {
            "RenderType" = "Opaque"
        }
 
        Pass {
            ZWrite Off
        }
    }
}

The Universal Render Data settings:

img3

However, I am encountering an issue where object B is still visible through object A even when object B is in front of object A, which is not the desired effect:

img4

img5

What I want to achieve is that the parts of object A behind other objects should not be written into the Stencil Buffer. I'm looking for any suggestions or alternative solutions to achieve this effect.

For reference, I have been following this tutorial: https://theslidefactory.com/see-through-objects-with-stencil-buffers-using-unity-urp/ .

Upvotes: 1

Views: 341

Answers (0)

Related Questions