Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Shading

What Should Be The Pixel Color?

Image

Image: Nikon D40

Image: Stanford bunny


surface mesh (courtesy Pixels
Pixel Color
of Stanford Univ.).

Scene Determined by
Lighting/Shading
Lighting and Material Appearance
Inputfor realistic rendering
Geometry, Lighting and Materials
Material appearance
Intensity and shape of highlights
Glossiness
Color
Spatial variation, i.e., texture

Images from Slide Addy Ngan


Light Sources
Images by Unity
4common light types
Point light Directional lights
Point lights
Directional lights
Spotlights
Area lights

Spotlight Area lights


Point lights

Assume isotropic
Intensity as function of distance
1/r2 fall-off for isotropic point lights
An isotropic point light outputs constant
power per solid angle (“into all directions”) r2
r1
Must have same power in all
concentric spheres
Sphere’s surface area grows with r2 =>
energy obeys 1/r2
Incoming Irradiance
The amount of light energy received by a
surface
Power incident on a surface - Radiant flux
density n
depends on incoming angle θ
Bigger at normal incidence, even if
distance is const.
Similar to winter/summer difference l
How exactly?
Cos θ law
Dot product with normal x Surface
Incoming Irradiance for Point lights
Let’s combine this with the 1/r2 fall-off:

𝐿𝑖𝑛 = 𝐿𝑖 cos 𝜃 Τ𝑟 2
n
Lin is the irradiance (“intensity”) at θ
surface point x
Li is the “intensity” of the light
θ is the angle between light direction l l
and surface normal n
r is the distance between light and x.
x Surface
Directional Lights
“Pointlights that are infinitely far”
No falloff, just one direction and one
intensity
n l
𝐿𝑖𝑛 = 𝐿𝑖 cos 𝜃 θ
Lin is the irradiance at surface point x
from the directional light
Li is the “intensity” of the light
θ is the angle between light direction l
and surface normal n
Only depends on n, not x! x Surface
Spotlights
Point lights with non-uniform directional emission
Usually symmetric about a central
direction d, with angular falloff
Often two angles
“Hotspot” angle:
No attenuation within the central cone
“Falloff” angle: Light attenuates
from full intensity to zero intensity
between the hotspot and falloff d
angles
Plus your favorite distance falloff curve
Spotlight Geometry

(direction d)

hotspot angle
POVRAY documentation
Adapted from
Area lights
Usefulfor distribution ray tracing
e.g., soft shadows
Can be approximated by set of point lights
Same 1/r2 fall-off for intensity one shadow ray
(to random location)

lots of shadow rays


Material Appearance
How it reflects light
How much given input light intensity is reflected
Shaded color:

𝐿𝑜 = ? 𝐿 𝑖 𝐿𝑖 Incoming
𝐿𝑜
direction

Outgoing
direction
Material Appearance
How it reflects light
How much given input light intensity is reflected
Shaded color:

𝐿𝑜 = ? 𝐿 𝑖
Material Appearance
How it reflects light
How much given input light intensity is reflected
Shaded color:

𝐿𝑜 = ? 𝐿 𝑖
Depends on
Where is the light source
Where is the camera
Material Appearance
How it reflects light
How much given input light intensity is reflected
Shaded color:

𝐿𝑜 = ? 𝐿 𝑖
Depends on
Where is the light source l
l v
Where is the camera v
Material Appearance
How it reflects light
How much given input light intensity is reflected
Shaded color:

𝐿𝑜 = ? 𝐿 𝑖
Depends on
Where is the light source l
l v
Where is the camera v
Need to model the relationship
between 𝐿𝑜 and 𝐿𝑖
Phong Illumination Model
Empirical model of the location illumination of
points on a surface
Bui Tuong Phong, 1975
Ideal Diffuse Reflectance
Assume surface reflects equally in all directions.
An ideal diffuse surface is, at the microscopic
level, a very rough surface.
Example: chalk, clay, some paints

Surface
Ideal Diffuse Reflectance
Ideal diffuse reflectors reflect light according to
Lambert’s cosine law
 also called Lambertian reflectance
The reflected light varies with cosine even if
distance to light source is kept constant

Lambert’s Cosine Law


Ideal Diffuse Reflectance
Brightness isproportional to cos(θ) because a
surface (a) perpendicular to the light direction
is more illuminated than a surface (b) at an
oblique angle
Ideal Diffuse Reflectance Math
Single Point Light Source

Light direction Light intensity

n
θ r
Shaded color Surface normal Distance to source l
diffuse coefficient
(color)

Surface
Non-Ideal Reflectors
Real glossy materials usually deviate significantly
from ideal mirror reflectors
Highlight is blurry
They are not ideal diffuse surfaces either …
Non-ideal Reflectors
Simple Empirical Reasoning for Glossy Materials
Most of the reflected light to travel in the
direction of the ideal mirror ray.
Microscopic surface variations → some of
the light to be reflected just slightly offset
from the ideal reflected ray.
As we move farther and farther, in the
angular sense, from the reflected ray, we
expect to see less light reflected.
The Phong Specular Model
How much light is reflected?
Depends on the angle  between the ideal
reflection direction r and the viewer direction v.

n
r
 θ θ l
Camera
v
Surface
The Phong Specular Model

Parameters
ks: specular reflection coefficient (overall scale)
q : specular reflection exponent n
r
 θ θ l
Camera
v
Surface
The Phong Specular Model
Effect of q – the specular reflection exponent

small q

large q
Terminology – Specular Lobe
The specular reflection distribution
is usually called a “lobe”
For Phong, its shape is

Surface
Ambient Illumination
Represents the reflection
of all indirect illumination.
This is a total hack!
Avoids the complexity of
indirect (“global”)
illumination
The Complete Phong Model
Sum of three components:
ideal diffuse reflection +
specular reflection + Specular reflection
ambient

Ideal diffuse
reflection

Surface
Putting It All Together
 Phong Illumination Model
Demo
https://threejs.org/docs/scenes/material-browser.html#MeshPhongMaterial

You might also like