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:
@@ -5,6 +5,7 @@ layout(location = 1) in vec3 inColor;
|
||||
layout(location = 2) in vec3 inNormal;
|
||||
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
layout(location = 1) out vec3 fragNormal;
|
||||
|
||||
layout(row_major, set = 0, binding = 0) uniform CameraUBO {
|
||||
mat4 vp;
|
||||
@@ -17,4 +18,5 @@ layout(row_major, push_constant) uniform PC {
|
||||
void main() {
|
||||
gl_Position = vp * pc.model * vec4(inPosition, 1.0);
|
||||
fragColor = inColor;
|
||||
fragNormal = mat3(pc.model) * inNormal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user