25. Mathematics of Lighting and Shading part - 1
Dated: 01-07-2025
Lights and Materials
Light
can have following properties
Color
(rgb
)- Intensity
- Attenuation (a
function
1 oflight intensity
whereintensity
decreases as distance from light source increases) - Shapes
- Positions
Light
interact with the material surface
in following ways
- Surface bounce
- Absorption
- Transmission
- Scattering
Materials
are described using the following colors
- Ambient
- Diffuse
- Specular
- Emissive
Emissive lights
are for objects which generate their own light
and ambient
is usually grouped with specular
.
Ambient Lighting
It's a global value that is added to each object in the scene
and is used general environmental illumination. It is the general color of objects due to the global ambient light
level.
Diffuse Lighting
It is the color
of the object due to specific light effect on an object (matte
). The light is reflected in all directions and depends only on the able between the incident light array and surface normal
.2
Specular Lighting
It is the color
of the highlights on the surface. The specular light
mimics the shininess of a surface, and its intensity
is a function
1 of the light
's reflection angle off the surface.
Emissive Lighting
These are lights emitted by the objects themselves. Shading
is simply calculating the color reflected off a surface (which is pretty much what shaders
do). When a light reflects off a surface, the light colors are modulated by the surface color
(typically, the diffuse or ambient surface color).
Let \(l = (r_l, g_l, b_l)\) be the color
of light
and \(s = (r_s, g_s, b_s)\) be color
of the surface
then the resulting color
is
So a shader
might typically do the following:
- Calculate the overall ambient light on a
surface
. - For each
light
in a scene, calculate thediffuse
andspecular contribution
for eachlight
. - Calculate any emissive light for a
surface
. - Add all these
lights
together to calculate the finalcolor
value.
For materials
like metal
(conductive), most of the light
is reflected and for dielectrics
(non conductive), most of it is penetrates.
The dispersion of light
is a function
1 of the roughness
of the surface
.
Light dispersion
Sub surface scattering
3 Shader passes into final lighting