Skip to content

Commit 231ae9b

Browse files
committed
Unity 2022.3.22f1 shaders Plus.
1 parent 0c73544 commit 231ae9b

25 files changed

+677
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

22
.idea/
3+
export/

CGIncludes/PlusStuff.cginc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ShingenPizza's Secret Shader Sauce. More info in README.txt .
2+
// Contains code by Hirabiki, the creator of VRCLens.
3+
4+
#ifndef SHINGENPIZZA_PLUS_STUFF
5+
#define SHINGENPIZZA_PLUS_STUFF
6+
7+
float _VRChatCameraMode;
8+
float _VRChatMirrorMode;
9+
10+
float _VRC_Limited_Visibility;
11+
float _VRC_Visible_Normal;
12+
float _VRC_Visible_Camera;
13+
float _VRC_Visible_VRCLens;
14+
float _VRC_Visible_Screenshot;
15+
float _VRC_Visible_Mirror;
16+
float _VRC_Visible_Mirror_Camera;
17+
float _VRC_Visible_Mirror_VRCLens;
18+
float _VRC_Visible_Mirror_Screenshot;
19+
20+
21+
void check_visibility()
22+
{
23+
if (!_VRC_Limited_Visibility) { return; }
24+
25+
if (_VRChatCameraMode == 0 || _VRChatCameraMode == -1) { // _VRChatCameraMode == -1 is looking at it in the Unity editor
26+
// Hirabiki's code, checking for being rendered in VRCLens
27+
#ifndef USING_STEREO_MATRICES
28+
if (abs(unity_CameraProjection._m11 - 1.73205) > 0.00001 // If it's not 60.000 degree camera
29+
&& (_ScreenParams.y / _ScreenParams.x == 0.5625 || _ScreenParams.y / _ScreenParams.x == 1.125) // And is 16:9 or 8:9 (3D)
30+
) {
31+
if (_VRChatMirrorMode == 0) { if (!_VRC_Visible_VRCLens) { discard; } }
32+
else { if (!_VRC_Visible_Mirror_VRCLens) { discard; } }
33+
}
34+
else
35+
#endif
36+
{
37+
if (_VRChatMirrorMode == 0) { if (!_VRC_Visible_Normal) { discard; } }
38+
else { if (!_VRC_Visible_Mirror) { discard; } }
39+
}
40+
}
41+
else if (_VRChatCameraMode == 1 || _VRChatCameraMode == 2) {
42+
if (_VRChatMirrorMode == 0) { if (!_VRC_Visible_Camera) { discard; } }
43+
else { if (!_VRC_Visible_Mirror_Camera) { discard; } }
44+
}
45+
else if (_VRChatCameraMode == 3) {
46+
if (_VRChatMirrorMode == 0) { if (!_VRC_Visible_Screenshot) { discard; } }
47+
else { if (!_VRC_Visible_Mirror_Screenshot) { discard; } }
48+
}
49+
}
50+
51+
#endif // SHINGENPIZZA_PLUS_STUFF
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_CORE_INCLUDED
46
#define UNITY_STANDARD_CORE_INCLUDED
57

@@ -13,6 +15,9 @@
1315
#include "UnityStandardBRDF.cginc"
1416

1517
#include "AutoLight.cginc"
18+
19+
#include "PlusStuff.cginc"
20+
1621
//-------------------------------------------------------------------------------------
1722
// counterpart for NormalizePerPixelNormal
1823
// skips normalization per-vertex and expects normalization to happen per-pixel
@@ -427,6 +432,8 @@ VertexOutputForwardBase vertForwardBase (VertexInput v)
427432

