-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAntiMirror_Camera.shader
107 lines (90 loc) · 3.96 KB
/
AntiMirror_Camera.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Shader "Frenetic/Anti Mirror&Camera"
{
Properties
{
[Enum(None, 4, Mirrors and Cameras , 0, Cameras, 1, Mirrors, 2, Player, 3)] _HideUIIn ("Hide UI In", Float) = 4
[Enum(None, 3, Both, 0, Cameras, 1, Mirrors, 2)] _RenderIn ("Render In", Float) = 3
[Toggle] _Blackout ("Blackout", Float) = 0
_BlackoutAmt ("Blackout Amount", Range(0, 1)) = 1
}
SubShader
{
Tags { "Queue"="Overlay+225375" }
Pass
{
ZTest Always
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DEFINE_INSTANCED_PROP(float, _RenderIn)
UNITY_DEFINE_INSTANCED_PROP(float, _VRChatCameraMode)
UNITY_DEFINE_INSTANCED_PROP(float, _VRChatMirrorMode)
UNITY_DEFINE_INSTANCED_PROP(float, _Blackout)
UNITY_DEFINE_INSTANCED_PROP(float, _BlackoutAmt)
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert(uint id : SV_VertexID)
{
v2f o;
float2 uv = float2((id << 1) & 2, id & 2);
o.vertex = float4(uv * 2 - 1, 1, 1);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
bool renderInCamera = UNITY_ACCESS_INSTANCED_PROP(_VRChatCameraMode_arr, _VRChatCameraMode);
bool renderInMirror = UNITY_ACCESS_INSTANCED_PROP(_VRChatMirrorMode_arr, _VRChatMirrorMode);
if (UNITY_ACCESS_INSTANCED_PROP(_Blackout_arr, _Blackout) >= 0.5)
return fixed4(0, 0, 0, UNITY_ACCESS_INSTANCED_PROP(_BlackoutAmt_arr, _BlackoutAmt));
if (UNITY_ACCESS_INSTANCED_PROP(_RenderIn_arr, _RenderIn) == 3) discard;
if (UNITY_ACCESS_INSTANCED_PROP(_RenderIn_arr, _RenderIn) == 0 && !(renderInCamera || renderInMirror)) discard;
if (UNITY_ACCESS_INSTANCED_PROP(_RenderIn_arr, _RenderIn) == 1 && !renderInCamera) discard;
if (UNITY_ACCESS_INSTANCED_PROP(_RenderIn_arr, _RenderIn) == 2 && !renderInMirror) discard;
return fixed4(0, 0, 0, 1);
}
ENDCG
}
// Hide UI
Pass
{
ZWrite On
Cull Off
Blend Zero One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
UNITY_DEFINE_INSTANCED_PROP(float, _HideUIIn)
UNITY_DEFINE_INSTANCED_PROP(float, _VRChatCameraMode)
UNITY_DEFINE_INSTANCED_PROP(float, _VRChatMirrorMode)
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert(uint id : SV_VertexID)
{
v2f o;
float2 uv = float2((id << 1) & 2, id & 2);
o.vertex = float4(uv * 2 - 1, 1, 1);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
bool renderInCamera = UNITY_ACCESS_INSTANCED_PROP(_VRChatCameraMode_arr, _VRChatCameraMode);
bool renderInMirror = UNITY_ACCESS_INSTANCED_PROP(_VRChatMirrorMode_arr, _VRChatMirrorMode);
if (UNITY_ACCESS_INSTANCED_PROP(_HideUIIn_arr, _HideUIIn) == 4) discard;
if (UNITY_ACCESS_INSTANCED_PROP(_HideUIIn_arr, _HideUIIn) == 0 && !(renderInCamera || renderInMirror)) discard;
else if (UNITY_ACCESS_INSTANCED_PROP(_HideUIIn_arr, _HideUIIn) == 1 && !renderInCamera) discard;
else if (UNITY_ACCESS_INSTANCED_PROP(_HideUIIn_arr, _HideUIIn) == 2 && !renderInMirror) discard;
return fixed4(0, 0, 0, 1);
}
ENDCG
}
}
}