ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
game_mushroom_trip.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file game_mushroom_trip.frag
5 * @brief Vulkan fragment shader: game mushroom trip.
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
20// Psychedelic power-up: sin warp + boosted saturation + slow hue rotation.
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 * @brief Evaluates hueRotate for this shader effect.
29 * @param c Input value for the calculation.
30 * @param a Input value for the calculation.
31 * @return Computed vec3 value.
32 */
33vec3 hueRotate(vec3 c, float a) {
34 const mat3 toYIQ = mat3(
35 0.299, 0.596, 0.211,
36 0.587, -0.274, -0.523,
37 0.114, -0.322, 0.312
38 );
39 const mat3 toRGB = mat3(
40 1.0, 1.0, 1.0,
41 0.956, -0.272, -1.106,
42 0.621, -0.647, 1.703
43 );
44 vec3 yiq = toYIQ * c;
45 float ca = cos(a), sa = sin(a);
46 yiq.yz = mat2(ca, -sa, sa, ca) * yiq.yz;
47 return toRGB * yiq;
48}
49
50/**
51 * @brief Executes the fragment shader entry point.
52 */
53void main(void) {
54 vec2 uv = tc;
55 uv.x += sin(uv.y * 14.0 + time_f * 1.7) * 0.012;
56 uv.y += sin(uv.x * 11.0 + time_f * 1.3) * 0.012;
57 vec3 c = texture(samp, uv).rgb;
58 c = hueRotate(c, time_f * 0.8);
59 float lum = dot(c, vec3(0.299, 0.587, 0.114));
60 c = mix(vec3(lum), c, 1.7);
61 color = vec4(clamp(c, 0.0, 1.5), 1.0);
62}
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 toRGB(uvec3 color)
Evaluates toRGB for this shader effect.
vec3 hueRotate(vec3 color, float angle)
Evaluates hueRotate for this shader effect.
float lum(vec3 c)
Evaluates lum for this shader effect.