computer graphics chapter 6 andreas savva. 2 interactive graphics graphics provides one of the most...
TRANSCRIPT
Computer GraphicsComputer Graphics
Chapter 6Chapter 6
Andreas SavvaAndreas Savva
2
Interactive GraphicsInteractive Graphics
Graphics provides one of the most natural means of communicating with a computer.
Interactive computer graphics permits user-computer interaction.
3
Graphics SoftwareGraphics Software
Programming packages (OpenGL)Designed for programmers
General-Purpose Applications packages (Paint)
Designed for non-programmers
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
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
6
AttributesAttributesproperties of the output primitivesproperties of the output primitives
Intensity Color specifications Line styles Text styles Area-filling patterns
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
8
Control OperationsControl Operations
Clearing a display screen Initialize a parameter
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
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.
11
Coordinate RepresentationsCoordinate RepresentationsModeling coordinates: (xm , ym)
World coordinates: (xw , yw)
Normalized coordinates (Range: 0 - 1): (xn , yn)
Device coordinates: (xd , yd)
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
13
World to NormalizedWorld to Normalized
ww
wwn MinXMaxX
MinXxx
ww
wwn MinYMaxY
MinYyy
Normalized to DeviceNormalized to DevicehDeviceWidtxx nd
htDeviceHeigyy nd
14
Device CoordinatesDevice Coordinates
(xw ,yw)
(xd ,yd)
Display area(xd ,DeviceHeight-yd)
(0,0)
(0,0)
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
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)
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.
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)
19
PipelinePipelineInput device
Model traversalnew view of the model
Model transform
Viewing transform
Clipping
Project & Map to Viewport
Lighting
Shading
Rasterization
Display
20
Model TraversalModel Traversal
Data structure of Polygons Each polygon in own coordinate system List:
01
2
3
21
Modeling TransformationsModeling Transformations
Move each polygon to its desired location
Operations: Translate, Scale, Rotate
01
2
3 x
y
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
23
Project & Map to ViewportProject & Map to Viewport
Projection takes 3D data and flattens it to 2D
Eye
Projection Plane(Screen)
24
LightingLighting
Simulate effects of light on surface of objects
Each polygon gets some light independent of other objects
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
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