0% found this document useful (0 votes)
8 views44 pages

7280 Lecture2 Graphics-Pipeline-1

The document discusses the graphics pipeline in computer games, emphasizing the creation of artificial worlds, interactive control, and real-time responses. It covers 3D geometry representation, including polyhedral representations, coordinate systems, transformations, and projection methods. Additionally, it explains hidden surface removal techniques, particularly the Z-buffer algorithm, which is essential for rendering scenes accurately by managing visibility of objects in 3D space.

Uploaded by

rkrams1989
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)
8 views44 pages

7280 Lecture2 Graphics-Pipeline-1

The document discusses the graphics pipeline in computer games, emphasizing the creation of artificial worlds, interactive control, and real-time responses. It covers 3D geometry representation, including polyhedral representations, coordinate systems, transformations, and projection methods. Additionally, it explains hidden surface removal techniques, particularly the Z-buffer algorithm, which is essential for rendering scenes accurately by managing visibility of objects in 3D space.

Uploaded by

rkrams1989
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/ 44

CSC7280

Graphics Pipeline 1

CSC7280 (Fall 2006)


Computer Game
General feature of computer games:

1. Create artificial world with a problem to solve


2. Provide interactive control
3. Dynamically change environment, force REAL-TIME response

Bioharzard II Final Fantasy 8


CSC7280 (Fall 2006)
3D Geometry Representation

CSC7280 (Fall 2006)


Polyhedral Representations
- Represent object as set of smoothly joined polygons.

Human with Robot scene based on polyhedra.


Note how the whole scene is composed of
rectangles, trapezoids, or, in the case of the
3D letters, rectangles and n-sided polygons

Exploded view of hierarchical structure of


robot. The robot main object (bold) is
constructed by assembling graphical primitive
subobjects which are easily generated by
CAD systems

CSC7280 (Fall 2006)


Advantages: 1. Simplicity
2. Generality
3. Computational efficiency
4. Support by most graphics hardwares
Weakness: 1. Poor approximation to smooth curved surfaces,
complex shapes and life-like forms
V ertex List Polygon List
V ertex # C oordinates robot
1 x1,y,1z1 Polygon # V ertex List
D ata 2 x2,y2,z2 1 V 1,V 2,V 3,V 4
Structure 3 x3,y3,z3 2 V 1,V 4,V 8,V 5
4 x4,y4,z4 3 V 5,V 6,V 2,V 1
5 x5,y5,z5 4 V 2,V 6,V 7,V 3
6 x6,y6,z6 5 V 4,V 3,V 7,V 8
7 x7,y7,z7 6 V 5,V 8,V 7,V 6
8 x8,y8,z8

Note that each subobject will have its own polygon list and
associated vertex list. Sometimes the vertex list is shared.
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
Coordinate Systems and
Transformation

CSC7280 (Fall 2006)


Coordinate Systems
• Coordinate systems used when rendering geometry
objects
Linear Linear
transformation transformation

Object World Eye/Camera


space space space

Non-linear
transformation

Raster Screen
space space

Rasterization

CSC7280 (Fall 2006)


Object Space

• The most natural coordinate system for the geometry


object
• Local coordinate system.
• “Local “ to the object
• Also known as modeling coordinate system
• e.g.

CSC7280 (Fall 2006)


World Space

• The global (world) coordinate system that is shared by all


objects in the modeled scene

World coordinate
system

CSC7280 (Fall 2006)


Eye/Camera Space
• The coordinate system with the eye or the center of
projection as its origin
• A space in which the viewing volume is established
• Facilitates clipping (removing out-of- view objects)

CSC7280 (Fall 2006)


Screen Space
• Transformation to screen space is a process that describes
how light rays reach our eyes
• Screen space is defined to act within a closed volume called
the viewing frustum

CSC7280 (Fall 2006)


3D Projection
• Even we model the world in 3D, the final display on your
monitor is 2D!!!
• Projection refers to the process of projecting the 3D world onto
the tiny 2D screen, so that you can visualize on your monitor.
• There are two major types of projections:
– Perspective projection, simulates your eye
– Orthogonal projection, preserve length after projection, used
in CAD systems.

