1 L Mar-4-05 SMM009, Exam Review Overview Working problems - - PDF document

1 l
SMART_READER_LITE
LIVE PREVIEW

1 L Mar-4-05 SMM009, Exam Review Overview Working problems - - PDF document

INSTITUTIONEN FR SYSTEMTEKNIK LULE TEKNISKA UNIVERSITET Exam Review David Carr Virtual Environments, Fundamentals Spring 2004 1 L Mar-4-05 SMM009, Exam Review Overview Working problems Summary of the course 2 L Mar-4-05


slide-1
SLIDE 1

1

Mar-4-05 SMM009, Exam Review 1 L

INSTITUTIONEN FÖR SYSTEMTEKNIK

LULEÅ TEKNISKA UNIVERSITET

Exam Review

David Carr Virtual Environments, Fundamentals Spring 2004

Mar-4-05 SMM009, Exam Review 2 L

Overview

  • Working problems
  • Summary of the course

Mar-4-05 SMM009, Exam Review 3 L

INSTITUTIONEN FÖR SYSTEMTEKNIK

LULEÅ TEKNISKA UNIVERSITET

Summary

slide-2
SLIDE 2

2

Mar-4-05 SMM009, Exam Review 4 L

Elements of Image Formation

  • Objects
  • Viewer
  • Light source(s)
  • Attributes that govern how light interacts with the

materials in the scene

  • Note the independence of the objects, viewer, and light

source(s)

Mar-4-05 SMM009, Exam Review 5 L

Three-Color Theory

  • Human visual system has two types of sensors
  • Rods: monochromatic, night vision
  • Cones

+ Color sensitive + Three types of cone + Only three values (the tri stimulus values) are sent to the brain

  • Need only match these three values
  • Need only three primary colors

Mar-4-05 SMM009, Exam Review 6 L

Pinhole Camera & Synthetic Camera Model

xp= -x/z/d yp= -y/z/d Use trigonometry to find projection of a point These are equations of simple perspective zp= d center of projection image plane projector p projection of p

slide-3
SLIDE 3

3

Mar-4-05 SMM009, Exam Review 7 L

Following the Pipeline: Transformations

  • Much of the work in the pipeline is in converting object

representations from one coordinate system to another

  • World coordinates
  • Camera coordinates
  • Screen coordinates
  • Every change of coordinates is equivalent to a matrix

transformation

Mar-4-05 SMM009, Exam Review 8 L

Clipping

  • Just as a real camera cannot “see” the whole world,

the virtual camera can only see part of the world space

  • Objects that are not within this volume are said to be clipped
  • ut of the scene

Mar-4-05 SMM009, Exam Review 9 L

Projection

  • Must carry out the process that combines the 3D

viewer with the 3D objects to produce the 2D image

  • Perspective projections: all projectors meet at the center of

projection

  • Parallel projection: projectors are parallel, center of

projection is replaced by a direction of projection

slide-4
SLIDE 4

4

Mar-4-05 SMM009, Exam Review 10 L

Rasterization

  • If an object is visible in the image, the appropriate

pixels in the frame buffer must be assigned colors

  • Vertices assembled into objects
  • Effects of lights and materials must be determined
  • Polygons filled with interior colors/shades
  • Must have also determine which objects are in front (hidden

surface removal)

Mar-4-05 SMM009, Exam Review 11 L

Geometry and Representation

  • Geometry
  • Relationships among objects in an n-dimensional space
  • In computer graphics, objects exist in 3 dimensions
  • Minimum set of primitives for building more sophisticated objects

+ Scalars, Vectors, Points

  • Representations
  • Dimension and basis
  • Coordinate systems for representing vectors spaces
  • Frames for representing affine spaces
  • Change of frames and basis
  • Homogeneous coordinates

Mar-4-05 SMM009, Exam Review 12 L

Affine Spaces

  • Point + a vector space
  • Operations
  • Vector-vector addition → vector
  • Scalar-vector multiplication → vector
  • Point-vector addition → point
  • Scalar-scalar operations → scalar
  • For any point P and the scalars 0,1 define
  • 1 • P = P
  • 0 • P = 0 (zero vector)
slide-5
SLIDE 5

5

Mar-4-05 SMM009, Exam Review 13 L

Convexity

  • An object is convex if and only if for any two points in

