3d graphics pipeline - ii

Post on 12-Sep-2021

36 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

3D Graphics Pipeline – II

Clipping

Instructor – Stephen J. Guy

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

3D Polygon Rendering - Examples

10/6/20103

Quake II(Id Software)

3D Polygon Rendering - Examples

10/6/20104

Architectural Walkthrough

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

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

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

Projective Transformation

Look familiar?

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

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

}

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

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

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

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

Clipping

Avoid parts of primitives outside window

Window defines part of scene being viewed

Must draw geometric primitives only inside window

Clipping

Avoid parts of primitives outside window

Window defines part of scene being viewed

Must draw geometric primitives only inside window

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Point Clipping

In point (x,y) outside window?

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Line Clipping

Find the part of the line inside the window

Before Clipping

Line Clipping

Find the part of the line inside the window

After Clipping

Cohen Sutherland Line Clipping

Use simple tests to classify easy cases first

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Cohen-Sutherland Line Clipping

Clipping

Avoid parts of primitives outside window

Points

Lines

Polygons

Circles

etc.

Polygon Clipping

Find the part of the polygon inside the window

Polygon Clipping

Find the part of the polygon inside the window

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Sutherland Hodgeman Clipping

Clip to each window boundary one at a time

Clipping to a Boundary

Clipping to a Boundary

Clipping to a Boundary

Clipping to a Boundary

Clipping to a Boundary

P’

Clipping to a Boundary

P’

Clipping to a Boundary

P’

Clipping to a Boundary

P’ P’’

Clipping to a Boundary

P’ P’’

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

Viewport Transformation

Viewport Transformation

Summary of Transformations

Summary

Summary

Next Time

top related