diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-08-26 10:55:18 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-08-26 10:55:18 +0500 |
commit | ad04490ef84d7565fbec0fa878a21694ad2d61f0 (patch) | |
tree | accfa142da0b3f99f957de6c030dc2c76639be53 /in_practice/breakout/shaders | |
parent | 1f93c3ef62af6c71217f06491ca2b859d4065740 (diff) |
guess that's all
Diffstat (limited to 'in_practice/breakout/shaders')
-rw-r--r-- | in_practice/breakout/shaders/particle.frag | 15 | ||||
-rw-r--r-- | in_practice/breakout/shaders/particle.vert | 20 | ||||
-rw-r--r-- | in_practice/breakout/shaders/post.frag | 38 | ||||
-rw-r--r-- | in_practice/breakout/shaders/post.vert | 33 | ||||
-rw-r--r-- | in_practice/breakout/shaders/text.frag | 16 | ||||
-rw-r--r-- | in_practice/breakout/shaders/text.vert | 15 |
6 files changed, 137 insertions, 0 deletions
diff --git a/in_practice/breakout/shaders/particle.frag b/in_practice/breakout/shaders/particle.frag new file mode 100644 index 0000000..ef62554 --- /dev/null +++ b/in_practice/breakout/shaders/particle.frag @@ -0,0 +1,15 @@ +#version 330 core + +in vert_t { + vec2 tex_coords; + vec4 color; +} vert; + +out vec4 frag_color; + +uniform sampler2D sprite; + +void main() +{ + frag_color = texture(sprite, vert.tex_coords) * vert.color; +} diff --git a/in_practice/breakout/shaders/particle.vert b/in_practice/breakout/shaders/particle.vert new file mode 100644 index 0000000..9827a95 --- /dev/null +++ b/in_practice/breakout/shaders/particle.vert @@ -0,0 +1,20 @@ +#version 330 core + +layout (location = 0) in vec4 vertex; + +out vert_t { + vec2 tex_coords; + vec4 color; +} vert; + +uniform mat4 projection; +uniform vec2 offset; +uniform vec4 color; + +void main() +{ + float scale = 10.0; + vert.tex_coords = vertex.zw; + vert.color = color; + gl_Position = projection * vec4((vertex.xy * scale) + offset, 0.0, 1.0); +} diff --git a/in_practice/breakout/shaders/post.frag b/in_practice/breakout/shaders/post.frag new file mode 100644 index 0000000..899b098 --- /dev/null +++ b/in_practice/breakout/shaders/post.frag @@ -0,0 +1,38 @@ +#version 330 core + +in vert_t { + vec2 tex_coords; +} vert; + +out vec4 frag_color; + +uniform sampler2D colorbuffer; +uniform vec2 offsets[9]; +uniform int edge_kernel[9]; +uniform float blur_kernel[9]; + +uniform bool chaos; +uniform bool confuse; +uniform bool shake; + +void main() +{ + frag_color = vec4(0.0); + vec3 sample[9]; + if (chaos || shake) + for (int i = 0; i < 9; i++) + sample[i] = vec3(texture(colorbuffer, vert.tex_coords + offsets[i])); + if (chaos) { + for (int i = 0; i < 9; i++) + frag_color += vec4(sample[i] * edge_kernel[i], 0.0); + frag_color.a = 1.0; + } else if (confuse) { + frag_color = vec4(1.0 - texture(colorbuffer, vert.tex_coords).rgb, 1.0); + } else if (shake) { + for (int i = 0; i < 9; i++) + frag_color += vec4(sample[i] * blur_kernel[i], 0.0); + frag_color.a = 1.0; + } else { + frag_color = texture(colorbuffer, vert.tex_coords); + } +} diff --git a/in_practice/breakout/shaders/post.vert b/in_practice/breakout/shaders/post.vert new file mode 100644 index 0000000..7a8ac4f --- /dev/null +++ b/in_practice/breakout/shaders/post.vert @@ -0,0 +1,33 @@ +#version 330 core + +layout (location = 0) in vec4 vertex; + +out vert_t { + vec2 tex_coords; +} vert; + +uniform bool chaos; +uniform bool confuse; +uniform bool shake; +uniform float time; + +void main() +{ + gl_Position = vec4(vertex.xy, 0.0, 1.0); + vec2 texture = vertex.zw; + if (chaos) { + float strength = 0.3; + vec2 pos = vec2(texture.x + sin(time) * strength, + texture.y + cos(time) * strength); + vert.tex_coords = pos; + } else if (confuse) { + vert.tex_coords = vec2(1.0) - texture; + } else { + vert.tex_coords = texture; + } + if (shake) { + float strength = 0.01; + gl_Position.x += cos(time * 10) * strength; + gl_Position.y += cos(time * 15) * strength; + } +} diff --git a/in_practice/breakout/shaders/text.frag b/in_practice/breakout/shaders/text.frag new file mode 100644 index 0000000..a6fae4b --- /dev/null +++ b/in_practice/breakout/shaders/text.frag @@ -0,0 +1,16 @@ +#version 330 core + +in vert_t { + vec2 tex_coords; +} vert; + +out vec4 frag_color; + +uniform sampler2D glyph; +uniform vec3 text_color; + +void main() +{ + vec4 glyph_color = vec4(1.0, 1.0, 1.0, texture(glyph, vert.tex_coords).r); + frag_color = vec4(text_color, 1.0) * glyph_color; +} diff --git a/in_practice/breakout/shaders/text.vert b/in_practice/breakout/shaders/text.vert new file mode 100644 index 0000000..aa22caa --- /dev/null +++ b/in_practice/breakout/shaders/text.vert @@ -0,0 +1,15 @@ +#version 330 core + +layout(location = 0) in vec4 vertex; + +out vert_t { + vec2 tex_coords; +} vert; + +uniform mat4 projection; + +void main() +{ + gl_Position = projection * vec4(vertex.xy, 0.0, 1.0); + vert.tex_coords = vertex.zw; +} |