CSC7280 (Fall 2006)


Screen Space (Perspective Projection)

xe ye
xs = D ys = D
ze ze

CSC7280 (Fall 2006)


Perspective projection
• There must be a center of projection which is a point in space.
• Analogous to the focus in your eye or camera
• Everything projects to this point!
• The screen analogous to your retina or film in the camera.
• All projection line are straight (simulate to light ray)
• Lengths are not preserved (farther object looks smaller)

CSC7280 (Fall 2006)


Screen Space (Orthogonal Projection)

xs = xe y s = ye

CSC7280 (Fall 2006)


Orthogonal (Parallel) projection
• No center of projection, but there is a projection plane.
• Or you can regard the center of projection is at infinity
• Everything projects to the plane orthogonally (perpendicularly
projects onto the plane)
• All lengths are preserved after projection (not true in perspective
projection)
• Parallel lines are remained parallel after projection.

CSC7280 (Fall 2006)


Raster Space
• A discretization process
• Determining onto which pixel (discrete sample) the 3D point
is projected

• Closely related to anti-aliasing as the rasterization is basically


a sampling process

CSC7280 (Fall 2006)


Transformation as Matrices

CSC7280 (Fall 2006)


Matrix representation of 3D transformations
• Use 4 x 4 matrices for 3D transformations
• Use homogeneous coordinate representation
i.e. (x, y, z) as (x, y, z, w)
• standard representation of a point (x,y,z,w) with w≠0 is given by
⎛x y z ⎞
⎜ , , ,1⎟
⎝w w w ⎠
• There are two major coordinate systems: right- and left-handed
systems

CSC7280 (Fall 2006)


Left- and Right- Handed Systems
• 3D coordinate system,
right-handed (mostly used)

• left-handed system (seldom used)

CSC7280 (Fall 2006)


Translation
⎡1 0 0 dx ⎤
⎢0 1 0 dy ⎥⎥
T ( dx , dy , dz ) = ⎢
⎢0 0 1 dz ⎥
⎢ ⎥
⎣0 0 0 1 ⎦

⎡x⎤ ⎡ x + dx ⎤
⎢y⎥ ⎢ y + dy ⎥
T ( dx , dy , dz ) ⎢ ⎥ = ⎢ ⎥
⎢z⎥ ⎢ z + dz ⎥
⎢ ⎥ ⎢ ⎥
⎣ ⎦
1 ⎣ 1 ⎦

• Inverse of T(dx,dy,dz) = T(-dx,-dy,-dz)

CSC7280 (Fall 2006)


Scaling
⎡sx 0 0 0⎤
⎢ 0 sy 0 0 ⎥⎥
S (sx, sy , sz ) = ⎢
⎢ 0 0 sz 0⎥
⎢ ⎥
⎣ 0 0 0 1⎦

⎡x⎤ ⎡sx ⋅ x ⎤
⎢y⎥ ⎢s ⋅ y⎥
S (sx, sy , sz )⎢ ⎥ = ⎢ y ⎥
⎢z⎥ ⎢ sz ⋅ z ⎥
⎢ ⎥ ⎢ ⎥
⎣1 ⎦ ⎣ 1 ⎦

• Inverse: ⎛1 1 1⎞
S ( sx , s y , sz ) = S ⎜ , , ⎟
⎜s s s ⎟
⎝ x y z⎠
CSC7280 (Fall 2006)
Rotation
Change angle :

Simple Proof

y x = r cos φ
r
y = r sin φ
φ
x

CSC7280 (Fall 2006)


rotate :

r (x’,y’) x' = r cos(θ + φ )


y’ = r cos φ cosθ − r sin φ sin θ
r (x,y)
y y ' = r sin(θ + φ )
θ r
= r sin φ cosθ + r cos φ sin θ
φ
x’ x
Or :
x' = x cosθ − y sin θ
y ' = x sin θ + y cosθ

CSC7280 (Fall 2006)


Rotation
• How about rotation?

• Let’s do it one-by-one, firstly, rotate about z


