forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB9d8f4f8Ivan Molodetskikh1 month ago2997 commits

gradient_fade.frag47 lines, 894 bytesHistoryRawDownload
1#version 100
2
3//_DEFINES_
4
5#if defined(EXTERNAL)
6#extension GL_OES_EGL_image_external : require
7#endif
8
9precision highp float;
10#if defined(EXTERNAL)
11uniform samplerExternalOES tex;
12#else
13uniform sampler2D tex;
14#endif
15
16uniform float alpha;
17varying vec2 v_coords;
18
19#if defined(DEBUG_FLAGS)
20uniform float tint;
21#endif
22
23// x is left edge, y is right edge of the gradient.
24uniform vec2 cutoff;
25
26void main() {
27 // Sample the texture.
28 vec4 color = texture2D(tex, v_coords);
29#if defined(NO_ALPHA)
30 color = vec4(color.rgb, 1.0);
31#endif
32
33 if (cutoff.x < cutoff.y) {
34 float fade = clamp((cutoff.y - v_coords.x) / (cutoff.y - cutoff.x), 0.0, 1.0);
35 color = color * fade;
36 }
37
38 // Apply final alpha and tint.
39 color = color * alpha;
40
41#if defined(DEBUG_FLAGS)
42 if (tint == 1.0)
43 color = vec4(0.0, 0.2, 0.0, 0.2) + color * 0.8;
44#endif
45
46 gl_FragColor = color;
47}