0% found this document useful (0 votes)
52 views7 pages

10 - Illumination and Shading

The document discusses illumination and shading in computer graphics. It defines illumination as the transport of energy from light sources to surfaces, both directly and indirectly. Shading is defined as the process of assigning colors to pixels based on a surface rendering or shading method. The document discusses empirical and physically-based illumination models, and notes that illumination models attempt to approximate observed lighting phenomena while physics-based models are based on actual light interaction properties. It also discusses the components involved in illumination like light sources, surfaces, and the use of an ambient light source to model indirect illumination.

Uploaded by

anju pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views7 pages

10 - Illumination and Shading

The document discusses illumination and shading in computer graphics. It defines illumination as the transport of energy from light sources to surfaces, both directly and indirectly. Shading is defined as the process of assigning colors to pixels based on a surface rendering or shading method. The document discusses empirical and physically-based illumination models, and notes that illumination models attempt to approximate observed lighting phenomena while physics-based models are based on actual light interaction properties. It also discusses the components involved in illumination like light sources, surfaces, and the use of an ambient light source to model indirect illumination.

Uploaded by

anju pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Illumination

ƒ So…given a 3-D triangle and a 3-D


Lecture 10 viewpoint, we can set the right pixels
ƒ But what color should those pixels be?
ƒ If we’re attempting to create a realistic
image, we need to simulate the lighting of
Illumination and shading the surfaces in the scene
- Fundamentally simulation of physics and
optics

Computer Graphics and Visualization


2 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Some definitions! Definitions


ƒ Illumination model, lighting model, shading ƒ Illumination: the transport of energy (luminous flux
model, surface rendering, shading method, of visible light) from lightsources to surfaces,
indirect and direct.
surface lighting effects......????
ƒ Often a confusion between lighting and shading
ƒ Lighting
ƒ Baker & Hearn took some heavy stuff while - The process of computing the luminous intensity
writing page 557! (outgoing light) at a particular 3D point.
- Illumination model (shading model!) (Hearn Baker)
ƒ Shading
- The process of assigning colors to pixels
- Surface-rendering method (Hearn Baker)

3 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
4 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Definitions Illumination
Fundamentally: Empirical illumination model
ƒ CG is about modelling the interaction of
electromagnetic energy within the objects of a
ƒ Tries to formulate approximations of
scene. observed phenomenon
ƒ What we see, is the light (electromagnetic energy ƒ Phong illumination model (OpenGL),
in the spectrum of visual light) that hits the eyes. Raytracing
ƒ Involves a number of things:
- Material properties Physically-based
Object position relative to lightsources and other objects
-
ƒ Models based on the actual physics of light
- Feature of light sources
interacting with matter
ƒ Radiosity, Photonmapping
5 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
6 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

1
Components Ambient Light Source
Light sources Simplification ƒ Due to reflections onto other objects, even object
ƒ Emitters of radiant energy ƒ Only direct illumination from that are not directly lit by a lightsource are visible
ƒ Geometric attributes the emitters to the reflectors
of the scene ƒ To model indirect illumination a hack called
- Position
- Direction ƒ Ignore Geometry of emitters Ambient light source is used
- Shape - No position nor direction.
ƒ Spectrum of emittance , - Constant for all surfaces in the scene
Color
- Can have colour
ƒ Directional attenuation
- Independent on objects orientation and position.
Surfaces
- Surface properties are used to determine how much
ƒ Reflecting spectrum (Color)
ambient light is reflected
ƒ Geometry (position,
orientation and micro
structure)
7 ƒ Absorption 8
Anders Backman Anders Backman
Computer Graphics and Visualization Department of Computing Science, Umeå University Computer Graphics and Visualization Department of Computing Science, Umeå University

Light sources Light sources


ƒ Point light sources ƒ Infinitely Distant Light Sources
- Approximates a lightbulb ƒ Attributes
ƒ Attributes - Direction
- Position - Color
- Colour ƒ The SUN!
ƒ Light are generated radially
ƒ Reasonable approximation for sources that ƒ Little variation in directional effects
are small compared to objects in the scene

9 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
10 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Lightsources Light source


ƒ Radial Intensity Attenuation Directional light sources
ƒ Requires the calculation of a normalied light
- Light source is attenuated by a factor 1/d2 direction:
- A surface close lightsource recieves higher d=
p−l
incident light intensity p−l

- 1/d2 does not produce acceptal result ƒ The angular distance of the object
from the light can be used:
- The problem: real lightsources are not
infitesimal small! (point sources) Vobj • Vlight = cosα