• same as before except we add a dummy z dimension

⎡cos θ − sin θ 0 0⎤
⎢ sin θ cos θ 0 0⎥
Rz (θ ) = ⎢ ⎥
⎢ 0 0 1 0⎥
⎢ ⎥
⎣ 0 0 0 1⎦

CSC7280 (Fall 2006)


Rotation (cont’d)
• Now do the same thing by looking at the yz-plane and assume x
is pointing to your eye (assume right handed system)

⎡1 0 0 0⎤
⎢0 cos θ − sin θ 0⎥
R x (θ ) = ⎢ ⎥
⎢0 sin θ cos θ 0⎥
⎢ ⎥
⎣0 0 0 1⎦

CSC7280 (Fall 2006)


Rotation (cont’d)
• Now the xz plane

⎡ cosθ 0 sin θ 0⎤
⎢ 0 1 0 0⎥
R y (θ ) = ⎢ ⎥
⎢− sin θ 0 cosθ 0⎥
⎢ ⎥
⎣ 0 0 0 1⎦

CSC7280 (Fall 2006)


Rotation (cont’d)
• Note: In Rx(θ) , Ry(θ) , Rz(θ) upper left 3x3 submatrix are
special orthogonal
• their column (and the row) vectors are mutually perpendicular
unit vectors.
• Inverse of any orthogonal matrix B

B-1 = BT
⎡ 0⎤ ⎡ 0⎤
⎢ B ⎥ ⎢ BT
R y (θ ) = ⎢
0⎥ −1 0⎥⎥
R y (θ ) = ⎢
⎢ 0⎥ ⎢ 0⎥
⎢⎣0 0 0 1⎥⎦ ⎢⎣0 0 0 1⎥⎦
CSC7280 (Fall 2006)
A Property
• Any set of rotation, scaling, translation can be multiplied
together to give a net transformation matrix

⎡ a11 a12 a13 tx ⎤


⎢a a22 a23 t y ⎥⎥
⎢ 21
⎢ a31 a32 a33 tz ⎥
⎢ ⎥
⎣0 0 0 1⎦

• This property loose when you project the object onto the screen.

CSC7280 (Fall 2006)


Handling fixed-point
• Just like in 2D
• Derive fixed point equations using

1. Translate Fixed pt. to origin


2. Scale, rotate, shear …
3. Translate origin back to fixed pt.

CSC7280 (Fall 2006)


Order of Issuing Transformation Commands
When using most graphics software to issue transformation command
to transform object, the order of issuing is REVERSED as the order
you think!!
e.g.

CSC7280 (Fall 2006)


Why reverse the order when writing?
Hierarchical modeling
e.g.

CSC7280 (Fall 2006)


CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
CSC7280 (Fall 2006)
Hidden Surface Removal

CSC7280 (Fall 2006)


Hidden Surface Removal
• If you draw a 3D scene using the technique as mentioned in previous
lectures, you will be disappointed.
• The image you created is not similar to what you see in real world.
• Why?
• The answer is in real world, you can only see front polygons!!!

• When 3D objects are projected onto the 2D screen, occlusion happens


• From a given viewpoint, what is in front?
• Viewpoint dependent problem
CSC7280 (Fall 2006)
Z-Buffer Algorithm
• Maintain a Z-buffer with same resolution as frame buffer
• During scan conversion compare
– Z value of pixel about to be stored with
Z value of current pixel in Z-buffer
• If new pixel’s Z value is closer, store new pixel value (color) in
frame buffer and new Z value in Z-buffer

Frame buffer
Depth buffer
for recording
for recording
pixel color
pixel depth

CSC7280 (Fall 2006)


Z-Buffer Algorithm

CSC7280 (Fall 2006)


Z-Buffer Algorithm

CSC7280 (Fall 2006)


Z-Buffer Algorithm

CSC7280 (Fall 2006)


Z-Buffer Algorithm
• Running time is proportional to the number of objects
• Very fast!
• De facto standard in most graphics systems.
• Frequent hardware implementations because of its simplicity
and speed

CSC7280 (Fall 2006)

You might also like