minecraftvulkan/res/shaders/simple_shader.vert
2022-09-25 23:08:03 -04:00

36 lines
843 B
GLSL
Executable file

#version 450
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 uv;
layout (location = 0) out vec3 fragColor;
layout (location = 1) out vec2 fragUv;
layout (binding = 0) uniform GlobalUbo {
mat4 projectionViewMatrix;
vec3 directionToLight;
} ubo;
layout (binding = 2) uniform Deez {
mat4 projectionViewMatrix;
vec3 directionToLight;
} deez;
layout (push_constant) uniform Push {
mat4 modelMatrix;
mat4 normalMatrix;
} push;
const float AMBIENT = 0.02;
void main() {
gl_Position = ubo.projectionViewMatrix * push.modelMatrix * vec4(position, 1.0);
vec3 normalWorldSpace = normalize(mat3(push.normalMatrix) * normal);
float lightIntensity = AMBIENT + max(dot(normalWorldSpace, ubo.directionToLight), 0);
fragColor = lightIntensity * vec3(1);
fragUv = uv;
}