ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
xor_code_rgb_smooth_velvet_prism.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file xor_code_rgb_smooth_velvet_prism.frag
5 * @brief Vulkan fragment shader: xor code rgb smooth velvet prism.
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) in vec2 tc;
21layout(location = 0) out vec4 color;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates bytes for this shader effect.
28 * @param c Input value for the calculation.
29 * @return Computed uvec3 value.
30 */
31uvec3 bytes(vec3 c) {
32 return uvec3(clamp(floor(c * 255.0 + 0.5), 0.0, 255.0));
33}
34
35/**
36 * @brief Evaluates xorColor for this shader effect.
37 * @param a Input value for the calculation.
38 * @param b Input value for the calculation.
39 * @return Computed vec3 value.
40 */
41vec3 xorColor(vec3 a, vec3 b) {
42 return vec3((bytes(a) ^ bytes(b)) & uvec3(255u)) / 255.0;
43}
44
45/**
46 * @brief Evaluates palette for this shader effect.
47 * @param t Input value for the calculation.
48 * @return Computed vec3 value.
49 */
50vec3 palette(float t) {
51 return 0.54 + 0.46 * cos(6.2831853 * (t + vec3(0.02, 0.34, 0.68)));
52}
53
54/**
55 * @brief Evaluates gaussian25 for this shader effect.
56 * @param uv Input value for the calculation.
57 * @return Computed vec3 value.
58 */
59vec3 gaussian25(vec2 uv) {
60 vec2 px = 1.25 / max(iResolution, vec2(1.0));
61 vec3 sum = vec3(0.0);
62 float total = 0.0;
63 for (int y = -2; y <= 2; ++y) {
64 for (int x = -2; x <= 2; ++x) {
65 vec2 offset = vec2(float(x), float(y));
66 float weight = exp(-dot(offset, offset) * 0.42);
67 sum += texture(samp, uv + offset * px).rgb * weight;
68 total += weight;
69 }
70 }
71 return sum / total;
72}
73
74/**
75 * @brief Executes the fragment shader entry point.
76 */
77void main(void) {
78 vec2 p = tc - 0.5;
79 float radius = length(p);
80 vec3 blur = gaussian25(tc);
81 float luminance = dot(blur, vec3(0.299, 0.587, 0.114));
82 vec2 direction = normalize(p + vec2(0.0001));
83 float split = 0.0015 + 0.003 * sin(radius * 18.0 - time_f * 0.7);
84 vec3 prism =
85 vec3(gaussian25(tc + direction * split).r, blur.g, gaussian25(tc - direction * split).b);
86
87 float key = 1.75 + 0.35 * sin(time_f * 0.2 + luminance * 3.0);
88 vec3 bits = xorColor(prism, blur.bgr * key);
89 vec3 velvet = palette(luminance * 0.65 + radius * 0.3 + time_f * 0.015);
90 float sheen = pow(0.5 + 0.5 * sin(radius * 32.0 - time_f * 1.6), 8.0);
91
92 vec3 result = mix(prism, bits, 0.34);
93 result = mix(result, result * velvet * 1.3, 0.38);
94 result += velvet * sheen * 0.16;
95 result = pow(clamp(result, 0.0, 1.0), vec3(0.92));
96 color = vec4(result, texture(samp, tc).a);
97}
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
vec3 palette(float phase)
Evaluates palette for this shader effect.
uvec3 bytes(vec3 c)
Evaluates bytes for this shader effect.
vec4 blur(sampler2D image, vec2 uv, vec2 resolution)
Evaluates blur for this shader effect.
Definition af_scale.frag:44
vec3 prism(float t)
Evaluates prism for this shader effect.
float luminance(vec3 c)
Evaluates luminance for this shader effect.
vec3 xorColor(vec3 a, vec3 b)
Evaluates xorColor for this shader effect.
vec3 gaussian25(vec2 uv)
Evaluates gaussian25 for this shader effect.