Illumination
Overview of Lighting
Different types of lighting (diffuse, specular, ambient,
etc.)
In almost all cases, we need to know about how light
bounces off of a surface
This means knowing about the normal at the intersection
point
Ray Tracing
In 3D computer graphics, ray tracing is a technique for
modeling light transport for use in a wide variety
of rendering algorithms for generating digital images.
Ray tracing is capable of simulating a variety
of optical effects, such as reflection, refraction, soft
shadows, scattering, depth of field, motion
blur, caustics, ambient occlusion and dispersion
phenomena (such as chromatic aberration).
Ray Tracing
Ray Tracing
The ray-tracing
algorithm builds an
image by extending
rays into a scene and
bouncing them off
surfaces and towards
sources of light to
approximate the color
value of pixels.
Ray Tracing
Ray Tracing
Ray tracing can
create
photorealistic
images.
Ray Tracing
In addition to the high degree of realism, ray tracing can simulate the effects of a
camera due to depth of field and aperture shape
What is Light?
Can be thought of as small packets of photons
When an electron drops from a higher level orbit to a lower orbit,
energy is emitted as photons
Different energy levels of electrons allow for different wavelengths of
light to be reflected
Metals have “loose” electrons, which can move relatively freely and occupy
many different levels, which is why they are more reflective
Insulators have more constrained electrons which cannot change energy levels
as easily, so they convert more absorbed light into heat instead of reflecting it
What is Light?
Another way to think
of light is to treat it as a
continuous wave (as
opposed to discrete
photons)
The wavelength (𝜆) of a wave is measured as the distance from one
peak of wave to the next
Different colors correspond to different wavelengths
Visible light has a wavelength between 400nm – 700nm
Different ways of thinking about light (photons vs. waves)
can result in different rendering styles
Illumination
Problem:
In ray casting, we have generated a ray (from the eye through a
pixel), found the point in which the ray intersects with an
object
Now we want to determine the color and brightness of that
point so that we can color in the pixel
Solution: we model the interactions between light
sources and the surface
Illumination Models
An “illumination model” describes inputs,
assumptions, and outputs used to calculate
illumination (color / brightness) of surface
elements
Usually includes
Light attributes (intensity, color, position, direction, shape)
Object surface properties (color, reflectivity, transparency, etc.)
Interaction between lights and objects
Illumination Models
Physically-based Illumination Models
Some models of illumination are based on real physics
Require accurate input data and make few assumptions
Rarely have enough information to specify all inputs
Takes a long time to compute
Non-Physically-Based Illumination Models
Just need a model that looks good enough for a specific
application
Emphasis on speed and efficiency (use of resources like
memory, CPU, etc.)
Light Attenuation: Inverse Square Law
The amount that a light illuminates an object decreases with
the square of the distance between them. This is known as
Light Attenuation.
Inverse square law: for a given 3D angle (solid angle), the area it
covers grows with the square of the distance
Intensity of light per unit area falls off with the inverse square
Conversely, for a fixed area, the angle it covers decreases with the square
of the distance
Basic Light Sources
As part of illumination models, one can specify
whether the light intensity varies with the distance
between the object and the light source
Illumination Models
Local Illumination
Takes only direct lighting information
Is an approximation of global illumination
Usually involves the use of an “ambient” term to simulate
indirect lighting
Global Illumination
Most light striking a surface element comes directly from a
light emitting source (direct illumination)
Sometimes light from a source is blocked by another object,
resulting in shadows
However, objects in the shadow can still receive light from light
bouncing off other objects (indirect illumination)
Example 1: Local Illumination
Only considers the light, the observer position, and
the object’s material properties
OpenGL does this.
Example 2: Global Illumination
Takes into account of the interaction of light from
all the surfaces in the scene
Recursive ray tracing is an example. It models light
rays bouncing between objects
Example 3: Global Illumination, Radiosity
Models energy moving
from emitters (light
sources) into the scene
as patches
Is view independent
Examples of Global Illumination
Direct illumination + specular reflection + soft shadows and caustics + diffuse reflection (color bleeding)
Ray trace Ray trace + caustic photon map Ray trace + caustic and diffuse photon maps
Simple Local Illumination (Phong)
The model used by OpenGL
Reduce the light model to 3 simple components:
Ambient
Diffuse
Specular
Illumination (color intensity) of a point is equal to:
Intensity = ambient + diffuse + specular
Materials reflect each component differently
Specified as material reflection coefficients: 𝐾𝑎 , 𝐾𝑑 , 𝐾𝑠
Ambient Light Contribution
Ambient light = background light
As noted before, it is used to simulate indirect lighting
Ambient component
Independent of
Object’s position
Viewer’s position
Light source’s position
Dependent of
A constant factor (in each of the R, G, B channels)
Diffuse Light Contribution
Diffuse light = illumination that a surface receives
from a light source that reflects equally in all
directions
Independent of:
Viewer’s position
Dependent of:
Light’s position
Surface property (normal, reflectance property)
Diffuse Light Calculation
Need to know how much light a point on the object
receives from the light source
Solution based on Lambert’s Law
Point receives more light Point receives less light
Diffuse Light Calculation
Lambert’s Law: The radiant energy D that a small surface
patch (or a point) receives from a light source is:
Diffuse = 𝐾𝑑 𝑥 𝐼 𝑥 cos(𝜃)
𝐾𝑑 = diffuse reflection constant
I = light intensity
𝜃 = angle between the light vector and the surface normal
How do we compute cos(𝜃)?
𝑁 ∙ 𝐿 (dot product between N and L)
As the angle between the light The hemisphere represents
and the normal increases, the equal magnitude of the reflected
light’s energy spreads across a intensity for any outgoing
larger area vector.
Diffuse Light Examples
Diffuse = 𝐾𝑑 𝑥 𝐼 𝑥 cos(𝜃)
For I = 1.0
Specular Light Contribution
Specular light = light reflection from shiny surfaces
Color depends on material and how it scatters light
Shiny surfaces (metal, mirror, etc.) reflect more light
Specular light depends on both light source position
and view position
Specular Light Calculation
𝜙 is the angle between the view direction and the
reflective vector
When 𝜙 is small, the viewer sees more specular
light
Specular Light Calculation
The Phong lighting model (not the Phong shading model)
Specular = 𝐾𝑠 𝑥 𝐼 𝑥 cos 𝑓 (𝜙)
𝐾𝑠 = specular reflection constant
𝐼 = light intensity
𝜙 = angle between reflective ray and view vector
𝑓 = surface property for specular highlight
Specular Light Calculation
Specular = 𝐾𝑠 𝑥 𝐼 𝑥 cos𝑓 (𝜙)
Diffuse hemisphere with specular Shape of the Gaussian
Gaussian surface
Specular Light Examples
Specular = 𝐾𝑠 𝑥 𝐼 𝑥 cos𝑓 (𝜙)
For I = 1.0
Variation in Diffuse and Specular
Putting Diffuse and Specular together in our local
illumination model
Lighting Equation
Direct Illumination = ambient + diffuse + specular
color =𝐾𝑎 𝑥 𝐼 + 𝐾𝑑 𝑥 𝐼 𝑥 (𝑁 ∙ 𝐿) + 𝐾𝑠 𝑥 𝐼 𝑥 𝑅 ∙ 𝑉 𝑓
If there are m lights, we sum over each light
color =𝐾𝑎 𝑥 𝐼 + σ𝑚(𝐾𝑑 𝑥 𝐼𝑚 𝑥 (𝑁 ∙ 𝐿𝑚 ) + 𝐾𝑠 𝑥 𝐼𝑚 𝑥 𝑅𝑚 ∙ 𝑉 𝑓 )
color =𝐾𝑎 𝑥 𝐼 + σ𝑚 𝐼𝑚 𝑥 (𝐾𝑑 𝑥 (𝑁 ∙ 𝐿𝑚 ) + 𝐾𝑠 𝑥 𝑅𝑚 ∙ 𝑉 𝑓 )
Cukup Sekian