vulkan-test/shaders/vertex.glsl
2024-11-15 21:25:10 -05:00

29 lines
769 B
GLSL

#version 450
layout(binding = 0) uniform UniformBufferObject {
mat4 model;
mat4 view;
mat4 proj;
} ubo;
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 3) in vec3 inNormal;
layout(location = 0) out vec3 fragColor;
layout(location = 1) out vec2 fragTexCoord;
layout(location = 2) out vec3 fragNormal;
layout(location = 3) out vec3 fragWorldPos;
void main() {
vec4 worldPos = ubo.model * vec4(inPosition, 1.0);
gl_Position = ubo.proj * ubo.view * worldPos;
// Transform normal to world space
fragNormal = mat3(transpose(inverse(ubo.model))) * inNormal;
fragWorldPos = worldPos.xyz;
fragColor = inColor;
fragTexCoord = inTexCoord;
}