- Solution: ƒ If we for example restrict the cone to 0 < θl <= 90 and



⎪ Then the object is outside the cone of light
⎪ 1.0, If source is at infinity
f l , radatten =⎨
⎪ 1 If source is local Vobj • Vlight < cos θ l
⎪⎩ a0 + a1d1 + a2 d l 2
11 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
12 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

2
Light sources Light sources
ƒ Angular Intensity Attenuation Area Light Sources
ƒ Spotlight
ƒ Occupies a 2D area
ƒ Attenuate the light intensity about
the cone axis vector. ƒ Generates soft shadows, WHY?
ƒ Highest intensity in center of cone


⎪ 1.0, If source is not a spotlight

f l , angatten =⎨ 0.0, If (Vobj • Vlight ) = cos α < cos θ l

⎪(Vobj • Vlight ) ,
al

⎩ otherwise

13 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
14 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Surface Lighting effects Surface Lighting Effects


Surface properties Ambient Lighting model
ƒ Transparecy ƒ Light coming from other objects
ƒ Reflectance coefficients Diffuse Lighting model
ƒ Texture ƒ Light reflected equally in all directions

ƒ When light hits an opaque surface parts of


Specular Lighting model
it is reflected and parts is absorbed. ƒ Light reflected in the area of the reflection
ƒ For transparent surfaces some light are vector between the view and light vector
also transmitted through the material
15 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
16 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Ambient lighting Diffuse reflection


ƒ Not dependent on light, view or object ƒ Rough surfaces scatter
direction, nor distance to anything else reflected light many directions
ƒ This is due to microscopic
ƒ Surface parameter ka - amount of reflected variations in the surface.
ambient light from surface.
ƒ An IDEAL DIFFUSE
ƒ Ilambient = ka Il REFLECTOR
- Will reflect incoming light equally
in all outgoing directions
independent from the view
direction
ƒ Chalk is an approximation for an
ideal surface
17 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
18 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

3
Diffuse
Computing Diffuse reflection reflection
Ideal diffuse surfaces ƒ We can model the amount of incident light on a surface with
a source with intensity Il such as:
ƒ Also called Lambertian reflectors
Idiffuse = I cos(θ) Error on
ƒ Reflected radiant light energy from any point on the surface
ƒ With a surface property to control the amount page 565
is calculated with Lamberts cosine law
of reflected diffuse light kd we have:
radiant energy per unit time ldiffuse = I kd cos(θ) Last
Intensity =
projected area ƒ Rember dot product, V1·V2=cos(θ), then we get: paragraph!
N
Idiffuse = I kd N·L,
θN where N and L must be normalized (have length 1)
θN INCOMING
LIGHT

ƒ Amount of radiant energy coming from any small surface dA


in a direction θN relative to the surface normal is proportional
to cosθN
19 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
20 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Diffuse +
Diffuse reflection Ambient lighting
ƒ An illumination modelleling example only
considering diffuse reflection
ƒ As we only consider angles in the range of 0° to 90°.
ƒ Greater angles, where N·L is below zero, the light is
blocked by the surface and the reflected energy is 0
ƒ So adding the Ambient (background) and the Diffuse
lighting equation together results in:
⎧k I + k I ( N • L ) , if N • L>0
I l , diff + amb = ⎨ a a d l
⎩ ka I a , if N • L ≤ 0

21 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
22 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Specular reflection Specular reflection


ƒ When we look at a shiny surface, polished ƒ Reflection behaves according to Snells laws which
metal, we see a highlight, or a bright spot. state:
nlsin(θl)=nrsin(θr)
ƒ This spot is view-dependent, that is it is ƒ The incoming ray, the surface normal, and the
related to the viewers position in relation to reflected ray all lie in a common plane.
the surface normal of the object and the ƒ The angle that the reflected ray forms with the
lights incoming direction. surface normal is determined by the angle that the
ƒ An ideal mirror is a purely specular incoming ray forms with the mediums (nl, nr) in
reflector. which the incident and reflected rays propagate.
ƒ Reflection is a special case, where the incidents
light medium and the reflected rays medium is the
same, which gives that: nl=nr → θl = θr
23 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
24 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

4
Specular reflection Phong Bui Toung!
ƒ Snells law applies only to ideal
mirror reflectors. Real materials ƒ A model for approximating the non ideal reflection
deviates significantly from ideal is the Phong specular-reflection model where V is
reflectors. the unit vector in the direction of the viewer and R
ƒ In general, we expect most of the reflected light to is the mirror reflection direction.
travel in the direction of the ideal reflection
⎪⎧k I (V • R ) s , if V • R > 0 and N • L>0
n
direction. But due to microscopic variations in the Il , spec = ⎨ s l
reflector (surface) the some of the reflected light ⎪⎩ 0.0, if V • R < 0 or N • L ≤ 0
scatters in different directions.
ƒ As we as a viewer moves out from the reflection ƒ The reflection vector R can be calculated as:

