Computer Graphics - Modeling & Simulation Lab.

advertisement
Photo-realistic Rendering and Global
Illumination in Computer Graphics
Spring 2012
Visual Appearance
K. H. Ko
School of Mechatronics
Gwangju Institute of Science and Technology
Introduction
Physics-based lighting simulation


Photograph
The production of realistic synthetic
images was and is still considered as one
of the ultimate goal to reach in computer
graphics.
By ‘realistic’, we mean here images
perceptually indistinguishable from the
real scene.
Direct lighting only
(http://www.mpi-sb.mpg.de/resources/atrium/)
2
Introduction

Illumination
 Light
rays coming from the rest of the scene strike
a surface element, and head out in different
directions.
 We want to calculate the intensity and
chromaticity values of the light that goes in the
direction of the viewer from that surface element
(if the viewer moves, those values will change).

This is defined as the “illumination” of that surface
element.
3
Introduction

Global Illumination
 Simulates
what happens when other objects affect light
reaching a surface element.
 It is expensive to compute: the light reaching surface
element may be affected by many other objects in the
scene.


Direct illumination: most light striking a surface element comes
directly from emissive light sources in the scene.
Indirect illumination: light bounces off other objects toward our
surface element. When that light reaches our surface element, it
brightens it.
object
eye
direct illumination
light
indirect illumination
object
object
light
4
Introduction

Non-global Illumination
 We only concentrate on light from light sources.
 Ignore effects of all other objects in the scene when considering a
particular surface element.


A scene can be rendered much faster.
But we pay a price in lost realism.
 We
lose effects of global illumination: shadows, interobject reflection, refraction, i.e. bending of light at
translucent surfaces, etc.
global illumination
non-global illumination
5
Introduction

Interaction between light and surfaces





Geometric relationship of surface with
respect to lights
Light incident on surface (color and
intensity of emitters and reflectors in the
scene)
Geometric relationship of surface with
respect to viewer and other (potentially
blocking) objects
Physical properties of the surface
(material)
 how much light it absorbs, reflects, or
refracts
Approximation with no firm grounding in
theory but good in practice.
6
Introduction

Illumination Models describe inputs,
assumptions, and outputs used to calculate
illumination of surface elements.
 Physics-based
models
Require accurate input data and make few assumptions
 rarely have enough information to specify all those
inputs.
 It takes a long time to compute illumination.

 Non-physics-based models

a model that looks good enough for our application and
can be calculated efficiently with available resources.
7
Illumination Models
Self-luminous Object
 Ambient light
 Diffuse Reflection
 Atmospheric Attenuation
 Specular Reflection
 Multiple Light Sources

8
Illumination Models

Self-luminous Object
 No
external light source: non realistic
 Illumination Model

Illumination equation
I = k].
 I: the resulting intensity
 k: object intrinsic intensity

 No
dependence on the position of the point being
shaded.

Compute once for each object.
9
Illumination Models

Characteristics of Surfaces
 ambient
component to account for non-specific global
light
 diffuse component
 specular component
10
Illumination Models

Ambient Light
 Consider a diffuse/non-directional source of light.
 Illumination equation
 I = Iaka.
 I: intensity of the ambient light, assumed to be constant for all
objects.
 ka: the ambient-reflection coefficient, which determines the
amount of ambient light reflected from an object’s surface.
 The ambient-reflection coefficient: an empirical
convenience. No relation to any physical property of real
materials.
 It is used to account for all the complex ways in which
light can reach an object that are not otherwise addressed
by the illumination equation.
11
Illumination Models

Diffuse Reflection
 Consider
illuminating an object by a point light source
whose rays emanate uniformly in all directions from a
single point.

The object’s brightness varies from one part to another, depending
on the direction of and distance to the light source.
 Lambertian
reflection (diffuse reflection): dull, matte
surfaces


The brightness depends only on the angle between the direction to
the light source and the surface normal.
Reflect light with equal intensity in all directions.
12
Illumination Models

Diffuse Reflection
 Diffuse illumination equation
 I = Ipkdcosθ or I = Ipkd(N·L).: N and L vectors have been
normalized.
 Directional light source
 If a point light source is sufficiently distant from the objects being
shaded, it makes essentially the same angle with all surfaces
sharing the same surface normal.

L is a constant for the light source.
13
Illumination Models

More realistic illumination equation so far.
I
= Iaka +Ipkd(N·L).
14
Illumination Models

Diffuse Reflection
 Light-source attenuation


Light energy attenuates as the distance to the light source
increases.
Consider such an attenuation effect in the illumination model.
For a square law attenuation
f att
1
 2
dL
f att
For a richer range of effects


1

 max
