Shaders Lighting Introduction
Basic Lightings
Ambient Lighting
An object in ambient light appears as if there is a light source somewhere in the same room, even though the light isn’t being cast directly onto it.
Usually in shader you return whatever the texture color is and multiply it with ambient strength or color like below:
I = Kd ** Cl \ Cm
where,
I is the ambient light result,
Kd is the diffuse coefficient (0 - 1),
Cl is the light color intensity, and
Cm is the material color or texture color of the object/mesh
Diffuse Lighting
Formula to calculate it is:
I = Kd \ Cl * Cm \ max(0, N.L)
where,
I is the diffuse light result,
Kd is the diffuse coefficient (0 - 1),
Cl is the light color intensity,
Cm is the material color or texture color of the object/mesh,
N is the normalized vector of the world normal of the vertex point,
L is the normalized vector of the direction of the light source (not from the source but the direction to the source),
Specular Lighting