ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
gem_txt.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file gem_txt.frag
5 * @brief Vulkan fragment shader: gem txt.
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;
22
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26// Function to generate "fake" scrolling code/text patterns
27/**
28 * @brief Evaluates text for this shader effect.
29 * @param p Input value for the calculation.
30 * @return Computed float value.
31 */
32float text(vec2 p) {
33 p.y += time_f * 0.2; // Vertical scroll speed
34 vec2 grid = floor(p * vec2(20.0, 40.0));
35 float h = fract(sin(dot(grid, vec2(12.9898, 78.233))) * 43758.5453);
36 return step(0.5, h) * step(0.3, fract(p.x * 20.0)) * step(0.3, fract(p.y * 40.0));
37}
38
39/**
40 * @brief Executes the fragment shader entry point.
41 */
42void main(void) {
43 // 1. Lens Distortion (Bulge effect)
44 vec2 uv = tc * 2.0 - 1.0;
45 uv.x *= iResolution.x / iResolution.y;
46
47 float r = length(uv);
48 // Fish-eye math: pushes coordinates outward from the center
49 vec2 bulgeUV = tc + (uv * r * 0.2);
50
51 // 2. Chromatic Aberration (RGB Split)
52 // We sample the texture at three slightly different bulges
53 float chromaticPower = 0.015 * r;
54 float r_ch = texture(samp, bulgeUV + vec2(chromaticPower, 0.0)).r;
55 float g_ch = texture(samp, bulgeUV).g;
56 float b_ch = texture(samp, bulgeUV - vec2(chromaticPower, 0.0)).b;
57 vec3 baseTex = vec3(r_ch, g_ch, b_ch);
58
59 // 3. Digital Overlay (The "Matrix" Complexity)
60 // This adds that layer of text/data seen in your image
61 float characters = text(bulgeUV * 1.5);
62 vec3 textColor = vec3(0.4, 1.0, 0.6) * characters * 0.4;
63
64 // 4. Color Grading (The Pink/Gold spectrum)
65 // Shifts the background toward the psychedelic tones in the snap
66 float hueShift = sin(r * 3.0 - time_f) * 0.5 + 0.5;
67 vec3 psychoTone = mix(vec3(0.8, 0.1, 0.5), vec3(0.1, 0.8, 0.9), hueShift);
68
69 // 5. Bright Central Flare
70 // Replicates the intense white light in the center of the text
71 float flare = exp(-r * 3.5) * 2.0;
72 vec3 flareColor = vec3(1.0, 1.0, 0.9) * flare;
73
74 // 6. Final Composite
75 vec3 result = mix(baseTex, psychoTone, 0.3); // Blend original texture with tones
76 result += textColor; // Add scrolling text
77 result += flareColor; // Add the central light
78
79 // Subtle vignette to focus the "eye"
80 result *= smoothstep(1.5, 0.2, r);
81
82 color = vec4(result, 1.0);
83}
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 h(vec2 p)
Evaluates h for this shader effect.
vec3 hueShift(vec3 col, float hue)
Evaluates hueShift for this shader effect.
float text(vec2 p)
Evaluates text for this shader effect.
Definition gem_txt.frag:32