Overview
Lighting is an important factor to consider while rendering realistic 3D shapes. The following discusses adapting lighting conditions while rendering 3D images.
Details
According to physics, visible light is made up of a band of different wavelengths. Each segment has a designated color that human eye can detect.
When light is shone on an object, it absorbs some wavelengths and reflects some giving out the color based on the material property of the object.
The reflection is different based on its proximity to the light source and the angle between its position and the light source. Therefore light calculations should factor these.
The calculations primarily considers three kinds of light sources.
Ambient
Ambient light means that light always existed in absence of a light source. Imagine a unlit room next to the street where light is coming in from a street lamp through the window bouncing off the walls onto curtains, furniture etc. It's dark, yet curtains, furnitures etc are visible albeit not clearly.
This pictorially represented as below
I = Ka ∑ Ia
Ka is the ambient reflection coefficient that ranges from 0 to 1. Higher the value stronger is the reflection.
Ia is global ambient intensity of the individual light source.
Example:
In this example, the Red light falls on Gray object. Here the 3rd image shows ambient lighting of the the back face of the sphere where lighting is same everywhere.
Diffused light means that directional light that is reflected equally irrespective of user view point.
The effectiveness of the reflection depends on the angle of incidence and the surface normal. In other words, the cross product of both. The lesser the value, higher is the reflection.
This pictorially represented as below.
To calculate the amount of diffuse reflection (I) on a surface, the formula below is used.
I = Kd Id (n.L)
Kd is the diffuse reflection coefficient that ranges from 0 to 1. Higher the value stronger is the reflection.
Id is the diffuse intensity of the light source.
(n.L) is the cross product of the surface normal n and light incident on the surface.
Example:
In this example, the red light falls on Gray object. Here the 3rd image represents the back face of the sphere where lighting is poor because of angle of incidence.
Specular Light
Specular light applies to smooth and polished surfaces that readily reflect light. When light hits the shiny surface it forms bright highlights.Here the reflection is targeted and is perpendicular to the angle of incidence in the opposite direction. A viewer can see only if in exactly the right position, somewhere along the path of the reflection r.
specular highlights on such a material are small and sharp. A duller surface will produce wider
cones of reflected light.
Specular reflection can be calculated as follows.
I = Ks Is max(0,(v⋅r))ᵖ
I = Ks Is max(0,(v⋅r))ᵖ
Ks is the specular reflection coefficient to determine how strong or weak the specular reflection appears.
Is is the brightness of the light source illuminating the surface.
r is (2 (l . n) n) - l
(v⋅r) is the cross product between the observer's line of view and the direction of the reflected light.
p is known as the Phong Exponent. As p increases, the light cone becomes narrower (because r⋅e ≤ 1), the highlighted spot becomes smaller.
max(0,(v⋅r))ᵖ controls the size and sharpness of the specular highlight, making it more or less focused depending on the value of p. The max returns 0 is returned if the v.r is negative.
Example
In this example, the White light source falls on Gray object. The 3rd image shows the specular reflection.
Emissive Light
Some surfaces such as ovens, TV screens etc may emit light. It's independent and can be directly factored. Emissive lighting represents a self-luminous glow that is additive, meaning it is added on top of the results of ambient, diffuse, and specular lighting.
I = KeIe
Ke is emissive light value.
Ke is emissive light intensity.
The following example shows a sphere with emissive lighting.
Material
As discussed earlier materials absorb some light wavelengths and reflect back remaining. Illumination models should also consider these in the calculations of ambient, diffuse and specular. In other words, three separate material reflection color, one each for ambient, diffuse and specular should be used for realistic renderings.
Phong Lighting Model
This combines all the three models discussed above - Ambient, Diffuse,Specular and attenuation.The combined formula combines all the three
I = KaIa + KdId(n.L) + KsIs(max(0,v⋅r)ᵖ) + KeIe
The image below combines ambient,diffuse and specular reflections resulting in highlight and the curvature.
This combines all the three models discussed above - Ambient, Diffuse and Specular same as Phong lighting model except specular component is calculated using the halfway vector h.
The combined formula combines all the three
I = Ka∑Ia + KdId(n.L) + KsIs(max(0,v⋅h)ᵖ)
h is (l+v) / |l+v|
The image below combines ambient,diffuse and specular reflections resulting in highlight and the curvature.
The image below combines ambient,diffuse and specular reflections resulting in highlight and the curvature.
These are the other light sources used to create realistic rendering.
Directional Light
Directional light refer to light sources such as sun where light reaches the objects irrespective of their location. Here the light source is assumed to be infinitely distant and intensity is same. Also the light rays are parallel to each other and are unidirectional.
In other words, Directional lights have only color and direction, not position.
Point Light
Point light emits light equally in all directions and also they have a position. Point lights have color and position within a scene, but no single direction.
However they suffer from attenuation where light gets waker over the distance.
Attenuation reduces light intensity based on distance, making objects further from a light source appear dimmer. Attenuation has no impact on ambient light. Attenuation is calculated as below.
d: Distance between the light source and the point on the surface.
Kc: Constant attenuation (usually 1.0) to prevent division by zero or small numbers.
Kl: Linear attenuation (reduces intensity proportionally to distance).
Kq: Quadratic attenuation (reduces intensity proportionally to the square of the distance, simulating physical reality).
The light bulb below illustrates a point light.
Spot Light
A spotlight is a light source that radiates light in a cone shape from a single point in a specific direction, designed to simulate real-world lights like flashlights or stage spotlights. This effect is achieved through a two-cone system that defines the intensity, producing a bright center and a soft, fading edge.
Spotlights have color, position, and direction in which they emit light.
Notice that color is brightest in the center and gradually fades outwards.
In order to calculate the fading, cosine value of the directional vector of the light and the vertex under the cone is used. Naturally as angle increases the cosine value decreases.









