Skip to content

Commit 967e6e2

Browse files
committed
Black and White postprocessing
1 parent ae2aca5 commit 967e6e2

18 files changed

Lines changed: 122 additions & 12 deletions

shaders/color_frag.spv

0 Bytes
Binary file not shown.

shaders/color_vert.spv

0 Bytes
Binary file not shown.

shaders/compile.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ glslc.exe -fshader-stage=frag color_frag.glsl -o color_frag.spv
55
glslc.exe -fshader-stage=vert texture_vert.glsl -o texture_vert.spv
66
glslc.exe -fshader-stage=frag texture_frag.glsl -o texture_frag.spv
77
glslc.exe -fshader-stage=vert model_vert.glsl -o model_vert.spv
8-
glslc.exe -fshader-stage=frag model_frag.glsl -o model_frag.spv
8+
glslc.exe -fshader-stage=frag model_frag.glsl -o model_frag.spv
9+
glslc.exe -fshader-stage=vert postprocess_vert.glsl -o postprocess_vert.spv
10+
glslc.exe -fshader-stage=frag postprocess_frag.glsl -o postprocess_frag.spv

shaders/compile.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ glslc -fshader-stage=frag color_frag.glsl -o color_frag.spv
66
glslc -fshader-stage=vert texture_vert.glsl -o texture_vert.spv
77
glslc -fshader-stage=frag texture_frag.glsl -o texture_frag.spv
88
glslc -fshader-stage=vert model_vert.glsl -o model_vert.spv
9-
glslc -fshader-stage=frag model_frag.glsl -o model_frag.spv
9+
glslc -fshader-stage=frag model_frag.glsl -o model_frag.spv
10+
glslc -fshader-stage=vert postprocess_vert.glsl -o postprocess_vert.spv
11+
glslc -fshader-stage=frag postprocess_frag.glsl -o postprocess_frag.spv

shaders/model_frag.spv

0 Bytes
Binary file not shown.

shaders/model_vert.spv

0 Bytes
Binary file not shown.

shaders/postprocess_frag.glsl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#version 450 core
2+
3+
layout(set = 0, input_attachment_index = 0, binding = 0) uniform subpassInput in_color;
4+
5+
layout(location = 0) out vec4 out_color;
6+
7+
void main() {
8+
vec4 color = subpassLoad(in_color);
9+
out_color = vec4(vec3(length(color.rgb)/sqrt(3.0)), color.a);
10+
}

shaders/postprocess_frag.spv

992 Bytes
Binary file not shown.

shaders/postprocess_vert.glsl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#version 450 core
2+
3+
//Basic Buffer/Layout-less fullscreen triangle vertex shader
4+
vec2 triangleVertex(in int vertID, out vec2 texcoord) {
5+
/*
6+
//See: https://web.archive.org/web/20140719063725/http://www.altdev.co/2011/08/08/interesting-vertex-shader-trick/
7+
1
8+
( 0, 2)
9+
[-1, 3] [ 3, 3]
10+
.
11+
|`.
12+
| `.
13+
| `.
14+
'------`
15+
0 2
16+
( 0, 0) ( 2, 0)
17+
[-1,-1] [ 3,-1]
18+
ID=0 -> Pos=[-1,-1], Tex=(0,0)
19+
ID=1 -> Pos=[-1, 3], Tex=(0,2)
20+
ID=2 -> Pos=[ 3,-1], Tex=(2,0)
21+
*/
22+
23+
texcoord.x = (vertID == 2) ? 2.0 : 0.0;
24+
texcoord.y = (vertID == 1) ? 2.0 : 0.0;
25+
26+
return texcoord * vec2(2.0, -2.0) + vec2(-1.0, 1.0);
27+
}
28+
29+
void main() {
30+
vec2 texcoord;
31+
vec2 pos = triangleVertex(gl_VertexIndex, texcoord);
32+
33+
gl_Position = vec4(pos, 1.0, 1.0);
34+
}

shaders/postprocess_vert.spv

1.66 KB
Binary file not shown.

0 commit comments

Comments
 (0)