80 lines
2.2 KiB
Plaintext
80 lines
2.2 KiB
Plaintext
Shader "KernelPanic/stencil"
|
|
{
|
|
Properties
|
|
{
|
|
// _NoiseTex ("Noise Tex", 2D) = "black"
|
|
[HideInInspector]_MainTex ("Base (RGB)", 2D) = "white" {}
|
|
_GlitchBlendTex ("Glitch", 2D) = "black" {}
|
|
_NoiseTex ("Noise", 2D) = "black" {}
|
|
// [Range(0,1)] _Sample ("Sample", Float) = 0.5
|
|
}
|
|
SubShader
|
|
{
|
|
// No culling or depth
|
|
Cull Off ZWrite Off ZTest Always Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#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;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.uv = v.uv;
|
|
return o;
|
|
}
|
|
|
|
sampler2D _MainTex;
|
|
sampler2D _GlitchBlendTex;
|
|
sampler2D _NoiseTex;
|
|
sampler2D _CameraDepthTexture;
|
|
|
|
float _Sample;
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
// depth
|
|
float d = tex2D(_CameraDepthTexture, i.uv);
|
|
|
|
// sample frame
|
|
float4 c = tex2D(_MainTex, i.uv);
|
|
|
|
// sample noise
|
|
float2 scroll = float2(sin(_Time.y), cos(_Time.w));
|
|
float4 n = tex2D(_NoiseTex, i.uv + scroll);
|
|
|
|
// sample frame but with noise
|
|
float4 cn = tex2D(_MainTex, i.uv + n.xy);
|
|
|
|
// raw blended glitch used to blend between things
|
|
float4 g = tex2D(_GlitchBlendTex, i.uv);
|
|
|
|
// c = lerp(c,cn,g);
|
|
c = lerp(c,g,g);
|
|
|
|
return c;
|
|
// return tex2D(_CameraDepthTexture, i.uv);
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|
|
|