-
Notifications
You must be signed in to change notification settings - Fork 7
/
frag.glsl
37 lines (30 loc) · 1 KB
/
frag.glsl
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
#extension GL_OES_standard_derivatives : enable
varying vec3 vNorm;
varying vec2 vUv;
uniform float iGlobalTime;
uniform sampler2D iChannel0;
#define TEXEL_SIZE 1.0/512.0
vec3 sample(vec2 uv);
#pragma glslify: blur = require('glsl-hash-blur', sample=sample, iterations=10)
#pragma glslify: halftone = require('glsl-halftone')
#pragma glslify: checker = require('glsl-checker')
vec3 sample(vec2 uv) {
return texture2D(iChannel0, uv).rgb;
}
void main() {
//the checker box
vec3 colorA = vNorm * 0.5 + 0.5;
colorA += vec3(checker(vUv, 15.0)) * 0.05;
//our texture with halftone + hash blur
float dist = length(vUv - 0.5);
float falloff = smoothstep(0.3, 0.7, dist);
float radius = TEXEL_SIZE * 40.0;
radius *= falloff;
vec3 colorB = blur(vUv, radius, 1.0);
falloff = smoothstep(0.5, 0.0, dist);
colorB = mix(colorB, halftone(colorB, vUv, 35.0), falloff);
//mix the two
float blend = smoothstep(0.0, 0.7, vNorm.z);
gl_FragColor.rgb = mix(colorA, colorB, blend);
gl_FragColor.a = 1.0;
}