ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
composite2.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file composite2.frag
5 * @brief Vulkan fragment shader: composite2.
6 */
7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
8 vec4 mouse;
9 vec4 u0;
10 vec4 u1;
11 vec4 u2;
12 vec4 u3;
13 vec4 custom_uniforms[16];
14 vec4 audio_bands;
15 vec4 audio_history;
17#define iResolution ext.u0.zw
18#define time_f ext.u2.y
19
20layout(location = 0) out vec4 color;
21layout(location = 0) in vec2 tc;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates hash for this shader effect.
28 * @param p Input value for the calculation.
29 * @return Computed float value.
30 */
31float hash(vec2 p){ return fract(sin(dot(p, vec2(127.1,311.7))) * 43758.5453); }
32
33/**
34 * @brief Evaluates compositeEffect for this shader effect.
35 * @param uv Input value for the calculation.
36 * @return Computed vec3 value.
37 */
38vec3 compositeEffect(vec2 uv) {
39 vec2 c = vec2(0.5);
40 vec2 d = uv - c;
41 float r2 = dot(d,d);
42 vec2 uvd = c + d * (1.0 + 0.15*r2 + 0.15*r2*r2);
43 float wob = (hash(vec2(time_f*0.73, uv.y*13.7)) - 0.5) * 0.003;
44 uvd.x += wob;
45 uvd = clamp(uvd, 0.001, 0.999);
46
47 float ca = 0.002 + 0.002*sin(time_f*0.37);
48 vec2 shift = d * ca;
49 float bleed = sin(uvd.y * iResolution.y * 0.2 + time_f * 5.0) * 0.003;
50
51 float off = 0.01;
52 vec3 col;
53 col.r = texture(samp, uvd + vec2(off + bleed, 0.0) + shift).r;
54 col.g = texture(samp, uvd).g;
55 col.b = texture(samp, uvd - vec2(off + bleed, 0.0) - shift).b;
56
57 float grain = hash(uvd * iResolution.xy + time_f*41.0) * 2.0 - 1.0;
58 col += grain * 0.03;
59
60 float scan = sin(uvd.y * iResolution.y * 3.14159) * 0.06;
61 col -= scan;
62
63 float l = dot(col, vec3(0.2126,0.7152,0.0722));
64 col = mix(vec3(l), col, 0.92);
65
66 float vig = 1.0 - smoothstep(0.25, 0.8, length(d));
67 col *= vig;
68
69 col = pow(max(col, 0.0), vec3(1.0/1.7));
70 return clamp(col, 0.0, 1.0);
71}
72
73/**
74 * @brief Executes the fragment shader entry point.
75 */
76void main(void) {
77 vec3 col = compositeEffect(tc);
78 color = vec4(col, 1.0);
79}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
ext
Definition 3high.frag:16
void main(void)
Executes the fragment shader entry point.
Definition 3high.frag:47
#define iResolution
Definition 3high.frag:18
#define time_f
Definition 3high.frag:19
float hash(vec2 p)
Evaluates hash for this shader effect.
vec3 compositeEffect(vec2 uv)
Evaluates compositeEffect for this shader effect.
Definition comp_inc.frag:31