the object all points on the line segment between these points are also in the object

P Q Q P

Mar-4-05 SMM009, Exam Review 14 L

P(α,β)=R+αu+βv P(α,β)=R+α(Q-R)+β(P-Q)

Planes

  • A plane be determined by a point and two vectors or by

three points

Mar-4-05 SMM009, Exam Review 15 L

Normals

  • Every plane has a vector n normal (perpendicular,
  • rthogonal) to it
  • From point-two vector form P(α,β) = R + αu + βv, we

know we can use the cross product to find n = u × v and the equivalent form (P(α)-P) × n = 0

u v P

slide-6
SLIDE 6

6

Mar-4-05 SMM009, Exam Review 16 L

Frames

  • Coordinate System is insufficient to present points
  • If we work in an affine space we can add a single point,

the origin, to the basis vectors to form a frame

  • Frame determined by (P0, v1, v2, v3)
  • Within this frame, every vector can be written as

v = α1v1 + α2v2 + … + αnvn

  • Every point can be written as

P = P0 + β1v1 + β2v2 + … + βnvn

P0 v1 v2 v3

Mar-4-05 SMM009, Exam Review 17 L

A Single Representation

  • If we define 0•P = 0 and 1•P = P then we can write

v=α1v1+ α2v2 +α3v3 = [α1 α2 α3 0] [v1 v2 v3 P0]T P = P0 + β1v1+ β2v2 +β3v3

= [β1 β2 β3 1] [v1 v2 v3 P0] T

  • Thus we obtain the four-dimensional homogeneous

coordinate representation v = [α1 α2 α3 0] T p = [β1 β2 β3 1] T

Mar-4-05 SMM009, Exam Review 18 L

Homogeneous Coordinates

  • The general form of 4 dimensional homogeneous coordinates is

p=[x y x w]T

  • We return to a three dimensional point (for w ≠ 0) by

x←x/w y←y/w z←z/w

  • If w=0, the representation is that of a vector
  • Note that homogeneous coordinates replaces points in three

dimensions by lines through the origin in four dimensions

slide-7
SLIDE 7

7

Mar-4-05 SMM009, Exam Review 19 L

Working with Representations

Within the two frames any point or vector has a representation of the same form a=[α1 α2 α3 α4 ] in the first frame b=[β1 β2 β3 β4 ] in the second frame where α4 = β4 = 1 for points and α4 = β4 = 0 for vectors and The matrix M is 4 x 4 and specifies an affine transformation in homogeneous coordinates

a=MTb

Mar-4-05 SMM009, Exam Review 20 L

Affine Transformations

  • Every linear transformation is equivalent to a change in

frames

  • Every affine transformation preserves lines
  • However, an affine transformation has only 12 degrees
  • f freedom because 4 of the elements in the matrix are

fixed and are a subset of all possible 4 x 4 linear transformations

Mar-4-05 SMM009, Exam Review 21 L

  • 1

d 1 d 1 d 1

z y x

Matrix Representation in 4D Homogeneous Coordinates

  • This form is better for implementation because:
  • All affine transformations can be expressed this way
  • Multiple transformations can be concatenated together
  • Translation
slide-8
SLIDE 8

8

Mar-4-05 SMM009, Exam Review 22 L

  • Rotation about z axis in three dimensions leaves all

points with the same z

  • Equivalent to rotation in 2 dimensions in planes of constant z
  • x- and y-axes similar

x’ = x cos θ – y sin θ y’ = x sin θ + y cos θ z’ = z

Rotation About the Z-Axis

  • 1

1 cos sin sin cos

Rz(θ) =

Mar-4-05 SMM009, Exam Review 23 L

  • 1

z y x

s s s

x’=sxx y’=syy z’=szz p’=Sp S = S(sx, sy, sz) =

Scaling

  • Expand or contract along each axis (fixed point of
  • rigin)
  • Reflections are negative scaling

Mar-4-05 SMM009, Exam Review 24 L

Shear

  • Equivalent to pulling faces in
  • pposite directions
  • On the x-axis

x’ = x + y cot θ y’ = y z’ = z

  • 1

1 1 cot 1 H(θ) =

slide-9
SLIDE 9

9

Mar-4-05 SMM009, Exam Review 25 L

Inverses

  • Could compute inverse matrices by general

