ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
aura.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file aura.frag
5 * @brief Vulkan fragment shader: aura.
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
25const float PI = 3.1415926535897932384626433832795;
26
27/**
28 * @brief Evaluates pingPong for this shader effect.
29 * @param x Input value for the calculation.
30 * @param length Input value for the calculation.
31 * @return Computed float value.
32 */
33float pingPong(float x, float length){
34 float m = mod(x, length*2.0);
35 return m <= length ? m : length*2.0 - m;
36}
37
38/**
39 * @brief Evaluates hsv2rgb for this shader effect.
40 * @param c Input value for the calculation.
41 * @return Computed vec3 value.
42 */
43vec3 hsv2rgb(vec3 c){
44 vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);
45 vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);
46 return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);
47}
48
49/**
50 * @brief Executes the fragment shader entry point.
51 */
52void main(void){
53 vec2 uv = tc * 2.0 - 1.0;
54 uv.x *= iResolution.x / iResolution.y;
55 float radius = mix(0.8, 1.2, 0.5 + 0.5 * sin(time_f * 1.3));
56 radius *= 2;
57 float r = length(uv);
58 float glow = smoothstep(radius, radius - 0.25, r) * pingPong(time_f, 5.0);
59 float ang = atan(uv.y, uv.x);
60 vec3 grad = hsv2rgb(vec3(fract(ang / (2.0 * PI) + time_f * 0.05), 0.8, 1.0));
61 vec4 base = texture(samp, tc);
62 vec3 aura = grad * glow * (0.8 + 0.2 * sin(time_f * 2.0));
63 color = vec4(base.rgb + aura * (1.0 - base.rgb), base.a);
64}
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
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