ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
tremor2.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file tremor2.frag
5 * @brief Vulkan fragment shader: tremor2.
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
25
26/**
27 * @brief Evaluates rand for this shader effect.
28 * @param co Input value for the calculation.
29 * @return Computed float value.
30 */
31float rand(vec2 co) {
32 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
33}
34
35/**
36 * @brief Evaluates pingPong for this shader effect.
37 * @param t Input value for the calculation.
38 * @param maxT Input value for the calculation.
39 * @return Computed float value.
40 */
41float pingPong(float t, float maxT) {
42 return abs(mod(t, 2.0 * maxT) - maxT);
43}
44
45/**
46 * @brief Evaluates tremorEffect for this shader effect.
47 * @param uv Input value for the calculation.
48 * @param frequency Input value for the calculation.
49 * @param maxAmplitude Input value for the calculation.
50 * @param interval Input value for the calculation.
51 * @return Computed vec2 value.
52 */
53vec2 tremorEffect(vec2 uv, float frequency, float maxAmplitude, float interval) {
54 float intervalFactor = pingPong(time_f, interval) / interval;
55 float amplitude = maxAmplitude * intervalFactor;
56 float tremorX = sin(uv.y * frequency + time_f * 5.0) * amplitude;
57 float tremorY = cos(uv.x * frequency + time_f * 5.0) * amplitude;
58 return uv + vec2(tremorX, tremorY);
59}
60
61/**
62 * @brief Executes the fragment shader entry point.
63 */
64void main() {
65 vec2 uv = tc;
66 float frequency = 20.0;
67 float maxAmplitude = 0.02;
68 float interval = 2.0;
69 uv = tremorEffect(uv, frequency, maxAmplitude, interval);
70 vec4 texColor = texture(samp, fract(uv));
71 color = texColor;
72}
73
float rand(vec2 co)
Evaluates rand for this shader effect.
Definition 3high.frag:40
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 pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
#define frequency
Definition ol.frag:13
vec2 tremorEffect(vec2 uv, float frequency, float amplitude)
Evaluates tremorEffect for this shader effect.
Definition tremor1.frag:42