,
1
 c1  c2 d L  c3d 2 
L


15
Illumination Models

Illumination equation so far.
I
= Iaka +fattIpkd(N·L).
16
Illumination Models

Colored Lights and Surfaces
 Commonly
treated by writing separate equations for each
component of the color model.
 For RGB color system, use the triple (OdR, OdG, OdB)
which defines an object’s diffuse red, green and blue
components in the RGB color system.
 The illuminating light’s three primary components, IpR,
IpG, and IpB are reflected in proportion to kdOdR, kdOdG and
kdOdB.
17
Illumination Models

Illumination equation so far.
 Iλ
= Iaλ kaOdλ +fattIpλ kdOdλ (N·L).
18
Illumination Models

Atmospheric Attenuation

Use Depth cueing to simulate
the atmospheric attenuation.



More distant objects are
rendered with lower intensity
than are closer ones.
Also consider to approximate
the shift in colors caused by
the intervening atmosphere.
I '  s0 I   (1  s0 ) I dc
s0  sb 
( z0  zb )(s f  sb )
z f  zb
The goal is to modify a
computed Iλ to yield the
depth-cued value I’λ that is
displayed.
19
Illumination Models

Specular Reflection
 It
can be observed on any shiny surface.



Ex. Illuminate an apple with a bright white light.
The highlight is caused by specular reflection.
At the highlight, the apple appears to be not red, but white, the
color of the incident light.
 When
α is zero, the viewer can see specularly reflected
light.
20
Illumination Models

Specular Reflection
 The

Phong illumination model
It assumes that maximum specular reflectance occurs when α is
zero and falls off sharply as α increases.

The rapid fall-off is approximated by cosn α , n: the material’s
specular-reflection exponent.
21
Illumination Models

Specular Reflection
 The Phong illumination model
 It accounts for viewers and lights at arbitrary positions.
 The amount of incident light specularly reflected depends on the
angle of incidence θ.

I   I a kaOd  f att I p kd Od cos  W ( ) cosn 




W(θ) is the fraction of specularly reflected light, which is typically
set to a constant ks, the material’s specular-reflection coefficient.
The color of the specular component in Phong’s illumination
model is not dependent on any material property.
Specular reflection is affected by the properties of the surface
itself.
22
Illumination Models

Specular Reflection
 The

Phong illumination model
In general specular reflection may have a different color than
diffuse reflection when the surface is a composite of several
materials.

I   I a kaOd  f att I p kd Od ( N  L)  ksOs (R V )n


Osλ is the object’s specular color.
23
Illumination Models

Specular Reflection
 The

Phong illumination model
Calculating the reflection vector



R=2N(N ·L)-L
R·V = (2N(N ·L)-L) ·V)
The halfway vector


Alternative formulation of Phong’s model uses the half way vector
H, which is defined as H = (L+V)/|L+V|.
It is known as the direction of maximum highlights. If the surface is
oriented so that its normal were in the same direction as H, the
viewer sees the brightest specular highlight.
24
Illumination Models

Improving the Point-Light-Source Model
 Real
light sources do not radiate equally in all directions.
 In Phong’s model, a point light source has only an
intensity and a position.
 Warn’s method: Easily implemented lighting controls



That can be added to any illumination equation.
To model some of the directionality of the lights.
A light L is modeled by a point on a hypothetical specular
reflecting surface.

The surface is illuminated by a
point light source L’ in the direction L’.
25
Illumination Models

Improving the Point-Light-Source Model
 Warn’s

method
A light L is modeled by a point on a hypothetical specular
reflecting surface.


The surface is illuminated by a
point light source L’ in the direction L’.
Then use the Phong illumination equation
to determine the intensity of L at a point
on the object in terms of the angle γ
between L and L’.
26
Illumination Models

Improving the Point-Light-Source Model
 Warn’s

method
Assume that the reflector reflects only specular light and has a
specular coefficient of 1, then the light’s intensity at a point on the
object is:

IL’λ cosp γ or IL’λ (-L ·L’)p
27
Illumination Models

Improving the Point-Light-Source Model
 To
restrict light’s effects to a limited area of the scene,
Warn implemented flaps and cones.


Flaps confine the effects of the light to a designated range in x, y,
and z world coordinates.
We can create a sharply delineated spotlight through the use of a
cone whose apex is at the light source and whose axis lies along
L’.
28
Illumination Models

Multiple Light Sources
 If
there are m light sources, then the terms for each light
source are summed.
I   I a kaOd 
 The

f
1i  m
att i

I p i kd Od ( N  Li )  ks Os ( Ri V ) n

summation harbors a new possibility for error.
Iλ can now exceed the maximum displayable pixel value.


