@@ -18,31 +18,38 @@ Shader "Hidden/X-PostProcessing/Glitch/ImageBlockV4"
18
18
uniform half4 _Params;
19
19
#define _Speed _Params.x
20
20
#define _BlockSize _Params.y
21
- #define _MaxOffsetX _Params.z
22
- #define _MaxOffsetY _Params.w
21
+ #define _MaxRGBSplitX _Params.z
22
+ #define _MaxRGBSplitY _Params.w
23
23
24
24
25
25
inline float randomNoise (float2 seed)
26
26
{
27
- return frac (sin (dot (seed * floor (_Time .y * _Speed), float2 (127.1 , 311.7 ))) * 43758.5453123 );
27
+ return frac (sin (dot (seed * floor (_Time .y * _Speed), float2 (17.13 , 3.71 ))) * 43758.5453123 );
28
28
}
29
29
30
-
31
30
inline float randomNoise (float seed)
32
31
{
33
32
return randomNoise (float2 (seed, 1.0 ));
34
33
}
35
34
36
- float4 Frag (VaryingsDefault i) : SV_Target
35
+ half4 Frag (VaryingsDefault i) : SV_Target
37
36
{
38
- float2 block = randomNoise (floor (i.texcoord * _BlockSize));
39
- float OffsetX = pow (block.x, 8.0 ) * pow (block.x, 3.0 ) - pow (randomNoise (7.2341 ), 17.0 ) * _MaxOffsetX;
40
- float OffsetY = pow (block.x, 8.0 ) * pow (block.x, 3.0 ) - pow (randomNoise (7.2341 ), 17.0 ) * _MaxOffsetY;
41
- float4 r = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
42
- float4 g = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord + half2 (OffsetX * 0.05 * randomNoise (7.0 ), OffsetY*0.05 *randomNoise (12.0 )));
43
- float4 b = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord - half2 (OffsetX * 0.05 * randomNoise (13.0 ), OffsetY*0.05 *randomNoise (12.0 )));
44
-
45
- return half4 (r.x, g.g, b.z, (r.a + g.a + b.a));
37
+ half2 block = randomNoise (floor (i.texcoord * _BlockSize));
38
+
39
+ float displaceNoise = pow (block.x, 8.0 ) * pow (block.x, 3.0 );
40
+ float splitRGBNoise = pow (randomNoise (7.2341 ), 17.0 );
41
+ float offsetX = displaceNoise - splitRGBNoise * _MaxRGBSplitX;
42
+ float offsetY = displaceNoise - splitRGBNoise * _MaxRGBSplitY;
43
+
44
+ float noiseX = 0.05 * randomNoise (13.0 );
45
+ float noiseY = 0.05 * randomNoise (7.0 );
46
+ float2 offset = float2 (offsetX * noiseX, offsetY* noiseY);
47
+
48
+ half4 colorR = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
49
+ half4 colorG = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord + offset);
50
+ half4 colorB = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord - offset);
51
+
52
+ return half4 (colorR.r , colorG.g, colorB.z, (colorR.a + colorG.a + colorB.a));
46
53
}
47
54
48
55
ENDHLSL
0 commit comments