ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
comp_inc.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file comp_inc.frag
5 * @brief Vulkan fragment shader: comp inc.
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 compositeEffect for this shader effect.
28 * @param uv Input value for the calculation.
29 * @return Computed vec3 value.
30 */
31vec3 compositeEffect(vec2 uv) {
32 float offset = 0.01;
33 vec3 col;
34 col.r = texture(samp, uv + vec2(offset, 0.0)).r;
35 col.g = texture(samp, uv).g;
36 col.b = texture(samp, uv - vec2(offset, 0.0)).b;
37 float noise = fract(sin(dot(uv.xy, vec2(12.9898, 78.233))) * 43758.5453);
38 col += noise * 0.05;
39 float scanline = sin(uv.y * iResolution.y * 1.5) * 0.1;
40 col -= scanline;
41 float bleed = sin(uv.y * iResolution.y * 0.2 + time_f * 5.0) * 0.005;
42 col.r += bleed * 0.002;
43 col.b -= bleed * 0.002;
44 return col;
45}
46
47/**
48 * @brief Evaluates aces for this shader effect.
49 * @param x Input value for the calculation.
50 * @return Computed vec3 value.
51 */
52vec3 aces(vec3 x){
53 const mat3 a=mat3(0.59719,0.35458,0.04823,0.07600,0.90834,0.01566,0.02840,0.13383,0.83777);
54 const mat3 b=mat3(1.60475,-0.53108,-0.07367,-0.10208,1.10813,-0.00605,-0.00327,-0.07276,1.07602);
55 vec3 v=a*x;
56 v=(v*(v+0.0245786)-0.000090537)*b;
57 return clamp(v,0.0,1.0);
58}
59
60/**
61 * @brief Evaluates hash12 for this shader effect.
62 * @param p Input value for the calculation.
63 * @return Computed float value.
64 */
65float hash12(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123);}
66
67/**
68 * @brief Executes the fragment shader entry point.
69 */
70void main(void) {
71 float aspect = iResolution.x / iResolution.y;
72 vec2 ar = vec2(aspect,1.0);
73 vec2 c = vec2(0.5);
74
75 vec2 p = (tc - c) * ar;
76 float r2 = dot(p,p);
77 float k1 = 0.15;
78 float k2 = 0.05;
79 vec2 pd = p*(1.0 + k1*r2 + k2*r2*r2);
80 vec2 uvd = pd/ar + c;
81
82 vec2 dir = normalize(p + 1e-6);
83 float ab = 0.0015 + 0.0015*sin(time_f*0.5);
84 vec2 uvR = uvd + dir*ab;
85 vec2 uvG = uvd;
86 vec2 uvB = uvd - dir*ab;
87
88 uvR = clamp(uvR,0.0,1.0);
89 uvG = clamp(uvG,0.0,1.0);
90 uvB = clamp(uvB,0.0,1.0);
91
92 vec3 cR = compositeEffect(uvR);
93 vec3 cG = compositeEffect(uvG);
94 vec3 cB = compositeEffect(uvB);
95 vec3 col = vec3(cR.r, cG.g, cB.b);
96
97 vec2 ts = 1.0 / iResolution;
98 float shAmt = 0.4;
99 vec3 bsum = vec3(0.0);
100 bsum += compositeEffect(uvd + vec2(1,1)*ts);
101 bsum += compositeEffect(uvd + vec2(-1,1)*ts);
102 bsum += compositeEffect(uvd + vec2(1,-1)*ts);
103 bsum += compositeEffect(uvd + vec2(-1,-1)*ts);
104 bsum *= 0.25;
105 col += (col - bsum) * shAmt;
106
107 float v = smoothstep(0.95, 0.3, length(p));
108 col *= v;
109
110 float gAmt = 0.03;
111 float g = hash12(gl_FragCoord.xy + time_f*123.45) - 0.5;
112 col += g * gAmt;
113
114 col = aces(col);
115 col = pow(col, vec3(1.0/2.2));
116
117 color = vec4(clamp(col,0.0,1.0),1.0);
118}
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 noise(vec2 p)
Evaluates noise for this shader effect.
float hash12(vec2 p)
Evaluates hash12 for this shader effect.
vec3 aces(vec3 x)
Evaluates aces for this shader effect.
vec3 compositeEffect(vec2 uv)
Evaluates compositeEffect for this shader effect.
Definition comp_inc.frag:31
float scanline(vec2 uv)
Evaluates scanline for this shader effect.