ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
comp_quality.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file comp_quality.frag
5 * @brief Vulkan fragment shader: comp quality.
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 hash12 for this shader effect.
28 * @param p Input value for the calculation.
29 * @return Computed float value.
30 */
31float hash12(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123);}
32
33/**
34 * @brief Evaluates tonemap for this shader effect.
35 * @param x Input value for the calculation.
36 * @return Computed vec3 value.
37 */
38vec3 tonemap(vec3 x){
39 x = x / (x + vec3(1.0));
40 return pow(x, vec3(1.0 / 2.2));
41}
42
43/**
44 * @brief Evaluates compositeEffect for this shader effect.
45 * @param uv Input value for the calculation.
46 * @return Computed vec3 value.
47 */
48vec3 compositeEffect(vec2 uv) {
49 vec2 px = 1.0 / iResolution;
50 float off = 1.5 * px.x;
51 vec3 col;
52 col.r = texture(samp, uv + vec2(off, 0.0)).r;
53 col.g = texture(samp, uv).g;
54 col.b = texture(samp, uv - vec2(off, 0.0)).b;
55
56 float n = hash12(uv * iResolution + time_f * 123.7) - 0.5;
57 col += n * 0.02;
58
59 float scan = sin((uv.y * iResolution.y) * 1.5) * 0.06;
60 col -= scan;
61
62 float bleed = sin(uv.y * iResolution.y * 0.2 + time_f * 5.0) * 0.004;
63 col += vec3(bleed * 0.001, 0.0, -bleed * 0.001); // smaller & balanced shift
64 return col;
65}
66
67/**
68 * @brief Executes the fragment shader entry point.
69 */
70void main(void) {
71 vec2 uv = tc;
72 vec3 col = compositeEffect(uv);
73
74 vec2 px = 1.0 / iResolution;
75 vec3 blur =
76 compositeEffect(uv + vec2( px.x, px.y)) +
77 compositeEffect(uv + vec2(-px.x, px.y)) +
78 compositeEffect(uv + vec2( px.x, -px.y)) +
79 compositeEffect(uv + vec2(-px.x, -px.y));
80 blur *= 0.25;
81
82 float sharpAmt = 0.35;
83 col += (col - blur) * sharpAmt;
84
85 vec2 c = vec2(0.5);
86 float v = smoothstep(0.95, 0.25, distance(uv, c));
87 col *= v;
88
89 col = tonemap(col);
90 color = vec4(clamp(col,0.0,1.0), 1.0);
91}
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
vec4 blur(sampler2D image, vec2 uv, vec2 resolution)
Evaluates blur for this shader effect.
Definition af_scale.frag:44
float hash12(vec2 p)
Evaluates hash12 for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.
vec3 compositeEffect(vec2 uv)
Evaluates compositeEffect for this shader effect.
Definition comp_inc.frag:31
vec3 tonemap(vec3 x)
Evaluates tonemap for this shader effect.