feat: add ambient component to fragment shader for Phong shading start
This commit is contained in:
@@ -6,7 +6,13 @@ in vec3 vNormal;
|
||||
|
||||
void main() {
|
||||
vec3 lightDirection = normalize(vec3(0.8, -0.5, 0.6));
|
||||
// ambient component
|
||||
float ambientStrength = 0.1;
|
||||
vec3 ambient = ambientStrength * vColor.rgb;
|
||||
// diffuse component (Lambert)
|
||||
float lambert = max(0.0, dot(normalize(vNormal), -lightDirection));
|
||||
vec3 litColor = vColor.rgb * lambert;
|
||||
color = vec4(litColor, vColor.a);
|
||||
vec3 diffuse = vColor.rgb * lambert;
|
||||
// combine ambient and diffuse
|
||||
vec3 result = ambient + diffuse;
|
||||
color = vec4(result, vColor.a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user