Files
HelloVulkan/shaders/simple_shader.vert
T

39 lines
843 B
GLSL

#version 450
const int MAX_LIGHTS = 4;
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 view;
mat4 proj;
vec4 ambientColor;
Light lights[MAX_LIGHTS];
} ubo;
void main() {
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;
}