formulas,

  • But, simple geometric observations are easier
  • Translation: T-1(dx, dy, dz) = T(-dx, -dy, -dz)
  • Rotation: R -1(θ) = R(-θ)

+Holds for any rotation matrix +Note that since cos(-θ) = cos(θ) and sin(-θ)=-sin(θ), R -1(θ) = R T(θ)

  • Scaling: S-1(sx, sy, sz) = S(1/sx, 1/sy, 1/sz)

Mar-4-05 SMM009, Exam Review 26 L

Concatenation

  • Form arbitrary affine transformation matrices by multiplying
  • Rotation, translation, and scaling matrices
  • Same transformation is applied to many vertices:
  • Cost of forming a matrix M=ABCD is not significant compared to the

cost of computing Mp for many vertices p

  • Difficulty is forming a desired transformation
  • Order of Transformations
  • Note that matrix on the right is the first applied
  • Mathematically, the following are equivalent

p’ = ABCp = A(B(Cp))

  • Note many references use column matrices to present points. In terms of

column matrices pT’ = pTCTBTAT

Mar-4-05 SMM009, Exam Review 27 L

Projection

Perspective Parallel

slide-10
SLIDE 10

10

Mar-4-05 SMM009, Exam Review 28 L

Three Aspects of Computer Viewing

  • Positioning the camera
  • Setting the model-view matrix
  • Selecting a lens
  • Setting the projection matrix
  • Clipping
  • Setting the view volume
  • All are implemented in the

pipeline

  • Default OpenGL projection is
  • rthogonal

Orthogonal Projection

Mar-4-05 SMM009, Exam Review 29 L

xp = x yp = y zp = 0

Projections and Normalization

  • The default projection in the eye (camera) frame is
  • rthogonal
  • For points within the default view volume
  • Most graphics systems use view normalization
  • All other views are converted to the default view by

transformations that determine the projection matrix

  • Allows use of the same pipeline for all views

M =

  • 1

1 1 Mar-4-05 SMM009, Exam Review 30 L

Simple Perspective

  • Center of projection at the origin
  • Projection plane z = d, d < 0
  • Consider top

and side views

xp =

d z x /

yp =

d z y /

zp = d

slide-11
SLIDE 11

11

Mar-4-05 SMM009, Exam Review 31 L

M =

  • /

1 1 1 1 d

  • 1

z y x

  • d

z z y x /

p = ⇒ q =

Homogeneous Coordinate Form

consider q = Mp where

Mar-4-05 SMM009, Exam Review 32 L

xp =

d z x /

yp =

d z y /

zp = d

Perspective Division

  • However w ≠ 1, so we must divide by w to return from

homogeneous coordinates

  • This perspective division yields
  • The desired perspective equations

Mar-4-05 SMM009, Exam Review 33 L

OpenGL Viewing

near and far measured from camera Orthogonal Projection Perspective Projection

slide-12
SLIDE 12

12

Mar-4-05 SMM009, Exam Review 34 L

Pipeline View of Projection Matrices

Model-View Transformation Projection Transformation Perspective Division Clipping Projection nonsingular 4D → 3D Against Default Cube 3D → 2D

Mar-4-05 SMM009, Exam Review 35 L

Orthogonal Normalization

  • Two steps
  • Move center to origin
  • Scale to have sides of length 2
  • Final Projection, set z =0

2 right left right + left right left 2 top bottom top + bottom top bottom 2 near far far + near far near 1

  • P = ST =

Mar-4-05 SMM009, Exam Review 36 L

Simple Perspective

  • Consider a simple perspective with the COP at the
  • rigin, the near clipping plane at z = -1, and a 90

degree field of view determined by the planes

  • x = ±z, y = ±z
slide-13
SLIDE 13

13

Mar-4-05 SMM009, Exam Review 37 L

Generalized Projection Matrix

1 1

  • 1
  • N =

after perspective division, the point (x, y, z, 1) goes to x’’ = -x/z y’’ = -y/z z’’ = -(α+β/z) which projects orthogonally to the desired point regardless of α and β

Mar-4-05 SMM009, Exam Review 38 L

If we pick α = β =

near + far far near 2near far near far

the near plane is mapped to z = -1 the far plane is mapped to z =1 and the sides are mapped to x = ± 1, y = ± 1 Hence the new clipping volume is the default clipping volume

Picking α and β