Clamp each Iλ individually.
Considers all of a pixel’s Iλ values together.
 If at least one is too big, each is divided by the largest to
maintain the hue and saturation at the expense of the value.
29
Shading Models for Polygons

We can shade any surface by calculating the surface
normal at each visible point and applying the desired
illumination model at that point.
 This

brute-force shading model is expensive!!!
Efficient Shading Methods
 Constant
shading
 Interpolated shading
 Polygon mesh shading
 Gouraud Shading
 Phong Shading
30
Constant Shading



Determine a single intensity value and use it to
shade an entire polygon.
Sample the value of the illumination equation once
for each polygon and hold the value across the
polygon to reconstruct the polygon’s shade.
This approach is valid if
 The
light source is at infinity, so N ·L is constant across
the polygon face.
 The viewer is at infinity, so N ·V is constant across the
polygon face.
 The polygon represents the actual surface being modeled
and is not an approximation to a curved surface.
31
Interpolated Shading


Shading information is linearly interpolated across a
triangle from values determined for its vertices.
Gouraud generalized this technique to arbitrary
polygons.
32
Polygon Mesh Shading


Objective: how to render a polygon mesh so that it
looks as much as possible like a curved surface.
If each polygonal facet is shaded individually, then a
faceted appearance is generated.
 True
for constant shading, interpolated shading or even
per-pixel illumination calculations

Two adjacent polygons of
different orientation have
different intensities along
their borders.
33
Polygon Mesh Shading

Simple solution of using a finer mesh turns out to be
surprisingly ineffective.
 The
perceived difference in shading between adjacent
facets is accentuated by the Mach band effect.
 The Mach band effect exaggerates the intensity change at
any edge where there is a discontinuity in magnitude or
slope of intensity.

At the border between two facets, the dark facet looks darker and
the light facet looks lighter.
34
Polygon Mesh Shading

The Mach Band Effect



At the border between two facets, the dark facet looks darker and the
light facet looks lighter.
It is caused by lateral inhibition of the receptors in the eye.
The more light a receptor receives, the more that receptor inhibits the
response of the receptors adjacent to it.
35
Polygon Mesh Shading

Gouraud Shading: intensity interpolation shading or
color interpolation shading.
 It
eliminates intensity discontinuities. But the bright ridges
on objects such as the torus and cone are Mach bands
caused by a rapid, although not discontinuous, change in
the slope of the intensity
curve.
 Gouraud shading does
not completely eliminate
such intensity changes.
36
Polygon Mesh Shading

Gouraud Shading
 Steps



Compute the normal at each vertex.
Find vertex intensities by using the vertex normal vectors with a
desired illumination model.
Each polygon is shaded by linear interpolation of vertex intensities
along each edge and then between edges along each scan line.
37
Polygon Mesh Shading

Phong Shading




It is known as normal-vector interpolation shading.
It interpolates the surface normal vector N, rather than the intensity.
Interpolation occurs across a polygon span on a scan line, between
starting and ending normals for the span.
These normals are themselves interpolated along polygon edges from
vertex normals that are computed.
38
Polygon Mesh Shading

Gouraud Shading vs. Phong Shading
 Phong
shading yields substantial improvements over
Gouraud shading when an illumination equation with a
specular-reflectance term is used since highlights are
reproduced more faithfully.
39
Polygon Mesh Shading

Gouraud Shading vs. Phong Shading
 Phong
shading yields substantial improvements over
Gouraud shading when an illumination equation with a
specular-reflectance term is used since highlights are
reproduced more faithfully.
 Reduces Mach-band problems in most cases.
Gouraud Shading
Phong Shading
40
Comparison
41
Polygon Mesh Shading

Problems with Interpolated Shading
 Polygonal

silhouette
No matter how good an approximation an interpolated shading
model offers to the actual shading of a curve surface, the silhouette
edge of the mesh is still clearly polygonal.

Curved surface models need to be considered.
 Perspective distortion

Anomalies are introduced because interpolation is performed after
perspective transformation in the 3D screen-coordinate system,
rather than in the WC system.
 Orientation dependence
42
Polygon Mesh Shading

A
Problems with Interpolated Shading
 Problems

at shared vertices
Shading discontinuity.
 Unrepresentative vertex normals

C
B
Computed vertex normals may not adequately represent the
surface’s geometry. -> More subdivision of the polygons is
necessary.
43
Surface Detail
(Simulation of missing surface detail)

Surface-Detail Polygons
 Add
gross detail through the use of surface-detail polygons
to show features on a base polygon.
 Each surface-detail polygon is coplanar with its base
polygon.
 It does not need to be compared with other polygons
during visible-surface determination.
44
Download