The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

23
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003

Transcript of The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

Page 1: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

The Rendering Pipeline

CS 445/645Introduction to Computer Graphics

David Luebke, Spring 2003

Page 2: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 2 04/20/23

Admin

● Call roll● Assignment 0: questions?

Page 3: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 3 04/20/23

Framebuffers

● So far we’ve talked about the physical display device● How does the interface between the device and the

computer’s notion of an image look?● Framebuffer: A memory array in which the computer

stores an image■ On most computers, separate memory bank from main

memory (why?)■ Many different variations, motivated by cost of memory

Page 4: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 4 04/20/23

Framebuffers: True-Color

● A true-color (aka 24-bit or 32-bit) framebuffer stores one byte each for red, green, and blue

● Each pixel can thus be one of 224 colors● Pay attention to

Endian-ness● How can 24-bit

and 32-bit mean the same thing here?

Page 5: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 5 04/20/23

Framebuffers: Indexed-Color

● An indexed-color (8-bit or PseudoColor) framebuffer stores one byte per pixel (also: GIF image format)

● This byte indexes into a color map: ● How many colors

can a pixel be?● Still common on

low-end displays (cell phones, PDAs,GameBoys)

● Cute trick: color-map animation

Page 6: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 6 04/20/23

Framebuffers: Hi-Color

● Hi-Color is/was a popular PC SVGA standard● Packs pixels into 16 bits:

■ 5 Red, 6 Green, 5 Blue (why would green get more?)■ Sometimes just 5,5,5

● Each pixel can be one of 216 colors● Hi-color images can exhibit worse quantization

artifacts than a well-mapped 8-bit image

Page 7: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 7 04/20/23

Recap: Matrices

● By convention, matrix element Mrc is located at row r and column c:

● By (OpenGL) convention, vectors are columns:

mnm2m1

2n2221

1n1211

MMM

MMM

MMM

M

3

2

v

v

v

v

1

Page 8: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 8 04/20/23

Recap: Matrices

● Matrix-vector multiplication applies a linear transformation to a vector:

● Recall how to do matrix multiplication

z

y

x

v

v

v

MMM

MMM

MMM

vM

333231

232221

131211

Page 9: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 9 04/20/23

Recap: Matrix Transformations

● A sequence or composition of linear transformations corresponds to the product of the corresponding matrices

■ Note: the matrices to the right affect vector first, e.g:

rotation about x, then translation along y, then rotation about z

■ Note: order of matrices matters!

● The identity matrix I has no effect in multiplication

● Some (not all) matrices have an inverse:

vvMM 1

' z y xp pR T R

x xPQ QP

x xI

Page 10: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 10 04/20/23

Vectors and Matrices

● Vector algebra operations can be expressed in this matrix form■ Dot product:

■ Cross product:○ Note: use

right-handrule!

z

y

x

zyx

b

b

b

aaaba

0

0

0

z y x x

z x y y

y x z z

a a b c

a a b c

a a b c

a b c

a c 0

b c 0

Page 11: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 11 04/20/23

The Rendering Pipeline: A Whirlwind Tour

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 12: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 12 04/20/23

The Display You Know

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 13: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 13 04/20/23

The Framebuffer You Know

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 14: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 14 04/20/23

The Rendering Pipeline

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 15: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 15 04/20/23

2-D Rendering: Rasterization(Coming Soon)

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 16: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 16 04/20/23

The Rendering Pipeline: 3-D

Transform

Illuminate

Transform

Clip

Project

Rasterize

Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay

Page 17: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 17 04/20/23

The Rendering Pipeline: 3-D

ModelingTransforms

Scene graphObject geometry

LightingCalculations

ViewingTransform

Clipping

ProjectionTransform

Result:Result:

• All vertices of scene in shared 3-D “world” coordinate All vertices of scene in shared 3-D “world” coordinate systemsystem

• Vertices shaded according to lighting modelVertices shaded according to lighting model

• Scene vertices in 3-D “view” or “camera” coordinate Scene vertices in 3-D “view” or “camera” coordinate systemsystem

• Exactly those vertices & portions of polygons in view Exactly those vertices & portions of polygons in view frustumfrustum

• 2-D screen coordinates of clipped vertices2-D screen coordinates of clipped vertices

Page 18: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 18 04/20/23

The Rendering Pipeline: 3-D

Scene graphObject geometry

LightingCalculations

Clipping

Result:Result:

• All vertices of scene in shared 3-D “world” coordinate All vertices of scene in shared 3-D “world” coordinate systemsystem

• Vertices shaded according to lighting modelVertices shaded according to lighting model

• Scene vertices in 3-D “view” or “camera” coordinate Scene vertices in 3-D “view” or “camera” coordinate systemsystem

• Exactly those vertices & portions of polygons in view Exactly those vertices & portions of polygons in view frustumfrustum

• 2-D screen coordinates of clipped vertices2-D screen coordinates of clipped vertices

ModelingTransforms

ViewingTransform

ProjectionTransform

Page 19: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 19 04/20/23

Rendering: Transformations

● So far, discussion has been in screen space● But model is stored in model space

(a.k.a. object space or world space)● Three sets of geometric transformations:

■ Modeling transforms■ Viewing transforms■ Projection transforms

Page 20: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 20 04/20/23

Rendering: Transformations

● Modeling transforms■ Size, place, scale, and rotate objects parts of the model

w.r.t. each other■ Object coordinates world coordinates

Z

X

Y

X

Z

Y

Page 21: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 21 04/20/23

Rendering: Transformations

● Viewing transform■ Rotate & translate the world to lie directly in front of the

camera○ Typically place camera at origin○ Typically looking down -Z axis

■ World coordinates view coordinates

Page 22: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 22 04/20/23

Rendering: Transformations

● Projection transform■ Apply perspective foreshortening

○ Distant = small: the pinhole camera model

■ View coordinates screen coordinates

Page 23: The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.

David Luebke 23 04/20/23

Rendering: Transformations

● All these transformations involve shifting coordinate systems (i.e., basis sets)

● That’s what matrices do…● Represent coordinates as vectors, transforms as

matrices

● Multiply matrices = concatenate transforms!

Y

X

Y

X

cossin

sincos