Perspective projection

This commit is contained in:
duck
2025-05-14 22:13:15 +05:00
parent a87d86b335
commit 12285321d2
6 changed files with 179 additions and 53 deletions

View File

@@ -1,9 +1,14 @@
#version 450
layout(location = 0) in vec3 fragCoord;
layout(location = 1) in float vertexIndex;
layout(location = 0) in float vertexIndex;
layout(location = 1) in float depth;
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(fragCoord.z, vertexIndex * 0.1, 0.0, 1.0);
fragColor = vec4(
depth,
0.0,
0.0,
1.0
);
}

View File

@@ -1,11 +1,20 @@
#version 450
layout(location = 0) in vec3 inCoord;
layout(location = 0) out vec3 outCoord;
layout(location = 1) out float vertexIndex;
layout(location = 0) out float vertexIndex;
layout(location = 1) out float depth;
layout(set = 1, binding = 0) uniform Camera{
mat4 transform;
} camera;
layout(set = 1, binding = 1) uniform Object{
mat4 transform;
} object;
void main() {
outCoord = inCoord * 0.5 + 0.5;
vertexIndex = gl_VertexIndex;
gl_Position = vec4(inCoord, 1.0);
vec4 outPos = vec4(inCoord, 1.0) * object.transform * camera.transform;
depth = outPos.z / outPos.w;
gl_Position = outPos;
}