Mar-4-05 SMM009, Exam Review 39 L

Phong Shading Model

  • Has three components
  • Diffuse, Specular, Ambient
  • Uses four vectors
  • To source, To viewer, Normal,
  • Ideal reflector
  • For each light source and each color component, the Phong

model can be written (without the distance terms) as I =kd Id l · n + ks Is (v · r )α + ka Ia

  • For each color component we add contributions from all sources

φ

slide-14
SLIDE 14

14

Mar-4-05 SMM009, Exam Review 40 L

r = 2 (l · n ) n - l

Components

  • Specular surfaces, ideal reflector
  • Normal is determined by local orientation
  • Angle of incidence = angle of reflection
  • The three vectors must be coplanar
  • Ir ~ ks I cosαφ
  • Shininess coeffient, metal 100-200, plastic 5-10
  • Lambertian Surface
  • Perfectly diffuse reflector, light scattered equally in all directions
  • Amount of light reflected is proportional to the vertical component of

incoming light + reflected light ~cos θi, cos θi = l · n if vectors normalized + 3 coefficients, kr, kb, kg show how much of each color is reflected

Mar-4-05 SMM009, Exam Review 41 L

Distance Terms

  • The light from a point source that reaches a surface is

inversely proportional to the square of the distance between them

  • We can add a factor of the

form 1/(a + bd +cd2) to the diffuse and specular terms

  • The constant and linear terms soften

the effect of the point source

Mar-4-05 SMM009, Exam Review 42 L

Object Oriented Models

  • Hierarchical models, trees, and DAGs
  • Scene graphs
  • Other graphical trees
  • Constructive Solid Geometry

+ Solid primitives, set operations ∪, ∩, & - + Construct expression trees

  • Shade trees

+ Expressions for custom rendering

  • BSP trees

+ Depth ordering

  • Quadtrees and Octrees
slide-15
SLIDE 15

15

Mar-4-05 SMM009, Exam Review 43 L

Scene Graphs, Design Goals

  • Node-Link Structure
  • Links can be implicit
  • Different types of nodes for:
  • Transformations
  • Object aggregation
  • Material properties
  • Cameras
  • Want:
  • Properties to propagate down the

graph

  • Coordinates to be local to each

group

  • Transformations to apply to all

children

Mar-4-05 SMM009, Exam Review 44 L

Scene Graphs, Basic Class Structure

Mar-4-05 SMM009, Exam Review 45 L

Cameras in a Scene Graph

  • Views of the scene graph
  • Separate from the scene
  • Can also be interior to a scene graph
  • Provide view of part of the scene
  • For example, set below an InvisibleGroupNode

+ View of the hidden for “x-ray” vision

  • Need to provide settings such as:
  • Location, orientation, view angle, …
slide-16
SLIDE 16

16

Mar-4-05 SMM009, Exam Review 46 L

Events in Scene Graphs

  • We need a way to interact
  • Nodes should generate events when accessed, selected, …
  • Applications register for event notification

+ Listeners attached to scene graph nodes + Multiple listeners allowed

  • May be associated with any scene graph node
  • Two kinds
  • Input, mouse events, etc.
  • Object, result from modifications of the scene graph
  • Events passed up the tree to ancestors by default
  • The application can stop this.

Mar-4-05 SMM009, Exam Review 47 L

Discrete Methods

  • XOR writing mode and buffers
  • Pixel pipeline
  • Texture Mapping
  • Environment mapping, box maps
  • Aliasing/anti-aliasing
  • RGBA, composition, and blending
  • Translucency, fog, anti-aliasing

Mar-4-05 SMM009, Exam Review 48 L

Renderer Implementation

  • 4 Tasks
  • Modeling
  • Geometric processing
  • Rasterization
  • Display
  • Clipping
  • Line

+ Cohen-Sutherland + Liang-Barsky + Cohen-Sutherland in 3D

  • Polygon

+ Sutherland-Hodgman

  • Hidden surface removal
  • Back-face removal
  • Depth sorting
  • Painter’s algorithm
  • Z-buffer algorithm
  • Octree methods
  • Scan conversion
  • Digital difference analyzers
  • Bresenham’s algorithm
  • Circles
  • Flood fill
  • Antialiasing
slide-17
SLIDE 17

17

Mar-4-05 SMM009, Exam Review 49 L

Questions?