mae 473-573: lecture #5 - 2d graphics€¦ · mae 473-573: lecture #5 - 2d graphics • overview of...

22
MAE 473-573: Lecture #5 - 2D Graphics Lecture Overview: •Lecture motivation •Overview of computer graphics •Building Blocks •Screen vs. world vs. model coordinates •Basics of Projection •2D windowing and clipping •Viewport and view frustum •Bandwidth requirements •Rasterization •Frame buffering •Next up: Programmatic generation of 2D graphics using X Assignment #2 - 2D Graphics exercise - delayed

Upload: others

Post on 19-Aug-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Lecture Overview:

• Lecture motivation• Overview of computer graphics• Building Blocks• Screen vs. world vs. model coordinates• Basics of Projection• 2D windowing and clipping• Viewport and view frustum• Bandwidth requirements• Rasterization• Frame buffering• Next up: Programmatic generation of 2D graphics using X

Assignment #2 - 2D Graphics exercise - delayed

Page 2: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Teaching Assistants:

Newsgroup: sunyab.mae.573

1. Nidal A [email protected]: 311 Jarvis HallOffice hours: Tuesday, Thursday: 11-1Lab hours: none

2. Kok-Lam [email protected]: 1017 Furnas HallOffice hours: Tuesday, Thursday: 1-3Lab hours: 8-10 Monday (139 Hochstetter), 3-5 Friday (1018 Furnas)

3. Pradeep [email protected] hours: noneLab hours: 8-10 Tuesday (1018 Furnas), 12-3 Thursday (139 Hochstetter)

4. Parijat [email protected]: 1014 Furnas HallOffice hours: Monday, Wednesday: 10-12Lab hours: none

Page 3: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Instructor Office Hours:

Dr. Chugh: Monday (10-11)Thursday (2-3)

Dr. Hulme Tuesday (9-10)Thursday (9-10)

Page 4: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Lecture Motivation:

• This class: programmatic generation of computer graphics

• Understand the basics of how graphics appear on a computer screen

• Prepare for more complex graphics operations (transformations)

Page 5: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• Overview of computer graphics:

End result: A 2D picture on a computer screenOften a projection of a 3D imageColors, lighting, intensity, (depth)

Must understand how:

• pictures are represented• pictures are prepared for presentation• previously prepared pictures are represented• interaction with picture is accomplished

(Picture: collection of points/lines/text displayed on a screen)

Page 6: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• Building Blocks:

• Representation - points (used to create polygons and lines, … )

ex: unit square - represent by points/lines/polygons

ex: VRML - indexed face set data

Page 7: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

• Preparing pictures for presentation

Storage of picture (points) - data baseTo specify point position - use relative or absolute coordinatesRelated concern - integer coordinate word length (2n-1 -1)For 16 bit machine: wl = 32767… … …

Can instead use homogeneous coordinates:Represent n-dimensional space with n+1 dimensions(x,y,z) - (x,y,z,h); h - homogeneous coordinateex: for x = 60000 - use: (30000, y/2, z/2, 1/2)

(Less of a concern with 32-bit machines… )

MAE 473-573: Lecture #5 - 2D Graphics

Page 8: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

• Presenting previously prepared images

Display file - some portion of the entire scene (clipping)

Displayed picture: rotated, translated, scaled, projected, … (not static)

Result: (compound) Transformation matrix

Then: hidden line removal, shading, transparency, textures, colors, ...

Windowing - the portion of the scene that is seen

MAE 473-573: Lecture #5 - 2D Graphics

Page 9: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

windowing (2D)

Page 10: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

view frustum (3D)

Page 11: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

• InteractionConventional: mouse, keyboard, tablet (CAD)Novelty: Joystick, track ballHigh-tech (VR): Haptic glove, wand

MAE 473-573: Lecture #5 - 2D Graphics

• Presenting previously prepared images (cont.)

Multiple viewports in a single window (translation/scaling):

Page 12: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• Coordinate systems:

World/Global, Model/Local, Screen, Camera...

Page 13: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• Basics of Projection - defines the viewing volumePerspective - uses foreshortening (~ distance from viewpoint)Implements a view frustum:

Page 14: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Orthographic - uses a viewing volume, which has static sizeUsed in CAD/Architecture, where object size/angles are crucial

Page 15: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• Bandwidth requirements

Importance of communication speed: CPU and graphics deviceExample: Refresh a curved line with 250 segments:

Refresh rate[(no. points)(no. coord./pt.)(no. sig figs./pt.)(no. bits/char.)]

30 frames/second250 points3 coords. (x,y,z)1 8-bit byte per character

= 1,080,000 bits/second bandwidth

Page 16: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

• RasterizationConversion of primitive objects to a 2D screen imageDetermine which squares of an integer grid are occupiedAssign color, and other values to the square

Anti-aliasing - correction for inclined lines, which cause jagged linesCommonly called “staircasing”, in graphics

Page 17: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

• Rasterization - numerical methods for determining “lit pixels”

MAE 473-573: Lecture #5 - 2D Graphics

A. 1st order:

Pick coordinate with largest variation (assume x). Start at minvalue, and increment by 1. Use 1st order T.S.E. to approximatecorresponding y. Then, round off for final value:

ab

ab

1nn

xxyy

xy

:where

)1(xyyy

???

??

???? ?xo = xa

x1 = xa+1...

Page 18: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

B. Parametric Approach: can yield a more uniform densityfor lines in arbitrary orientations

Define an integer parameter n (a pixel density)Then:

Round off to get pixel positions: x = [xn], y = [yn]

Example (overhead)

MAE 473-573: Lecture #5 - 2D Graphics

dndyyy;

dndxxx

nyy

dndy;

nxx

dndx

1nn1nn

abab

????

????

??

Page 19: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Hardware: Frame buffering

DEF: A large contiguous piece of computer memory whichstores the image to be displayed

Common example:

8 bit planes per color (RGB) - 24 total256 (28) intensities of each color(28)3 = 16,777,216 possible colors

Page 20: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Page 21: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

Pixel access time (nanoseconds):

• 1/(Frame buffer size x Desired screen resolution)(Typically, 30-60 Hz is required for smooth visuals… )

• ex: 512 x 512 element square raster, 30 Hz:1/(512 x 512 x 30) = 127 nanoseconds

• Resolution degradation at 1024 x 1024:1/(1024 x 1024 x res) = 127 ns; res = 7.5 Hz.

Q: Relevance? A: “The battle of the clock” - detail vs. performance

MAE 473-573: Lecture #5 - 2D Graphics

Hardware: Frame buffering (cont.)

Page 22: MAE 473-573: Lecture #5 - 2D Graphics€¦ · MAE 473-573: Lecture #5 - 2D Graphics • Overview of computer graphics: End result: A 2D picture on a computer screen Often a projection

MAE 473-573: Lecture #5 - 2D Graphics

Next up: Programmatic generation of 2D graphics using X

You build the entire graphics scene from the ground up

Programmatic control over:• Viewing (“positioning the tripod”) • Modeling (“designing the scene”)• Projection (“adjusting the camera lens”) • Viewport (“take the photograph”)

Will incorporate translation, rotation, scaling, etc… .