ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
water_hq_01_caustic_shallows.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file water_hq_01_caustic_shallows.frag
5 * @brief Vulkan fragment shader: water hq 01 caustic shallows.
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/**
34 * @brief Evaluates surface for this shader effect.
35 * @param p Input value for the calculation.
36 * @param t Input value for the calculation.
37 * @return Computed float value.
38 */
39float surface(vec2 p, float t) {
40 float h = sin(dot(p, vec2(13.0, 9.0)) + t * 1.7);
41 h += 0.55 * sin(dot(p, vec2(-8.0, 17.0)) - t * 1.25);
42 h += 0.28 * sin(dot(p, vec2(25.0, 6.0)) + t * 2.1);
43 return h;
44}
45
46/**
47 * @brief Executes the fragment shader entry point.
48 */
49void main(void) {
50 float e = 0.0025;
51 float h = surface(tc, time_f);
52 vec2 n =
53 vec2(surface(tc + vec2(e, 0.0), time_f) - h, surface(tc + vec2(0.0, e), time_f) - h) / e;
54 vec2 uv = safeUV(tc + n * 0.0018);
55 vec4 src = texture(samp, uv);
56 float caustic = pow(max(0.0, 1.0 - length(n) * 0.055), 7.0);
57 vec3 lit = src.rgb * (0.94 + 0.20 * caustic);
58 lit += vec3(0.03, 0.11, 0.14) * caustic;
59 color = vec4(lit, texture(samp, tc).a);
60}
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.
float n(vec2 p)
Evaluates n for this shader effect.
vec2 safeUV(vec2 p)
Evaluates safeUV for this shader effect.
float surface(vec2 p, float t)
Evaluates surface for this shader effect.
float caustic(vec2 p)
Evaluates caustic for this shader effect.