(
R + L = 2( N • L ) N )
vector, we expect to see less light reflected.

25 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
26 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Phong Constant Specular lighting


ƒ ns controlles the ”size” of the reflection lobe ƒ Adding ambient, diffuse and specular
together results in the following lighting
equation:
⎪⎧k I + k I ( N • L ) + ks Il (V • R ) s , if V • R > 0 and N • L>0
n

Il ,diff + amb+ spec = ⎨ a a d l


⎪⎩ k I
a a , if V • R < 0 or N • L ≤ 0

ƒ Which is the basic lighting equation for


computer graphics.
ƒ Its empirical, not physical!

ns=5 ns=30
27 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
28 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Final result! Shading


ƒ Or surface rendering!
What about colors then? Red, Blue, Green?
ƒ Up to this point we have discussed how to
ƒ One lighting equation per color...
compute the illumination model at a point
Several lightsources? on a surface. At which point should we
ƒ Iterate over all lightsources and add the result, apply the model? Where and how often it is
per color. applied has a noticable effect on the end
result.

∑ I ( k ( N • L ) + k (V • R ) )
Il ,diff + amb+ spec = ka I a +
nlights
ns ƒ Calculating the illumination model is costly,
i =1
l d s
including several normalizations of vectors.

29 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
30 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

5
Flat Shading Flat shading
ƒ Applying the illumination ƒ Introducing normals on the
calculation once per primitive surface
(quad, triangle, ...)
ƒ Used for back face culling etc..
ƒ Constant intensity surface
rendering (Hearn Baker) ƒ One normal for each primitive
is obviously not enough.
Issues:
ƒ Vertex normals can be
ƒ For point light sources, the calculated by averaging the
direction light varies over the
primitive. normals sharing that vertex.
ƒ For specular reflections the
direction to the eye varies k
ni
1 nv = ∑
numvertices
over the primitive. centroid = ∑ pi
numvertices i =1 ni
ƒ Illumination is usually i =1
calculated at the centroid of
the primitive.

31 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
32 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Goraud Shading Phong Shading


ƒ Intensity-interpolation surface rendering ƒ Not the same thing as Phong’s illumination model!
ƒ The Goraud shading method applies the Shading ≠ Illumination
illumination model at several positions of a ƒ Illumination model applied
primitive, usually per vertex. The result is then to every point on the
interpolated over the facet (primitive). primitives surface.
ƒ Still artefacts are present, highligts sometimes ƒ Requires a normal per vertex
shows anomalies, Mach bands (as Gouraud)
ƒ Interpolates the normals over
each point on the surface
(Gouraud interpolates colors!)
Scanline
ƒ Drawbacks
Mach bands
- Computational demanding
33 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
34 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Phong Shading Comparison, where is the Phongie?

ƒ Up until for a couple of years ago, phong


shading was not possible in realtime for
larger models.
ƒ GPU enables that,
(Graphics Processor Unit)
ƒ A very short shader code snippet will do
the phong shading for you...

35 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
36 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

6
Other effects Other effects
Transparent surfaces Transparent surfaces
An object with ƒ When light enters a transparent
ƒ Simple transparency equation: transparency kt surface, the direction of the light beam changes direction
I = (1-kt)Irefl+ktItransparency according to Snell’s law: nlsin(θl) = nrsin(θr)
ƒ Refraction index n depends on temperatur, and the wavelength
of the light. Therefore light can scatter into several rays of
different color (prisma!)
A ƒ For Air n=1, for water we have n=1.33, using those two refraction
Irefl index we can calculate the refraction direction.
ƒ If we follow the refraction ray and get the color information which
it contributes to the image, we could get something like:
The color of the
background behind
Itrans
object A
37 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University
38 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

Is this all?
ƒ So we can land on the moon, thinking of going to
Mars, and the Phong illumination model is all we
can do?
ƒ No there are a lot more
ƒ One exampel is Cook-Torrance-Illumination

ƒ Takes into account, microfacet distribution,


geometric attenuation, fresnel conductance term.

39 Computer Graphics and Visualization


Anders Backman
Department of Computing Science, Umeå University
40 Computer Graphics and Visualization
Anders Backman
Department of Computing Science, Umeå University

You might also like