fix: add normal-based diffuse lighting so cube is visible as 3D
- Fragment shader: directional light dot(normal, lightDir) with 0.2 ambient - Vertex shader: pass normal through mat3(model) to fragment - Same-color faces now have different shading based on orientation
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 fragColor;
|
||||
layout(location = 1) in vec3 fragNormal;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = vec4(fragColor, 1.0);
|
||||
vec3 lightDir = normalize(vec3(0.5, 0.8, 0.3));
|
||||
float diff = max(dot(normalize(fragNormal), lightDir), 0.2);
|
||||
outColor = vec4(fragColor * diff, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user