ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ripple_a.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file ripple_a.frag
5 * @brief Vulkan fragment shader: ripple a.
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
26const float PI = 3.14159265359;
27const vec3 NEON_COLOR = vec3(0.8, 0.2, 1.0);
28
29/**
30 * @brief Evaluates pingPong for this shader effect.
31 * @param value Input value for the calculation.
32 * @param length Input value for the calculation.
33 * @return Computed float value.
34 */
35float pingPong(float value, float length) {
36 float modValue = mod(value, length * 2.0);
37 return length - abs(modValue - length);
38}
39
40/**
41 * @brief Evaluates hsv2rgb for this shader effect.
42 * @param c Input value for the calculation.
43 * @return Computed vec3 value.
44 */
45vec3 hsv2rgb(vec3 c) {
46 vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
47 vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
48 return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
49}
50
51/**
52 * @brief Evaluates vortexEffect for this shader effect.
53 * @param uv Input value for the calculation.
54 * @param time Input value for the calculation.
55 * @return Computed vec3 value.
56 */
57vec3 vortexEffect(vec2 uv, float time) {
58 uv = uv * 2.0 - 1.0;
59 uv.x *= iResolution.x / iResolution.y;
60 float angle = atan(uv.y, uv.x) + time * 0.5;
61 float radius = length(uv);
62 uv = vec2(cos(angle), sin(angle)) * radius;
63 float ripple = sin(radius * 10.0 - time * 5.0) * 0.05;
64 uv += ripple * vec2(cos(angle), sin(angle));
65 vec3 texColor = texture(samp, uv * 0.5 + 0.5).rgb;
66 texColor += NEON_COLOR * exp(-10.0 * radius);
67 return texColor;
68}
69
70/**
71 * @brief Executes the fragment shader entry point.
72 */
73void main(void) {
74 vec2 uv = tc;
75 vec3 colorEffect = vortexEffect(uv, time_f);
76 float offset = 0.005 * sin(time_f);
77 vec3 finalColor = vec3(
78 vortexEffect(uv + vec2(offset, 0.0), time_f).r,
79 colorEffect.g,
80 vortexEffect(uv - vec2(offset, 0.0), time_f).b
81 );
82 color = vec4(finalColor, 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
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
#define PI
vec3 vortexEffect(vec2 uv, float time)
Evaluates vortexEffect for this shader effect.
Definition ripple_a.frag:57
const vec3 NEON_COLOR
Definition ripple_a.frag:27