You are on page 1of 10

Based on material

by Werner Purgathofer
Illumination Models
„ light sources
„ basic models
„ effects
‹ transparency
‹ atmospheric effects
‹…

Surface Rendering
Dieter Schmalstieg

Surface-Rendering Methods Light Sources


„ point light source
„ polygon rendering methods
„ directional point light source
„ environment mapping „ distributed light source (“area light source”)
„ texture mapping
„ bump mapping

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Surface Lighting Effects Basic Illumination Models


„ empirical models
diffuse reflection reflections from
other surfaces „ lighting calculations
‹ surface properties
(glossy, matte, opaque,…)
‹ background lighting conditions
‹ light-source specification
‹ reflection, absorption
specular reflection
„ ambient light (background light) Ia
‹ approximation of global diffuse lighting
effects

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

1
Ambient Light Reflection Illumination and Shading
„ constant over a surface „ shaded surfaces generate a spatial impression
„ independent of viewing direction
the flatter light falls on a surface,
„ diffuse-reflection coefficient kd (0≤ kd ≤1) the darker it will appear

„ therefore:
we need the incident light direction
I ambdiff = kd I a
or
the position of the (point) light source
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Lambert's Law Lambertian (Diffuse) Reflection


Ll „ ideal diffuse reflectors (Lambertian reflectors)
α
θ „ brightness depends on orientation of surface
Ll α
θ
. .

I = ILl · cos α
θ „ Lambert’s cosine law

when considering the material:


I l ,diff = kd I l cos θ
I = kd ⋅ Il ⋅ cos θ
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Diffuse Reflection Diffuse Reflection Coefficient


„ angle of incidence θ ∈ [0°,90°] ⇒ surface „ varying kd
illuminated
result for varying values of kd, Ia = 0

0 0.2 0.4 0.6 0.8 1

I l ,diff = kd I l ( N ⋅ L)
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

2
Ambient and Diffuse Reflection Specular Highlights
„ total diffuse reflection I l,diff = ka I a + kd I l ( N ⋅ L)

(sometimes this area must be lighter


ka for ambient than the shading model
light) calculates, because the
light source is reflected
directly into the viewer's
eye

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Specular Reflection Model Specular Reflection Coefficient ns


„ reflection of incident light around specular-
reflection angle
φφφ
64
128
8
cos256

cosns φ

„ empirical Phong model


I l,spec = I l cosns φ
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Specular Reflection Coefficient ns Specular Reflection Coefficient


cos φ „ empirical Phong model I l,spec = I l cosns φ
‹ ns large ⇒ shiny surface
cosns φ ‹ ns small ⇒ dull surface

cos64 φ

cos256 φ
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

3
Fresnel Specular Refl. Coefficient Simple Specular Reflection
„ Fresnel’s laws of Reflection „ W(θ) ≈ constant for many opaque materials (ks)
‹ specular reflection coefficient W(θ)

I l,spec = W (θ ) I l cosns φ I l,spec = ks I l (V ⋅ R) ns

specular reflection calculation of R:


coefficient as a
function of angle of R + L = ( 2 N ⋅ L) N
incidence for R = ( 2 N ⋅ L) N − L
different materials
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Specular Reflection Results Simplified Specular Reflection


I l,spec = ks I l (V ⋅ R) ns
„ simplified Phong model with halfway vector H
I spec = ks I l (V ⋅ R) ns → I spec = ks I l ( N ⋅ H ) ns

L +V
H=
L +V

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Diffuse and Specular Reflection Other Aspects


I = ka I a + ∑ I l [ kd ( N ⋅ Ll ) + ks (N ⋅ H l ) ns]
n
„ intensity attenuation with distance
l =1
„ anisotropic light sources (Warn model)
ambient
„ transparency (Snell’s law)
ambient „ atmospheric effects
ambient + diffuse
+ diffuse + specular „ shadows
„…

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

4
Polygon-Rendering Methods Polygon Shading: Interpolation
„ application of illumination model to polygon „ the shading of a polygon is not constant,
rendering because it normally is only an approximation
of the real surface ⇒ interpolation
„ constant-intensity shading (flat shading)
‹ single intensity for each polygon
Gouraud shading: intensities
Phong shading: normal vectors

flat Gouraud

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Gouraud Shading Overview Gouraud Shading


„ intensity-interpolation
‹ determine average unit normal vector at I1
each polygon vertex I3
‹ apply illumination model to each vertex
‹ linearly interpolate vertex intensities
I2
n

∑ Nk
1. find normal vectors at corners and calculate
shading (intensities) there: Ii
k =1
NV = n
∑ Nk
k =1
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Gouraud Shading Gouraud Shading

I1 I1
I3 v·I +(1–v)· I ' I 3
I= t·I 1+(1-t)·I 2 I'=u·I 2+(1-u)·I 3 I= t·I 1+(1-t)·I 2 I'=u·I 2+(1-u)·I 3
I2 I2

1. find normal vectors at corners and calculate 1. find normal vectors at corners and calculate
shading (intensities) there: Ii shading (intensities) there: Ii
2. interpolate intensities along the edges linearly: I, I’ 2. interpolate intensities along the edges linearly: I, I’
3. interpolate intensities along scanlines linearly: Ip

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

5
Gouraud Shading Gouraud Shading
„ interpolating intensities „ incremental update

y4 − y2 y1 − y4 x5 − xp xp − x4 y − y2 y1 − y I2 − I1
I4 = I + I Ip = I4 + I I= I + I I′ = I +
y1 − y2 1 y1 − y2 2 x5 − x4 x5 − x4 5 y1 − y2 1 y1 − y2 2 y1 − y2
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Problems of Gouraud Shading Gouraud Shading Results


