diff --git a/shaders/simple_shader.frag b/shaders/simple_shader.frag index c10c04fa..1336d398 100644 --- a/shaders/simple_shader.frag +++ b/shaders/simple_shader.frag @@ -2,11 +2,15 @@ layout(set = 0, binding = 1) uniform sampler2D tex; -layout(location = 0) in vec3 fragColor; +layout(location = 0) in vec3 fragNormal; layout(location = 1) in vec2 fragTexCoord; layout(location = 0) out vec4 outColor; -void main() { - outColor = texture(tex, fragTexCoord); +void main() +{ + vec3 normal = abs(normalize(fragNormal)); + float intensity = normal.x * 0.200 + normal.y * 0.500 + normal.z * 0.800; + + outColor = texture(tex, fragTexCoord) * intensity; } diff --git a/shaders/simple_shader.vert b/shaders/simple_shader.vert index 124d54da..ff5b39f7 100644 --- a/shaders/simple_shader.vert +++ b/shaders/simple_shader.vert @@ -1,11 +1,13 @@ #version 450 -layout(set = 0, binding = 0) uniform CameraMatrices { +layout(set = 0, binding = 0) uniform CameraMatrices +{ mat4 view; mat4 projection; }cm; -layout(push_constant) uniform PushConstants { +layout(push_constant) uniform PushConstants +{ mat4 model; }pc; @@ -13,11 +15,12 @@ layout(location = 0) in ivec3 positions; layout(location = 1) in vec3 normal; layout(location = 2) in vec2 texCoords; -layout(location = 0) out vec3 fragColor; +layout(location = 0) out vec3 fragNormal; layout(location = 1) out vec2 fragTexCoords; -void main() { +void main() +{ gl_Position = cm.projection * cm.view * pc.model * vec4(positions, 1.0); - fragColor = normal; + fragNormal = normal; fragTexCoords = texCoords; }