添加多模型渲染,添加贴图渲染,添加平行光, 暂时不上传assets

This commit is contained in:
2026-09-21 14:07:20 +08:00
parent 381b7c0aa6
commit 7d628f8d8a
37 changed files with 9817 additions and 189 deletions
+30 -6
View File
@@ -1,15 +1,39 @@
#version 450
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
const int MAX_LIGHTS = 4;
layout(location = 0) out vec3 fragColor;
struct Light {
vec4 direction;
vec4 color;
};
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inUV;
layout(location = 0) out vec2 fragUV;
layout(location = 1) out vec3 fragNormal;
layout(location = 2) out vec3 fragWorldPos;
layout(push_constant) uniform PushConstants {
mat4 model;
} pc;
layout(set = 0, binding = 0) uniform UniformBufferObject {
mat4 mvp;
mat4 view;
mat4 proj;
vec4 ambientColor;
Light lights[MAX_LIGHTS];
} ubo;
void main() {
gl_Position = ubo.mvp * vec4(inPosition, 1.0);
fragColor = inColor;
vec4 worldPos = pc.model * vec4(inPosition, 1.0);
gl_Position = ubo.proj * ubo.view * worldPos;
fragWorldPos = worldPos.xyz;
mat3 normalMatrix = mat3(transpose(inverse(pc.model)));
fragNormal = normalize(normalMatrix * inNormal);
fragUV = inUV;
}