ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
color_g.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file color_g.frag
5 * @brief Vulkan fragment shader: color g.
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 alpha ext.u0.x
18#define iResolution ext.u0.zw
19#define time_f ext.u2.y
20
21layout(location = 0) out vec4 color;
22layout(location = 0) in vec2 tc;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27
28/**
29 * @brief Evaluates pingPong for this shader effect.
30 * @param x Input value for the calculation.
31 * @param length Input value for the calculation.
32 * @return Computed float value.
33 */
34float pingPong(float x, float length) {
35 float modVal = mod(x, length * 2.0);
36 return modVal <= length ? modVal : length * 2.0 - modVal;
37}
38
39/**
40 * @brief Evaluates hash for this shader effect.
41 * @param p Input value for the calculation.
42 * @return Computed float value.
43 */
44float hash(vec2 p) {
45 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
46}
47
48/**
49 * @brief Evaluates noise for this shader effect.
50 * @param p Input value for the calculation.
51 * @return Computed float value.
52 */
53float noise(vec2 p) {
54 vec2 i = floor(p);
55 vec2 f = fract(p);
56 vec2 u = f * f * (3.0 - 2.0 * f);
57 return mix(mix(hash(i + vec2(0.0, 0.0)), hash(i + vec2(1.0, 0.0)),
58u.x),
59 mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)),
60u.x), u.y);
61}
62
63/**
64 * @brief Executes the fragment shader entry point.
65 */
66void main(void) {
67 vec2 uv = (tc * iResolution - 0.5 * iResolution) / iResolution.y;
68 float t = time_f * 0.7;
69 float radius = length(uv);
70 float angle = atan(uv.y, uv.x);
71 angle += t * 0.5;
72 float radMod = pingPong(radius + t * 0.3, 0.5);
73 float wave = sin(radius * 10.0 - t * 6.0) * 0.5 + 0.5;
74 float noiseEffect = noise(uv * 10.0 + t * 0.5) * 0.2;
75 float r = sin(angle * 3.0 + radMod * 8.0 + wave * 6.2831 +
76noiseEffect);
77 float g = sin(angle * 4.0 - radMod * 6.0 + wave * 4.1230 +
78noiseEffect);
79 float b = sin(angle * 5.0 + radMod * 10.0 - wave * 3.4560 -
80noiseEffect);
81 float blur = exp(-radius * 10.0) * 0.8 + 0.2;
82 vec3 col = vec3(r, g, b) * blur * 0.5 + 0.5;
83 vec3 texColor = texture(samp, tc + sin(t * 0.2 + radius) * 0.01).rgb;
84 col = mix(col, texColor, 0.4);
85 color = vec4(col, alpha);
86}
87
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 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec4 blur(sampler2D image, vec2 uv, vec2 resolution)
Evaluates blur for this shader effect.
Definition af_scale.frag:44
float hash(vec2 p)
Evaluates hash for this shader effect.
float noise(vec2 p)
Evaluates noise for this shader effect.
#define alpha
Definition color_g.frag:17