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
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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
• 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)
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)
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
• 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
• Presenting previously prepared images
Display file - some portion of the entire scene (clipping)
Multiple viewports in a single window (translation/scaling):
MAE 473-573: Lecture #5 - 2D Graphics
• Coordinate systems:
World/Global, Model/Local, Screen, Camera...
MAE 473-573: Lecture #5 - 2D Graphics
• Basics of Projection - defines the viewing volumePerspective - uses foreshortening (~ distance from viewpoint)Implements a view frustum:
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
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
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
• 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...
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
????
????
??
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
MAE 473-573: Lecture #5 - 2D Graphics
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.)
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… .