Created
October 24, 2018 10:35
-
-
Save lyuma/9e85634181585b5abe86fb7084771403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "LyumaShader/HideAllWithin" { | |
Properties { | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" "Queue" = "Transparent+2000"} | |
Cull Back | |
// To test: ColorMask R | |
ColorMask 0 | |
ZTest Always | |
ZWrite On | |
Pass { | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
// make fog work | |
#pragma multi_compile_fog | |
#include "UnityCG.cginc" | |
struct appdata { | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f { | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
v2f vert (appdata v) { | |
v2f o; | |
float4 objCamPos = mul(unity_WorldToObject, _WorldSpaceCameraPos); | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
float3 objCamPosAbs = abs(objCamPos.xyz); | |
if (all(objCamPosAbs < 1.)) { | |
o.vertex = float4(4.*saturate(v.vertex.xy)-1., 0., 1.); | |
} | |
o.uv = v.uv; | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target { | |
// ColorMask 0 causes frag to be ignored. | |
fixed4 col = float4(1.,1.,1.,1.); | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment