3d graphics pipeline - ii

67
3D Graphics Pipeline II Clipping Instructor Stephen J. Guy

Upload: others

Post on 12-Sep-2021

36 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3D Graphics Pipeline - II

3D Graphics Pipeline – II

Clipping

Instructor – Stephen J. Guy

Page 2: 3D Graphics Pipeline - II

3D Rendering Pipeline (for direct illumination)

Modeling

Transformation

Lighting

Viewing

Transformation

Projection

Transformation

Clipping

View Port

Transformation

3D Geometric Primitives

Image

3D Model Primitives

3D World Coordinates

3D World Coordinates

3D Camera Coordinates

2D Screen Coordinates

2D Screen Coordinates

2D Image CoordinatesScan

Conversion2D Image Coordinates

Page 3: 3D Graphics Pipeline - II

3D Polygon Rendering - Examples

10/6/20103

Quake II(Id Software)

Page 4: 3D Graphics Pipeline - II

3D Polygon Rendering - Examples

10/6/20104

Architectural Walkthrough

Page 5: 3D Graphics Pipeline - II

3D Rendering Pipeline (for direct illumination)

Modeling

Transformation

Lighting

Viewing

Transformation

Projection

Transformation

Clipping

View Port

Transformation

3D Geometric Primitives

Image

3D Model Primitives

3D World Coordinates

3D World Coordinates

3D Camera Coordinates

2D Screen Coordinates

2D Screen Coordinates

2D Image CoordinatesScan

Conversion2D Image Coordinates

Page 6: 3D Graphics Pipeline - II

3D Rendering Pipeline (for direct illumination)

Modeling

Transformation

Lighting

Viewing

Transformation

Projection

Transformation

Clipping

View Port

Transformation

3D Geometric Primitives

Image

3D Model Primitives

3D World Coordinates

3D World Coordinates

3D Camera Coordinates

2D Screen Coordinates

2D Screen Coordinates

2D Image CoordinatesScan

Conversion2D Image Coordinates

Page 7: 3D Graphics Pipeline - II

Viewing Summary

Camera transformations

Map 3D world coordinates to 3D camera coordinates

Matrix has camera vectors as columns

Projection transformation

Map 3D camera coordinates to 2D screen coordinates

Two types of projections:

Parallel

Perspective

Page 8: 3D Graphics Pipeline - II

Projective Transformation

Look familiar?

Page 9: 3D Graphics Pipeline - II

Viewing in OpenGL

OpenGL has multiple matrix stacks – transformation

functions right-multiply the top of the stack

Two most important stacks: GL_MODLEVIEW and

GL_PROJECTION

Points are multiplied by the modelview matrix first

then the projection matrix

GL_MODLEVIEW: Object -> Camera

GL_PROJECTION: Camera -> Screen

glViewport(0,0,w,h): Screen -> Device

Page 10: 3D Graphics Pipeline - II

OpenGL Examplevoid SetUpViewing(){

// The viewport isn’t a matrix, it’s just state...

glViewport( 0, 0, window_width, window_height );

// Set up camera->screen transformation first

glMatrixMode( GL_PROJECTION );

glLoadIdentity();

gluPerspective( 60, 1, 1, 1000 ); // fov, aspect, near, far

// Set up the model->camera transformation

glMatrixMode( GL_MODELVIEW );

gluLookAt( 3, 3, 2, // eye point

0, 0, 0, // look at point

0, 0, 1 ); // up vector

glRotatef( theta, 0, 0, 1 ); // rotate the model

glScalef( zoom, zoom, zoom ); // scale the model

}

Page 11: 3D Graphics Pipeline - II

3D Rendering Pipeline (for direct illumination)

Modeling

Transformation

Lighting

Viewing

Transformation

Projection

Transformation

Clipping

View Port

Transformation

3D Geometric Primitives

Image

3D Model Primitives

3D World Coordinates

3D World Coordinates

3D Camera Coordinates

2D Screen Coordinates

2D Screen Coordinates

2D Image CoordinatesScan

Conversion2D Image Coordinates

Page 12: 3D Graphics Pipeline - II

3D Rendering Pipeline (for direct illumination)

