You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
2.2 KiB
120 lines
2.2 KiB
3 years ago
|
// Colorful FX - Unity Asset
|
||
|
// Copyright (c) 2015 - Thomas Hourdel
|
||
|
// http://www.thomashourdel.com
|
||
|
|
||
|
Shader "Hidden/Colorful/Glitch"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||
|
}
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
ZTest Always Cull Off ZWrite Off
|
||
|
Fog { Mode off }
|
||
|
|
||
|
// Interference
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
|
||
|
#pragma vertex vert_img
|
||
|
#pragma fragment frag
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#include "UnityCG.cginc"
|
||
|
#pragma target 3.0
|
||
|
|
||
|
sampler2D _MainTex;
|
||
|
half3 _Params; // x: speed, y: density, z: maxDisplace
|
||
|
|
||
|
inline half rand(half2 seed)
|
||
|
{
|
||
|
return frac(sin(dot(seed * floor(_Time.y * _Params.x), half2(127.1, 311.7))) * 43758.5453123);
|
||
|
}
|
||
|
|
||
|
inline half rand(half seed)
|
||
|
{
|
||
|
return rand(half2(seed, 1.0));
|
||
|
}
|
||
|
|
||
|
half4 frag(v2f_img i) : SV_Target
|
||
|
{
|
||
|
half2 rblock = rand(floor(i.uv * _Params.y));
|
||
|
half displaceNoise = pow(rblock.x, 8.0) * pow(rblock.x, 3.0) - pow(rand(7.2341), 17.0) * _Params.z;
|
||
|
|
||
|
half r = tex2D(_MainTex, i.uv).r;
|
||
|
half g = tex2D(_MainTex, i.uv + half2(displaceNoise * 0.05 * rand(7.0), 0.0)).g;
|
||
|
half b = tex2D(_MainTex, i.uv - half2(displaceNoise * 0.05 * rand(13.0), 0.0)).b;
|
||
|
|
||
|
return half4(r, g, b, 1.0);
|
||
|
}
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
|
||
|
// Tearing
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
|
||
|
#pragma vertex vert_img
|
||
|
#pragma fragment frag_tearing
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#pragma target 3.0
|
||
|
|
||
|
#include "./Glitch.cginc"
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
|
||
|
#pragma vertex vert_img
|
||
|
#pragma fragment frag_tearing
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#pragma target 3.0
|
||
|
|
||
|
#define ALLOW_FLIPPING
|
||
|
#include "./Glitch.cginc"
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
|
||
|
#pragma vertex vert_img
|
||
|
#pragma fragment frag_tearing
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#pragma target 3.0
|
||
|
|
||
|
#define YUV_COLOR_BLEEDING
|
||
|
#include "./Glitch.cginc"
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
CGPROGRAM
|
||
|
|
||
|
#pragma vertex vert_img
|
||
|
#pragma fragment frag_tearing
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#pragma target 3.0
|
||
|
|
||
|
#define ALLOW_FLIPPING
|
||
|
#define YUV_COLOR_BLEEDING
|
||
|
#include "./Glitch.cginc"
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
}
|
||
|
|
||
|
FallBack off
|
||
|
}
|