save code

This commit is contained in:
xsl
2025-09-15 22:03:51 +08:00
parent 8e1c574122
commit bf8a14f549
4 changed files with 40 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#version 450
layout(binding = 0) uniform sampler2D backgroundTexture; // Binding 0
layout(location = 0) in vec2 inUV;
layout(location = 0) out vec4 outColor;
void main() {
//outColor = texture(backgroundTexture, inUV);
outColor = vec4(1.0, 0.0, 0.0, 1.0); // 输出红色
}
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
#version 450
// 在没有顶点缓冲区的情况下,通过顶点ID生成全屏 quad
// 顶点ID: 0=(-1,-1), 1=(1,-1), 2=(-1,1), 3=(1,1)
out gl_PerVertex {
vec4 gl_Position;
};
layout(location = 0) out vec2 outUV;
void main() {
vec2 pos;
vec2 uv;
if (gl_VertexIndex == 0) {
pos = vec2(-1.0, -1.0);
uv = vec2(0.0, 0.0);
} else if (gl_VertexIndex == 1) {
pos = vec2(1.0, -1.0);
uv = vec2(1.0, 0.0);
} else if (gl_VertexIndex == 2) {
pos = vec2(-1.0, 1.0);
uv = vec2(0.0, 1.0);
} else { // gl_VertexIndex == 3
pos = vec2(1.0, 1.0);
uv = vec2(1.0, 1.0);
}
gl_Position = vec4(pos, 0.0, 1.0);
outUV = uv;
}
Binary file not shown.