2025-03-28 16:33:40 -04:00
|
|
|
#version 450
|
2025-04-01 21:41:24 -04:00
|
|
|
|
2025-04-05 20:54:38 -04:00
|
|
|
// INPUTS from Vertex Buffer (matching Vertex struct)
|
2025-04-01 21:41:24 -04:00
|
|
|
layout(location = 0) in vec3 inPosition;
|
2025-04-05 20:54:38 -04:00
|
|
|
layout(location = 1) in vec3 inNormal;
|
|
|
|
|
layout(location = 2) in vec2 inTexCoord; // <<< MUST be vec2
|
2025-04-01 21:41:24 -04:00
|
|
|
|
2025-04-05 20:54:38 -04:00
|
|
|
// UNIFORMS (Set 0)
|
|
|
|
|
layout(set = 0, binding = 0) uniform UniformBufferObject {
|
2025-04-01 21:41:24 -04:00
|
|
|
mat4 view;
|
|
|
|
|
mat4 proj;
|
|
|
|
|
} ubo;
|
|
|
|
|
|
2025-04-05 20:54:38 -04:00
|
|
|
// PUSH CONSTANTS
|
|
|
|
|
layout(push_constant) uniform PushConstants {
|
|
|
|
|
mat4 model;
|
|
|
|
|
} pushConstants;
|
|
|
|
|
|
|
|
|
|
// OUTPUTS to Fragment Shader
|
|
|
|
|
layout(location = 0) out vec3 fragNormal; // Location 0 for Normal
|
|
|
|
|
layout(location = 1) out vec2 fragTexCoord; // Location 1 for TexCoord
|
2025-03-28 16:33:40 -04:00
|
|
|
|
|
|
|
|
void main() {
|
2025-04-05 20:54:38 -04:00
|
|
|
vec4 worldPos = pushConstants.model * vec4(inPosition, 1.0);
|
|
|
|
|
|
|
|
|
|
// Calculate final position
|
|
|
|
|
gl_Position = ubo.proj * ubo.view * worldPos;
|
|
|
|
|
|
|
|
|
|
// --- Pass attributes to Fragment Shader ---
|
|
|
|
|
|
|
|
|
|
// Pass world-space normal (adjust calculation if needed)
|
|
|
|
|
// Ensure fragNormal is assigned a vec3
|
|
|
|
|
fragNormal = normalize(mat3(transpose(inverse(pushConstants.model))) * inNormal);
|
2025-04-01 21:41:24 -04:00
|
|
|
|
2025-04-05 20:54:38 -04:00
|
|
|
// Pass texture coordinates (ensure inTexCoord is vec2)
|
|
|
|
|
// Ensure fragTexCoord is assigned a vec2
|
|
|
|
|
fragTexCoord = inTexCoord;
|
2025-03-28 16:33:40 -04:00
|
|
|
}
|