Modeling

Transformation

Lighting

Viewing

Transformation

Projection

Transformation

Clipping

View Port

Transformation

3D Geometric Primitives

Image

3D Model Primitives

3D World Coordinates

3D World Coordinates

3D Camera Coordinates

2D Screen Coordinates

2D Screen Coordinates

2D Image CoordinatesScan

Conversion2D Image Coordinates

Page 13: 3D Graphics Pipeline - II

2D Rendering Pipeline

Clip portions of geometric primitives outside of viewing windowClipping

Viewport

Transformation

Scan

Conversion

2D Geometric Primitives

Transform from clipped primitives from screen to image coordinates

Fill pixels representing primitives in screen coordinates

3D Geometric Primitives

Image

Page 14: 3D Graphics Pipeline - II

2D Rendering Pipeline

Clip portions of geometric primitives outside of viewing windowClipping

Viewport

Transformation

Scan

Conversion

2D Geometric Primitives

Transform from clipped primitives from screen to image coordinates

Fill pixels representing primitives in screen coordinates

3D Geometric Primitives

Image

Page 15: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Window defines part of scene being viewed

Must draw geometric primitives only inside window

Page 16: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Window defines part of scene being viewed

Must draw geometric primitives only inside window

Page 17: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Page 18: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Page 19: 3D Graphics Pipeline - II

Point Clipping

In point (x,y) outside window?

Page 20: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Page 21: 3D Graphics Pipeline - II

Line Clipping

Find the part of the line inside the window

Before Clipping

Page 22: 3D Graphics Pipeline - II

Line Clipping

Find the part of the line inside the window

After Clipping

Page 23: 3D Graphics Pipeline - II
Page 24: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Use simple tests to classify easy cases first

Page 25: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 26: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 27: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 28: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 29: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 30: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 31: 3D Graphics Pipeline - II

Cohen Sutherland Line Clipping

Page 32: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 33: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 34: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 35: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 36: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 37: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 38: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 39: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 40: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 41: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 42: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 43: 3D Graphics Pipeline - II

Cohen-Sutherland Line Clipping

Page 44: 3D Graphics Pipeline - II

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Page 45: 3D Graphics Pipeline - II

Polygon Clipping

Find the part of the polygon inside the window

Page 46: 3D Graphics Pipeline - II

Polygon Clipping

Find the part of the polygon inside the window

Page 47: 3D Graphics Pipeline - II

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Page 48: 3D Graphics Pipeline - II

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Page 49: 3D Graphics Pipeline - II

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Page 50: 3D Graphics Pipeline - II

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Page 51: 3D Graphics Pipeline - II

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Page 52: 3D Graphics Pipeline - II

Clipping to a Boundary

Page 53: 3D Graphics Pipeline - II

Clipping to a Boundary

Page 54: 3D Graphics Pipeline - II

Clipping to a Boundary

Page 55: 3D Graphics Pipeline - II

Clipping to a Boundary

Page 56: 3D Graphics Pipeline - II

Clipping to a Boundary

P’

Page 57: 3D Graphics Pipeline - II

Clipping to a Boundary

P’

Page 58: 3D Graphics Pipeline - II

Clipping to a Boundary

P’

Page 59: 3D Graphics Pipeline - II

Clipping to a Boundary

P’ P’’

Page 60: 3D Graphics Pipeline - II

Clipping to a Boundary

P’ P’’

Page 61: 3D Graphics Pipeline - II

2D Rendering Pipeline

Clip portions of geometric primitives outside of viewing windowClipping

Viewport

Transformation

Scan

Conversion

2D Geometric Primitives

Transform from clipped primitives from screen to image coordinates

Fill pixels representing primitives in screen coordinates

3D Geometric Primitives

Image

Page 62: 3D Graphics Pipeline - II

Viewport Transformation

Page 63: 3D Graphics Pipeline - II

Viewport Transformation

Page 64: 3D Graphics Pipeline - II

Summary of Transformations

Page 65: 3D Graphics Pipeline - II

Summary

Page 66: 3D Graphics Pipeline - II

Summary

Page 67: 3D Graphics Pipeline - II

Next Time