„ highlights can get lost or grow „ no intensity discontinuities
„ corners on silhouette remain „ Mach bands due to linear intensity interpolation
„ Machband effect is visible at some edges „ problems with highlights

dark dark
light dark
dark dark
flat Gouraud

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Phong Shading Phong Shading Principle


„ instead of intensities the normal vectors are „ normal-vector interpolation
interpolated, and for every point the shading
‹ determine average unit normal vector at
calculation is performed separately
each polygon vertex
‹ linearly interpolate vertex normals

dark ‹ apply illumination model along each scan


light line
dark

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

6
Phong Shading Overview Phong Shading Normal Vectors
„ normal-vector interpolation

P
y − y2
N=
y1 − y2 1 +
N
1. normal vectors at corner points
y1 − y
2. interpolate normal vectors along the edges + N
y1 − y2 2
3. interpolate normal vectors along scanlines
& calculate shading (intensities) for every pixel

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Phong Shading Environment Mapping (1)


„ incremental normal vector update along and „ reflection mapping
between scan lines „ defined over the surface of an enclosing
universe (sphere, cube, cylinder)
„ comparison to Gouraud shading
‹ better highlights
‹ less Mach banding
‹ more costly

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Environment Mapping (2) Environment Mapping (3)


„ information in the environment map
‹ intensity values for light sources
‹ sky
‹ background
objects

„ pixel area
Blinn, CACM 76

‹ projected onto
surface
‹ reflected onto
environment
map
Haeberli/Segal
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

7
Environment Mapping (4) Adding Surface Detail (1)
„ most objects do not have smooth surfaces
‹ brick walls
‹ gravel roads
‹ shag carpets

„ surface texture required

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Adding Surface Detail (2) Texture Mapping (1)


„ modeling surface detail with polygons „ texture patterns
‹ small polygon facets
mapped onto
surfaces
(e.g., checkerboard squares)
‹ facets overlaid on surface polygon „ texture pattern:
(parent) ‹ raster image
‹ parent surface used for visibility ‹ or procedure (modifies surface intensities)
calculations
‹ facets used for illumination calculations
‹ impractical for intricate surface structure

Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Texture Mapping (2) Texture Mapping (3)


„ texture mapping „ projecting pixel areas to texture space =
‹ texture scanning (s,t)→(x,y)
= inverse scanning (x,y)→(s,t)
‹ inverse scanning (x,y)→(s,t)

„ texture-surface transformation „ calculation of M VP


-1
MT
-1
u = u ( s, t) = au s + but + cu
v = v ( s, t) = av s + bvt + cv „ anti-aliasing with filter operations
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

8
Texture-Map.: Cylindrical Surface Texture-Map.: Cylindrical Surface
„ MVP „ MT u = s π / 2, v = t
u = θ, with 0 ≤ θ ≤ π/2
v = z with 0 ≤ z ≤ 1

x = r⋅cos u, „ M-1VP
y = r⋅sin u, ‹ pixel → surface point (x,y,z)
z=v ‹ (x,y,z) → (u,v): u = tan −1 ( y / x), v= z
„ M-1T s = 2u / π , t = v
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Texture Mapping: Anti-aliasing Procedural Texturing (1)


„ anti-aliasing with filter operations „ procedural texture definition
‹ project larger ‹ texture_function (x,y,z) returns intensity
pixel area into ‹ avoid MT
texture space
‹ mip-mapping
„ 2D (surface texturing) or 3D (solid texturing)
‹ summed-area „ stochastic variations (noise function)
table method
„ examples
‹ wood grains
‹ marble
‹ leaves
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg
Copyright Alias|Wavefront

Procedural Texturing (2) Procedural Texturing (3)


gem faces:
a scene with polygonal facets
surface rest: quadric & bicubic
characteristics patches
generated using
solid-texture surface texturing
methods
procedural texturing
for steamy jungle
atmosphere
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

9
Bump Mapping (1) Bump Mapping Examples
bumps are visible because of shading

modeling of bumps is very costly.


trick: insert a detail structure T:
v
+ =
T Blinn, SIGGRAPH78 Blinn, SIGGRAPH78 Blinn, SIGGRAPH78

u Surface Rendering Surface Rendering


Dieter Schmalstieg Dieter Schmalstieg

Bump Mapping (2) Bump Mapping (3)


„ surface roughness simulated P ′(u, v) = P (u, v) + b(u, v)n
‹ perturbation function varies
N ′ = Pu′ × Pv′
surface normal locally
‹ bump map b(u,v) ∂
Pu′ = ( P + bn ) = Pu + bu n + bn u
∂u
Pu′ ≈ Pu + bu n, Pv′ ≈ Pv + bvn,
Copyright Alias|Wavefront
P ( u , v) surface point Perlin, SIGGRAPH85

N = Pu × Pv n = N/N surface normal N ′ = Pu × Pv + bv ( Pu × n ) + bu (n × Pv ) + bu bv (n × n )


n×n = 0
P ′(u, v) = P (u, v) + b(u, v)n modified surface
point N ′ = N + bv ( Pu × n) + bu ( n × Pv )
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg

Bump Mapping (4) Combination of Mapping Methods


„ bump map b(u,v) defined as raster image
„ bu, bv: approximated with finite differences

armor surface =
combination of
bump mapping
& environment mapping
& texture mapping
Surface Rendering Surface Rendering
Dieter Schmalstieg Dieter Schmalstieg
Copyright Alias|Wavefront

10

You might also like