Skip to content

Commit 9f127bc

Browse files
Full procedural effect.
1 parent 01d50fb commit 9f127bc

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

radial_blur_2k18.shader

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
Shader "Radial Blur 2k18"
2+
{
3+
Subshader
4+
{
5+
Pass
6+
{
7+
CGPROGRAM
8+
#pragma vertex vertex_shader
9+
#pragma fragment pixel_shader
10+
#pragma target 3.0
11+
12+
struct structure
13+
{
14+
float4 vertex : SV_POSITION;
15+
float2 uv : TEXCOORD0;
16+
};
17+
18+
float hash(float3 n)
19+
{
20+
return frac(sin(dot(n, float3(95.43583, 93.323197, 94.993431))) * 65536.32);
21+
}
22+
23+
float noise(float3 n)
24+
{
25+
float3 base = floor(n * 64.0) * 0.015625;
26+
float3 dd = float3(0.015625, 0.0, 0.0);
27+
float a = hash(base);
28+
float b = hash(base + dd.xyy);
29+
float c = hash(base + dd.yxy);
30+
float d = hash(base + dd.xxy);
31+
float3 p = (n - base) * 64.0;
32+
float t = lerp(a, b, p.x);
33+
float tt = lerp(c, d, p.x);
34+
return lerp(t, tt, p.y);
35+
}
36+
37+
float fbm(float3 n)
38+
{
39+
float total = 0.0;
40+
float m1 = 1.0;
41+
float m2 = 0.1;
42+
for (int i = 0; i < 5; i++)
43+
{
44+
total += noise(n * m1) * m2;
45+
m2 *= 2.0;
46+
m1 *= 0.5;
47+
}
48+
return total;
49+
}
50+
51+
float heightmap (float3 n)
52+
{
53+
return fbm((5.0 * n) + fbm((5.0 * n) * 3.0 - 1000.0) * 0.05);
54+
}
55+
56+
float3 surface(float2 uv)
57+
{
58+
float color = clamp(heightmap(float3(uv.xy*5.0,2.0)*0.02)-1.0,0.0,1.0);
59+
if (color<0.1) return float3(0.35,0.40,0.44);
60+
else if (color<0.2) return float3(0.29,0.32,0.35);
61+
else if (color<0.3) return float3(0.20,0.21,0.22);
62+
else if (color<0.55) return float3(0.09,0.11,0.09);
63+
else if (color<0.65) return float3(0.18,0.19,0.14);
64+
else if (color<0.75) return float3(0.52,0.52,0.33);
65+
else if (color<0.85) return float3(0.45,0.37,0.27);
66+
else if (color<0.95) return float3(0.34,0.25,0.17);
67+
else if (color<0.99) return float3(0.59,0.34,0.29);
68+
else return float3(0.14,0.09,0.08);
69+
}
70+
71+
structure vertex_shader (float4 vertex:POSITION, float2 uv:TEXCOORD0)
72+
{
73+
structure vs;
74+
vs.vertex = UnityObjectToClipPos (vertex);
75+
vs.uv = uv;
76+
return vs;
77+
}
78+
79+
float4 pixel_shader (structure ps) : COLOR
80+
{
81+
float2 resolution = float2(1024,1024);
82+
float2 fragCoord = ps.uv*resolution;
83+
float2 p = (2.0*fragCoord-resolution)/resolution.y;
84+
float3 col = float3(0.0,0.0,0.0);
85+
float2 d = (float2(0.0,0.0)-p)/74.0;
86+
float w = 1.0;
87+
float2 s = p;
88+
for( int i=0; i<74; i++ )
89+
{
90+
float3 res = surface(float2(s.x+_Time.g,s.y)+sin(_Time.g)) ;
91+
col += w*smoothstep( 0.0, 1.0, res );
92+
w *= .985;
93+
s += d;
94+
}
95+
col = col * 4.5 / 74.0;
96+
return float4( col.xyz, 1.0 );
97+
}
98+
ENDCG
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)