428433
half4 fragForwardBaseInternal (VertexOutputForwardBase i)
429434
{
435+
check_visibility();
436+
430437
FRAGMENT_SETUP(s)
431438

432439
UNITY_SETUP_INSTANCE_ID(i);
@@ -520,6 +527,8 @@ VertexOutputForwardAdd vertForwardAdd (VertexInput v)
520527

521528
half4 fragForwardAddInternal (VertexOutputForwardAdd i)
522529
{
530+
check_visibility();
531+
523532
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
524533

525534
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
@@ -630,6 +639,8 @@ void fragDeferred (
630639
#endif
631640
)
632641
{
642+
check_visibility();
643+
633644
#if (SHADER_TARGET < 30)
634645
outGBuffer0 = 1;
635646
outGBuffer1 = 1;

CGIncludes/UnityStandardCoreForward.cginc renamed to CGIncludes/UnityStandardCoreForward Plus.cginc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_CORE_FORWARD_INCLUDED
46
#define UNITY_STANDARD_CORE_FORWARD_INCLUDED
57

@@ -10,13 +12,13 @@
1012
#include "UnityStandardConfig.cginc"
1113

1214
#if UNITY_STANDARD_SIMPLE
13-
#include "UnityStandardCoreForwardSimple.cginc"
15+
#include "UnityStandardCoreForwardSimple Plus.cginc"
1416
VertexOutputBaseSimple vertBase (VertexInput v) { return vertForwardBaseSimple(v); }
1517
VertexOutputForwardAddSimple vertAdd (VertexInput v) { return vertForwardAddSimple(v); }
1618
half4 fragBase (VertexOutputBaseSimple i) : SV_Target { return fragForwardBaseSimpleInternal(i); }
1719
half4 fragAdd (VertexOutputForwardAddSimple i) : SV_Target { return fragForwardAddSimpleInternal(i); }
1820
#else
19-
#include "UnityStandardCore.cginc"
21+
#include "UnityStandardCore Plus.cginc"
2022
VertexOutputForwardBase vertBase (VertexInput v) { return vertForwardBase(v); }
2123
VertexOutputForwardAdd vertAdd (VertexInput v) { return vertForwardAdd(v); }
2224
half4 fragBase (VertexOutputForwardBase i) : SV_Target { return fragForwardBaseInternal(i); }

CGIncludes/UnityStandardCoreForwardSimple.cginc renamed to CGIncludes/UnityStandardCoreForwardSimple Plus.cginc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_CORE_FORWARD_SIMPLE_INCLUDED
46
#define UNITY_STANDARD_CORE_FORWARD_SIMPLE_INCLUDED
57

6-
#include "UnityStandardCore.cginc"
8+
#include "UnityStandardCore Plus.cginc"
79

810
// Does not support: _PARALLAXMAP, DIRLIGHTMAP_COMBINED
911
#define GLOSSMAP (defined(_SPECGLOSSMAP) || defined(_METALLICGLOSSMAP))
@@ -197,6 +199,8 @@ half3 BRDF3DirectSimple(half3 diffColor, half3 specColor, half smoothness, half
197199

198200
half4 fragForwardBaseSimpleInternal (VertexOutputBaseSimple i)
199201
{
202+
check_visibility();
203+
200204
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
201205

202206
FragmentCommonData s = FragmentSetupSimple(i);
@@ -349,6 +353,8 @@ half3 LightSpaceNormal(VertexOutputForwardAddSimple i, FragmentCommonData s)
349353

350354
half4 fragForwardAddSimpleInternal (VertexOutputForwardAddSimple i)
351355
{
356+
check_visibility();
357+
352358
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
353359

354360
FragmentCommonData s = FragmentSetupSimpleAdd(i);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_META_INCLUDED
46
#define UNITY_STANDARD_META_INCLUDED
57

@@ -9,7 +11,7 @@
911
#include "UnityCG.cginc"
1012
#include "UnityStandardInput.cginc"
1113
#include "UnityMetaPass.cginc"
12-
#include "UnityStandardCore.cginc"
14+
#include "UnityStandardCore Plus.cginc"
1315

1416
struct v2f_meta
1517
{
@@ -53,6 +55,8 @@ half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness)
5355

5456
float4 frag_meta (v2f_meta i) : SV_Target
5557
{
58+
check_visibility();
59+
5660
// we're interested in diffuse & specular colors,
5761
// and surface roughness to produce final albedo.
5862
FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);

CGIncludes/UnityStandardParticleEditor.cginc renamed to CGIncludes/UnityStandardParticleEditor Plus.cginc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_PARTICLE_EDITOR_INCLUDED
46
#define UNITY_STANDARD_PARTICLE_EDITOR_INCLUDED
57

@@ -13,6 +15,8 @@
1315
#include "UnityStandardUtils.cginc"
1416
#include "UnityStandardParticleInstancing.cginc"
1517

18+
#include "PlusStuff.cginc"
19+
1620
#ifdef _ALPHATEST_ON
1721
half _Cutoff;
1822
#endif
@@ -88,12 +92,16 @@ void fragSceneClip(VertexOutput i)
8892

8993
half4 fragSceneHighlightPass(VertexOutput i) : SV_Target
9094
{
95+
check_visibility();
96+
9197
fragSceneClip(i);
9298
return float4(_ObjectId, _PassValue, 1, 1);
9399
}
94100

95101
half4 fragScenePickingPass(VertexOutput i) : SV_Target
96102
{
103+
check_visibility();
104+
97105
fragSceneClip(i);
98106
return _SelectionID;
99107
}

CGIncludes/UnityStandardParticleShadow.cginc renamed to CGIncludes/UnityStandardParticleShadow Plus.cginc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_PARTICLE_SHADOW_INCLUDED
46
#define UNITY_STANDARD_PARTICLE_SHADOW_INCLUDED
57

@@ -16,6 +18,8 @@
1618
#include "UnityStandardUtils.cginc"
1719
#include "UnityStandardParticleInstancing.cginc"
1820

21+
#include "PlusStuff.cginc"
22+
1923
#if (defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)) && defined(UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS)
2024
#define UNITY_STANDARD_USE_DITHER_MASK 1
2125
#endif
@@ -142,6 +146,8 @@ half4 fragParticleShadowCaster (
142146
#endif
143147
) : SV_Target
144148
{
149+
check_visibility();
150+
145151
#ifdef UNITY_STANDARD_USE_SHADOW_UVS
146152
half alpha = tex2D(_MainTex, i.texcoord).a;
147153
#ifdef _FLIPBOOK_BLENDING

CGIncludes/UnityStandardParticles.cginc renamed to CGIncludes/UnityStandardParticles Plus.cginc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_PARTICLES_INCLUDED
46
#define UNITY_STANDARD_PARTICLES_INCLUDED
57

@@ -15,6 +17,8 @@
1517
#include "UnityPBSLighting.cginc"
1618
#include "UnityStandardParticleInstancing.cginc"
1719

20+
#include "PlusStuff.cginc"
21+
1822
// Particles surface shader has a lot of variants in it, but some of those do not affect
1923
// code generation (i.e. don't have inpact on which Input/SurfaceOutput things are read or written into).
2024
// Surface shader analysis done during import time skips "completely identical" shader variants, so to
@@ -368,6 +372,8 @@ void vertParticleUnlit (appdata_particles v, out VertexOutput o)
368372

369373
half4 fragParticleUnlit(VertexOutput IN) : SV_Target
370374
{
375+
check_visibility();
376+
371377
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
372378
half4 albedo = readTexture (_MainTex, IN);
373379
albedo *= _Color;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
22

3+
// Modified by ShingenPizza. More info in README.txt .
4+
35
#ifndef UNITY_STANDARD_SHADOW_INCLUDED
46
#define UNITY_STANDARD_SHADOW_INCLUDED
57

@@ -12,6 +14,8 @@
1214
#include "UnityStandardConfig.cginc"
1315
#include "UnityStandardUtils.cginc"
1416

17+
#include "PlusStuff.cginc"
18+
1519
#if (defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)) && defined(UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS)
1620
#define UNITY_STANDARD_USE_DITHER_MASK 1
1721
#endif
@@ -164,6 +168,8 @@ half4 fragShadowCaster (VertexOutput input
164168
#endif
165169
) : SV_Target
166170
{
171+
check_visibility();
172+
167173
UNITY_SETUP_INSTANCE_ID(input);
168174

169175
#if defined(UNITY_STANDARD_USE_SHADOW_UVS)

0 commit comments

Comments
 (0)