ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
dmd_gpt.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file dmd_gpt.frag
5 * @brief Vulkan fragment shader: dmd gpt.
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
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 diamond for this shader effect.
26 * @param p Input value for the calculation.
27 * @return Computed float value.
28 */
29float diamond(vec2 p){
30 p = abs(p);
31 float d = p.x + p.y;
32 return 1.0 - smoothstep(0.48, 0.5, d);
33}
34
35/**
36 * @brief Executes the fragment shader entry point.
37 */
38void main(void) {
39 float aspect = iResolution.x / iResolution.y;
40 vec2 ar = vec2(aspect, 1.0);
41
42 vec2 uv = tc;
43 vec2 uva = uv * ar;
44
45 float tiles = 8.0;
46 vec2 gv = uva * tiles;
47 vec2 f = fract(gv) - 0.5;
48
49 float mask = diamond(f);
50
51 vec2 mirrored = abs(fract(uv * ar) - 0.5) + 0.5;
52 vec2 tuv = mirrored / ar;
53
54 vec4 c1 = texture(samp, tuv);
55 vec4 c2 = texture(samp, tuv * 0.5);
56 vec4 c3 = texture(samp, tuv * 0.25);
57 vec4 c4 = texture(samp, tuv * 0.125);
58 vec4 mixcol = c1 * 0.4 + c2 * 0.3 + c3 * 0.2 + c4 * 0.1;
59
60 mixcol.rgb *= mask;
61
62 color = vec4(mixcol.rgb, 1.0);
63}
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
float diamond(vec2 p)
Evaluates diamond for this shader effect.
Definition dmd_gpt.frag:29
float tiles(vec2 p)
Evaluates tiles for this shader effect.