ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
water_hq_25_coral_lagoon.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file water_hq_25_coral_lagoon.frag
5 * @brief Vulkan fragment shader: water hq 25 coral lagoon.
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 time_f ext.u2.y
18
19layout(location = 0) in vec2 tc;
20layout(location = 0) out vec4 color;
21layout(set = 0, binding = 0) uniform sampler2D samp;
22
23
24/**
25 * @brief Evaluates safeUV for this shader effect.
26 * @param p Input value for the calculation.
27 * @return Computed vec2 value.
28 */
29vec2 safeUV(vec2 p) {
30 return 1.0 - abs(mod(p, 2.0) - 1.0);
31}
32/**
33 * @brief Evaluates lagoon for this shader effect.
34 * @param p Input value for the calculation.
35 * @return Computed float value.
36 */
37float lagoon(vec2 p) {
38 float t = time_f * 0.48;
39 float a = sin(p.x * 17.0 + sin(p.y * 9.0 - t) * 2.4 + t);
40 float b = sin(p.y * 20.0 + sin(p.x * 8.0 + t) * 2.1 - t * 1.2);
41 return a + b + 0.45 * sin((p.x - p.y) * 29.0 + t * 1.7);
42}
43
44/**
45 * @brief Executes the fragment shader entry point.
46 */
47void main(void) {
48 float e = 0.002;
49 float h = lagoon(tc);
50 vec2 grad = vec2(lagoon(tc + vec2(e, 0)) - h, lagoon(tc + vec2(0, e)) - h) / e;
51 vec4 src = texture(samp, safeUV(tc + grad * 0.00055));
52 float caustic = pow(clamp(1.0 - abs(h) * 0.28, 0.0, 1.0), 6.0);
53 float shallows = 1.0 - smoothstep(0.0, 1.0, tc.y);
54 vec3 tint = mix(vec3(0.78, 0.96, 1.02), vec3(0.92, 1.02, 0.96), shallows);
55 vec3 rgb = src.rgb * tint + vec3(0.08, 0.19, 0.16) * caustic * (0.20 + shallows * 0.16);
56 color = vec4(rgb, texture(samp, tc).a);
57}
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
float h(vec2 p)
Evaluates h for this shader effect.
vec2 safeUV(vec2 p)
Evaluates safeUV for this shader effect.
float caustic(vec2 p)
Evaluates caustic for this shader effect.
float lagoon(vec2 p)
Evaluates lagoon for this shader effect.