computer graphics chapter 6 andreas savva. 2 interactive graphics graphics provides one of the most...

26
Computer Computer Graphics Graphics Chapter 6 Chapter 6 Andreas Savva Andreas Savva

Upload: austin-ball

Post on 04-Jan-2016

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

Computer GraphicsComputer Graphics

Chapter 6Chapter 6

Andreas SavvaAndreas Savva

Page 2: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

2

Interactive GraphicsInteractive Graphics

Graphics provides one of the most natural means of communicating with a computer.

Interactive computer graphics permits user-computer interaction.

Page 3: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

3

Graphics SoftwareGraphics Software

Programming packages (OpenGL)Designed for programmers

General-Purpose Applications packages (Paint)

Designed for non-programmers

Page 4: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

4

Graphics FunctionsGraphics FunctionsA general-purpose graphics package provides users with a variety of functions for creating and manipulating pictures. These routines can be categorized according to whether they deal with:

Output

Input

Attributes

Transformations

Viewing

General control

Page 5: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

5

Output PrimitivesOutput Primitivesbasic tools for constructing picturesbasic tools for constructing pictures

Character strings

Geometric entitiesPoints

Straight lines

Curved lines

Filed areas (Polygons, Circles, etc)

Shapes defined with arrays or color points

Page 6: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

6

AttributesAttributesproperties of the output primitivesproperties of the output primitives

Intensity Color specifications Line styles Text styles Area-filling patterns

Page 7: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

7

Geometric TransformationsGeometric Transformationssize, position and orientation of an object within the scenesize, position and orientation of an object within the scene

Translate Scale Rotate

Page 8: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

8

Control OperationsControl Operations

Clearing a display screen Initialize a parameter

Page 9: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

9

Software StandardsSoftware Standards

Primary goal – portability Software can be moved easily from one

hardware system to another Software can be used in different

implementations and applications Without standards, software need to be

rewritten for different systems

Page 10: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

10

A simple Paint ProgramA simple Paint ProgramIt should have the ability to work with geometric objects such as line segments and polygons. Given that geometric objects are defined through vertices, the program should allow us to enter vertices interactively.It should have the ability to manipulated pixels, and thus to draw directly into the frame buffer.It should provide control of attributes such as color, line type, and fill patterns.It should include menus for controlling the application.It should behave correctly when the window is moved or resized.

Page 11: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

11

Coordinate RepresentationsCoordinate RepresentationsModeling coordinates: (xm , ym)

World coordinates: (xw , yw)

Normalized coordinates (Range: 0 - 1): (xn , yn)

Device coordinates: (xd , yd)

Page 12: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

12

World to DeviceWorld to Device

hDeviceWidt

MinXMaxXxScale ww

htDeviceHeig

MinYMaxYyScale ww

xScale

MinXxx ww

d

(xw ,yw) (xd ,yd)

Display area

yScale

MinYyy ww

d

Page 13: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

13

World to NormalizedWorld to Normalized

ww

wwn MinXMaxX

MinXxx

ww

wwn MinYMaxY

MinYyy

Normalized to DeviceNormalized to DevicehDeviceWidtxx nd

htDeviceHeigyy nd

Page 14: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

14

Device CoordinatesDevice Coordinates

(xw ,yw)

(xd ,yd)

Display area(xd ,DeviceHeight-yd)

(0,0)

(0,0)

Page 15: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

15

ExercisesExercises

Assume that the screen monitor has 1200800 pixels. Find and display:

(0,0)

(1200,800)

1. the device coordinates for the point (-18,12) if the display area is -25 ≤ x ≤ 8 and -8 ≤ y ≤ 16, as shown below:

2. the device coordinates for the point (-18,12) if the display area is -216 ≤ x ≤ -2 and -30 ≤ y ≤ 30.

(-18,12)

Display area

8-25

-8

16

Page 16: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

16

3. the device coordinates for the triangle shown in the figure below, by using the normalized coordinates which you should calculate first.

4. the device coordinates for the triangle shown above if the display area is 25 ≤ x ≤ 100 and -5 ≤ y ≤ 40. You should also find the device coordinates for the two points where the triangle sides intersect the line x = 25.

5. the world coordinate of the pixel (400,167) for the display area in question 1.

(35,30)

Display area

5010-5

40

(43,15)(18,10)

Page 17: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

17

Pipeline Vs ParallelismPipeline Vs Parallelism

Multiprocessing has two basic forms:A pipeline processor contains a number of processing elements (PEs) arranged such that the output of one becomes the input of the next, in pipeline fashion.

The PEs of a parallel processor are arranged side-by-side and operate simultaneously on different portions of the data.

Page 18: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

18

Drawing PipelineDrawing Pipeline

Standard drawing process uses a pipeline of computations

Starts with: Collection of polygons Ends with: Image stored in frame buffer

(Desired result)

Page 19: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

19

PipelinePipelineInput device

Model traversalnew view of the model

Model transform

Viewing transform

Clipping

Project & Map to Viewport

Lighting

Shading

Rasterization

Display

Page 20: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

20

Model TraversalModel Traversal

Data structure of Polygons Each polygon in own coordinate system List:

01

2

3

Page 21: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

21

Modeling TransformationsModeling Transformations

Move each polygon to its desired location

Operations: Translate, Scale, Rotate

01

2

3 x

y

Page 22: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

22

ClippingClipping

Viewport is the area of the Frame Buffer where the new image is to appear

Clipping eliminates geometry outside the viewport

Viewport

Clipping

ResultingPolygon

Page 23: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

23

Project & Map to ViewportProject & Map to Viewport

Projection takes 3D data and flattens it to 2D

Eye

Projection Plane(Screen)

Page 24: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

24

LightingLighting

Simulate effects of light on surface of objects

Each polygon gets some light independent of other objects

Page 25: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

25

ShadingShading

Lighting could be calculated for each pixel, but that’s expensive

Shading is an approximation:Gouraud shading: Light each vertex

Interpolate color across pixels

Page 26: Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive

26

RasterizationRasterization

Find which pixels are covered by polygon:

Plane Sweep: For each polygongo line-by-line from min to max

go from left boundary to right boundary pixel by pixelFill each pixel (color & density)

2D Process