File: wave.glsl

package info (click to toggle)
python-moderngl-window 2.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 69,260 kB
  • sloc: python: 11,225; makefile: 20
file content (41 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#version 330

#if defined VERTEX_SHADER

in vec3 in_position;
in vec2 in_texcoord_0;

out vec2 uv0;

void main() {
    gl_Position = vec4(in_position, 1.0);
    uv0 = in_texcoord_0;
}

#elif defined FRAGMENT_SHADER

out vec4 fragColor;
in vec2 uv0;

uniform sampler2D texture0;
uniform sampler2D texture1;

void main() {
    float v = 0.25;
    ivec2 uv = ivec2(gl_FragCoord.xy);

    vec4 c1 = texelFetch(texture0, ivec2(uv + ivec2(-1, 1)), 0);
    vec4 c2 = texelFetch(texture0, ivec2(uv + ivec2( 0, 1)), 0);
    vec4 c3 = texelFetch(texture0, ivec2(uv + ivec2( 1, 1)), 0);

    vec4 c4 = texelFetch(texture0, ivec2(uv + ivec2(-1, 0)), 0);
    vec4 c5 = texelFetch(texture1, ivec2(uv + ivec2( 0, 0)), 0);
    vec4 c6 = texelFetch(texture0, ivec2(uv + ivec2( 1, 0)), 0);

    vec4 c7 = texelFetch(texture0, ivec2(uv + ivec2(-1, -1)), 0);
    vec4 c8 = texelFetch(texture0, ivec2(uv + ivec2( 0, -1)), 0);
    vec4 c9 = texelFetch(texture0, ivec2(uv + ivec2( 1, -1)), 0);

    fragColor = ((c1 + c2 + c3 + c4 + c6 + c7 + c8 + c9) * 0.25 - c5) * 0.999;
}
#endif