fix stencil pass

This commit is contained in:
2023-02-14 17:03:12 +01:00
parent da1837f00c
commit dd080ef541
8 changed files with 86 additions and 75 deletions

View File

@@ -1,21 +1,16 @@
Shader "Escape Room Engine/FullScreenDepth" {
Properties {
_PortalNumber ("Portal Number", Int) = 1
}
Properties {}
SubShader {
Pass
{
Pass {
ColorMask 0
Cull Off
ZWrite On
ZTest Always
Stencil
{
Ref [_PortalNumber]
Comp Equal // pass if equal
Pass Keep // keep stencil value
Fail Keep // keep stencil if depth fails
Stencil {
Ref 1
Comp LEqual
}
CGPROGRAM
@@ -23,18 +18,16 @@
#pragma fragment frag
#include "UnityCG.cginc"
void vert(appdata_img v, out float4 pos : SV_POSITION)
{
#ifdef UNITY_REVERSED_Z
void vert(appdata_img v, out float4 pos : SV_POSITION) {
#ifdef UNITY_REVERSED_Z // clip space [near 1, 0 far]
float far = 0.00001;
#else
#else // clip space [near -1, 1 far]
float far = 0.99999;
#endif
pos = float4(v.vertex.xy * 2.0, far, 1); // quad xy goes from -0.5 to 0.5, clip space from -1 to 1
}
fixed4 frag() : SV_Target
{
fixed4 frag() : SV_Target {
return 0;
}
ENDCG

View File

@@ -25,6 +25,6 @@ Material:
m_TexEnvs: []
m_Ints: []
m_Floats:
- _PortalNumber: 1
- _PortalNumber: 0
m_Colors: []
m_BuildTextureStacks: []

View File

@@ -1,23 +1,13 @@
Shader "Escape Room Engine/PortalStencil"
{
Properties
{
_PortalNumber ("Portal Number", Int) = 1
Shader "Escape Room Engine/PortalStencil" {
Properties {
_PortalNumber ("Portal Number", Int) = 0
}
SubShader
{
Tags
{
"RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"
}
SubShader {
Pass {
ColorMask 0 // don't draw this to the main framebuffer
Pass
{
ColorMask 0
Stencil
{
Stencil {
Ref [_PortalNumber]
Comp Always // always pass
Pass Replace // set stencil value