ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
water_prism.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file water_prism.frag
5 * @brief Vulkan fragment shader: water 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) out vec4 color;
21layout(location = 0) in vec2 tc;
22
23
24layout(set = 0, binding = 0) uniform sampler2D samp;
25
26/**
27 * @brief Evaluates pingPong for this shader effect.
28 * @param x Input value for the calculation.
29 * @param length Input value for the calculation.
30 * @return Computed float value.
31 */
32float pingPong(float x, float length) {
33 float modVal = mod(x, length * 2.0);
34 return modVal <= length ? modVal : length * 2.0 - modVal;
35}
36
37vec3 hsv2rgb(vec3 c)
38{
39 vec4 K = vec4(1.0, 2.0/3.0, 1.0/3.0, 3.0);
40 vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
41 return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
42}
43
44/**
45 * @brief Executes the fragment shader entry point.
46 */
47void main(void) {
48 float time_t = pingPong(time_f, 7.0);
49 vec2 uv = tc * 2.0 - 1.0;
50 float frequency = 10.0;
51 float amplitude = 0.02;
52 float waveX = sin(uv.y * frequency + time_t) * amplitude;
53 waveX += sin(uv.y * frequency * 0.5 + time_t * 1.5) * amplitude * 0.5;
54 float waveY = sin(uv.x * frequency + time_t * 0.8) * amplitude;
55 waveY += sin(uv.x * frequency * 0.5 + time_t * 1.2) * amplitude * 0.5;
56 uv += vec2(waveX, waveY);
57
58 float hue = mod((uv.y + 1.0) * 0.5 + time_t * 0.1, 1.0);
59 float saturation = 1.0;
60 float value = 1.0;
61 vec3 neonColor = hsv2rgb(vec3(hue, saturation, value));
62
63 vec4 texColor = texture(samp, uv * 0.5 + 0.5);
64 float depth = (uv.y + 1.0) * 0.5;
65 float attenuation = mix(1.0, 0.6, depth);
66 vec3 finalColor = mix(neonColor, sin(texColor.rgb * time_t), 0.5) * attenuation;
67
68 color = vec4(finalColor, 1.0);
69}
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 time_f
Definition 3high.frag:19
vec3 saturation(vec3 color, float amount)
Evaluates saturation for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec3 hue(float t)
Evaluates hue for this shader effect.
Definition auraXi1.frag:65
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
#define frequency
Definition ol.frag:13