This commit is contained in:
xsl
2025-09-16 18:56:06 +08:00
parent fab00f8466
commit e6bef08ecf
4 changed files with 30 additions and 12 deletions
+20 -8
View File
@@ -1,14 +1,26 @@
#version 450
layout(location = 0) out vec2 uv;
// 硬编码的顶点数据 - 4个顶点组成三角形带覆盖整个屏幕
const vec2 positions[6] = vec2[6](
vec2( 1.0, 1.0), // 右上 - 三角形1
vec2(-1.0, 1.0), // 左上 - 三角形1
vec2(-1.0, -1.0), // 左下 - 三角形1
vec2(-1.0, -1.0), // 左下 - 三角形2
vec2( 1.0, -1.0), // 右下 - 三角形2
vec2( 1.0, 1.0) // 右上 - 三角形2
);
// 输出变量
layout(location = 0) out vec2 outPosition;
void main() {
// 使用NDC坐标(-1到1),并为四个顶点分配位置
vec2 positions[4] = vec2[](
vec2(-1.0, -1.0), vec2(1.0, -1.0),
vec2(-1.0, 1.0), vec2(1.0, 1.0)
);
// 获取顶点位置
vec2 position = positions[gl_VertexIndex];
uv = positions[gl_VertexIndex].xy * 0.5 + 0.5;
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
// 设置输出位置(Vulkan使用不同的坐标系)
gl_Position = vec4(position, 0.0, 1.0);
// 输出位置坐标(如果需要传递给片段着色器)
outPosition = position;
}