ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
light-rings.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file light-rings.frag
5 * @brief Vulkan fragment shader: light-rings.
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 random for this shader effect.
28 * @param st Input value for the calculation.
29 * @return Computed float value.
30 */
31float random(vec2 st) {
32 return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
33}
34
35/**
36 * @brief Evaluates noise for this shader effect.
37 * @param st Input value for the calculation.
38 * @return Computed float value.
39 */
40float noise(vec2 st) {
41 vec2 i = floor(st);
42 vec2 f = fract(st);
43 float a = random(i);
44 float b = random(i + vec2(1.0, 0.0));
45 float c = random(i + vec2(0.0, 1.0));
46 float d = random(i + vec2(1.0, 1.0));
47 vec2 u = f * f * (3.0 - 2.0 * f);
48 return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
49}
50
51/**
52 * @brief Evaluates fbm for this shader effect.
53 * @param st Input value for the calculation.
54 * @return Computed float value.
55 */
56float fbm(vec2 st) {
57 float value = 0.0;
58 float amplitude = 0.5;
59 float frequency = 0.0;
60 for (int i = 0; i < 5; i++) {
61 value += amplitude * noise(st);
62 st *= 2.0;
63 amplitude *= 0.5;
64 }
65 return value;
66}
67
68/**
69 * @brief Evaluates pingPong for this shader effect.
70 * @param x Input value for the calculation.
71 * @param length Input value for the calculation.
72 * @return Computed float value.
73 */
74float pingPong(float x, float length) {
75 float modVal = mod(x, length * 2.0);
76 return modVal <= length ? modVal : length * 2.0 - modVal;
77}
78
79/**
80 * @brief Executes the fragment shader entry point.
81 */
82void main(void) {
83 vec2 uv = tc;
84 vec2 center = iResolution * 0.5;
85 vec2 pos = uv * iResolution - center;
86 float dist = length(pos);
87 float angle = atan(pos.y, pos.x);
88 float lightning = smoothstep(0.1, 0.12, fbm(vec2(angle * 8.0, time_f * 0.5) + vec2(dist * 0.1)));
89 float brightness = lightning * (1.0 - dist / (iResolution.x * 0.5));
90 float time_z = pingPong(time_f, 5.0) + 2.0;
91 brightness = sin(brightness * time_z);
92 vec4 texColor = texture(samp, uv);
93
94 float time_t = pingPong(time_f, 10.0) + 2.0;
95
96 color = texColor + sin(vec4(vec3(brightness), 1.0) * time_t);
97 color.a = 1.0;
98}
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 fbm(vec2 point)
Evaluates fbm for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
float noise(vec2 p)
Evaluates noise for this shader effect.
float lightning(vec2 uv, float seed)
Evaluates lightning for this shader effect.
float random(vec2 st)
Evaluates random for this shader effect.
#define frequency
Definition ol.frag:13