29 lines
709 B
GLSL
29 lines
709 B
GLSL
#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;
|
|
} |