49
Rendering Pipeline Fall, 2013

Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Embed Size (px)

DESCRIPTION

3D Polygon Rendering What steps are necessary to utilize spatial coherence while drawing these polygons into a 2D image?

Citation preview

Page 1: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Rendering Pipeline

Fall, 2013

Page 2: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

3D Polygon Rendering

Many applications use rendering of 3D polygons with direct illumination

Page 3: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

3D Polygon Rendering

What steps are necessary to utilize spatial coherence while drawing these polygons into a 2D image?

Page 4: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

3D Rendering Pipeline (for direct illumination)

Transform into 3D world coordinate system

Illuminate according to lighting and reflection

Transform into 3D camera coordinate system

Transform into 2D camera coordinate system

Clip primitives outside camera’s view

Transform into image coordinate system

Draw pixels (includes texturing, hidden surface, …)

Page 5: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Transformations

Page 6: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewing Transformations

Page 7: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewing Transformation

Mapping from world to camera coordinates Eye position maps to origin Right vector maps to X axis Up vector maps to Y axis Back vector maps to Z axis

World X

Y

Z

Page 8: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Camera Coordinates

Canonical coordinate system Convention is right-handed (looking down –z axis) Convenient for projection, clipping, etc .

Page 9: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Finding the viewing transformation

We have the camera (in world coordinates) We want T taking objects from world to camera

Trick: find T-1 taking objects in camera to world

wc Tpp

cw pTp 1

Page 10: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Finding the viewing transformation

Trick: map from camera coordinate to world Origin maps to eye position Z axis maps to Back vector Y axis maps to Up vector X axis maps to Right vector

This matrix is T-1 so we invert in to get T (easy)

Page 11: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewing Transformations

Page 12: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Projection

General definition: Transform points in n-space to m-space (m<n)

In computer Graphics: Map 3D camera coordinates to 2D screen coordinates

Page 13: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Taxonomy of Projections

Page 14: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Parallel Projection

Center of projections is at infinity Direction of projection (DOP) same for all points

Page 15: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Orthogonal Projections

DOP perpendicular to view plane

Page 16: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Oblique Projections

DOP not perpendicular to view plane1) Cavalier projection

• when angle between projector and view plane is 45 degree• foreshortening ratio for all three principal axis are equal.

2) Cabinet projection• the foreshortening ratio for edges that perpendicular to the

plane of projection is one-half (angle 63.43 degree )

perpendicular angle

Oblique angle

Page 17: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Oblique Projections

DOP not perpendicular to view plane

Page 18: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Parallel Projection View Volume

Page 19: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Parallel Projection Matrix

General parallel projection transformation

Page 20: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection

Map points onto “view plane” along “projectors” emanating from “center of projection” (COP)

Page 21: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection

How many vanishing points?

Page 22: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection View Volume

Page 23: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection

Compute 2D coordinates from 3D coordinates with similar triangles

Page 24: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection Matrix

4 x 4 matrix representation?

1

s

s

ccs

ccs

wDz

zDyy

zDxx

Page 25: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective Projection Matrix

4 x 4 matrix representation?

1

s

s

ccs

ccs

wDz

zDyy

zDxx

Dzw

zzyyxx

c

c

c

c

'

'''

Page 26: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Perspective vs. Parallel

Parallel Projection+ Good for exact measurements+ Parallel lines remain parallel- Angles are not (in general) preserved- Less realistic looking

Perspective Projection+ Size varies inversely with distance – looks realistic- Distance and angles are not (in general) preserved- Parallel line do not (in general) remain parallel

Page 27: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Classical Projections

Page 28: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Taxonomy of Projections

Page 29: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewing Transformations Summary

Camera Transformation Map 3D world coordinates to 3D camera coordinates Matrix has camera vectors are rows

Projection Transformation Map 3D camera coordinates to 2D screen coordinates Two type of projections

• Parallel • Perspective

Page 30: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

3D Rendering Pipeline (for direct illumination)

Page 31: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

2D Rendering Pipeline

Clip portions of geometric primitivesresiding outside the window

Transform the clipped primitives From screen to image coordinates

Fill pixels representing primitivesIn screen coordinates

Page 32: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Clipping

Avoid drawing parts of primitives outside window Window defines part of scene being viewed Must draw geometric primitives only inside window

Page 33: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Clipping

Avoid drawing parts of primitives outside window Points Lines Polygons Circles etc.

Page 34: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Point Clipping

Is point (x, y) inside window?

Page 35: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Line Clipping

Find the part of a line inside the clip window

Page 36: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Cohen Sutherland Line Clipping

Use simple tests to classify easy cases first

Page 37: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Cohen Sutherland Line Clipping

Classify some lines quickly AND of bit codes representing regions of two end points (must be 0)

Page 38: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Cohen Sutherland Line Clipping

Compute intersections with window boundary for lines that can’t be classified quickly

Page 39: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Cohen Sutherland Line Clipping

Compute intersections with window boundary for lines that can’t be classified quickly

Page 40: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Cohen Sutherland Line Clipping

Compute intersections with window boundary for lines that can’t be classified quickly

Page 41: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Polygon Clipping

Find the part of a polygon inside the clip window?

Page 42: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Sutherland Hodgeman Clipping

Clip each window boundary one at a time

Page 43: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Clipping to a Boundary

1. Do inside test for each point in sequence, 2. Insert new points when cross window boundary,3. Remove Points outside window boundary

Page 44: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

2D Rendering Pipeline

Clip portions of geometric primitivesresiding outside the window

Transform the clipped primitives From screen to image coordinates

Fill pixels representing primitivesIn screen coordinates

Page 45: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewport Transformation

Transformation 2D geometric primitives from screen coordinate system (normalized device coordinates) to image coordinate system (pixels)

Page 46: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Viewport Transformation

Window-to-Viewport mapping

Page 47: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Summary of Transformations

Page 48: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Summary

Page 49: Rendering Pipeline Fall, 2013. 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination

Next Time