-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathGlitchDigitalStripe.shader
More file actions
70 lines (49 loc) · 1.75 KB
/
GlitchDigitalStripe.shader
File metadata and controls
70 lines (49 loc) · 1.75 KB
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
//----------------------------------------------------------------------------------------------------------
// X-PostProcessing Library
// https://github.com/QianMo/X-PostProcessing-Library
// Copyright (C) 2020 QianMo. All rights reserved.
// Licensed under the MIT License
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
// http://opensource.org/licenses/MIT
//----------------------------------------------------------------------------------------------------------
//reference : https://github.com/keijiro/KinoGlitch
Shader "Hidden/X-PostProcessing/Glitch/DigitalStripe"
{
HLSLINCLUDE
#include "../../../Shaders/XPostProcessing.hlsl"
#pragma shader_feature NEED_TRASH_FRAME
TEXTURE2D_SAMPLER2D(_NoiseTex, sampler_NoiseTex);
uniform half _Indensity;
uniform half4 _StripColorAdjustColor;
uniform half _StripColorAdjustIndensity;
half4 Frag(VaryingsDefault i): SV_Target
{
// 基础数据准备
half4 stripNoise = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, i.texcoord);
half threshold = 1.001 - _Indensity * 1.001;
// uv偏移
half uvShift = step(threshold, pow(abs(stripNoise.x), 3));
float2 uv = frac(i.texcoord + stripNoise.yz * uvShift);
half4 source = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
#ifndef NEED_TRASH_FRAME
return source;
#endif
// 基于废弃帧插值
half stripIndensity = step(threshold, pow(abs(stripNoise.w), 3)) * _StripColorAdjustIndensity;
half3 color = lerp(source, _StripColorAdjustColor, stripIndensity).rgb;
return float4(color, source.a);
}
ENDHLSL
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
ENDHLSL
}
}
}