Download presentation
1
Attributes of Graphics Primitives Chapter 4
2
Atrributes of Output Primitves
In general, any parameter that affects the way a primitive displayed is an attribute parameter. Ex: Line attributes type (solid, dashed, dotted), width, cap (butt, round, projecting square caps), join (miter, round, etc.), color, grayscale
3
Point Attributes -OpenGL
glPointSize(GLfloat size); Example : glColor3f ( 1.0, 0.0, 0.0); glBegin(GL_POINTS); glVertex2i(50,100); glPointSize(2.0); glColor3f ( 0.0, 1.0, 0.0); glVertex2i(75,150); glPointSize(3.0); glColor3f ( 0.0, 0.0, 1.0); glVertex2i(100,200); glEnd ( );
4
3 Line Attributes- OpenGL
Line Color – glcolor( ); Line Width - glLineWidth(GLfloat width); Line Style - glLineStipple(repeatFactor, pattern); Pattern – 16-bit integer ( 0xFFFF with each bit position 1 ) default is a solid line Repeat factor specifies how many times each bit in the pattern is repeated before the next bit in the pattern is applied.- Default value is 1 Example: glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x00FF); // Plot dashed double width line glLineWidth(2.0); lineplot( ) ; // plot the line glLineStipple(1, 0x0101); \\Plot dotted triple width line glLineWidth(3.0); lineplot( ); glDisable(GL_LINE_STIPPLE);
5
Polygons Filling Polygons Scan-line fill algorithm
Inside-Outside tests Boundary fill algorithm 11 1 2 3 4 5 6 7 8 9 10 5 6 7 8 9 4 3 1 2
6
SCAN-CONVERTING POLYGONS
Find the intersections of the scan-line with all edges of the polygon. Sort the intersections by increasing the x coordinate. Fill in all pixels between pairs of intersections that lie interior to the polygon, using the odd-parity rule to determine that a point is inside a region. 6 .6.
7
Scan-Line Polygon Fill
Topological Difference between 2 Scan lines y : intersection edges are opposite sides y’ : intersection edges are same side y 1 2 2 y’ 1 1
8
Scan-Line Polygon Fill (cont.)
Edge Sorted Table B yC yB xC 1/mCB C C’ E yD yC’ xD 1/mDC yE xD 1/mDE D yA yE xA 1/mAE yB xA 1/mAB A 1 Scan-Line Number
9
Procedure Set y to the smallest y that has an entry in the ET(Edge Table – all edges sorted by smaller y cord Initialize the AET(Active ET corresponds to current scan line) to be empty. Repeat until the AET and ET are empty: Move from ET bucket y to AET those edges whose ymin = y. Sort the AET on x. Fill-in desired pixel values on scan-line y by using pairs of x coord. from the AET. Increment y by 1. Remove from the AET those entries that y=ymax. For each non-vertical edge remaining in the AET, update x for the new y: x = x + 1/m.
10
Example
11
Inside-Outside Tests Self-Intersections – scan line polygon Fill Algorithm Odd (Interior)-Even(Exterior) rule exterior interior
12
Boundary-Fill Algorithm
Proceed to Neighboring Pixels 4-Connected 8-Connected
13
OpenGL Implementation
A convex polygon means that all the angles inside the polygon formed by the edges are smaller than 180 degrees. If a polygon is not convex, it is concave. Convex polygons can be scan-converted faster than concave polygons. OpenGL draws a convex polygon with the following commands: glBegin(GL_POLYGON); // a list of vertices glEnd();
14
Effects of Scan conversion
Aliasing : The distortion that result from scan conversion. Staircase Effect ( jagged appearance) Unequal Brightness( slanted line appears dimmer than a horizontal/vertical) Picket Fence Problem(object is not aligned to the pixel grid) Hence we go for Anti Aliasing
15
Antialiasing Aliasing Undersampling: Low-frequency sampling
Nyquist sampling frequency: Nyquist sampling interval: original sample reconstruct
16
Antialiasing Supersampling (Postfiltering)
Increase the sampling rate by Sampling object charactersitics at a high resolution and display the results in low resolution is called Area Sampling (Prefiltering) Pixel Phasing Shift the display location of pixel areas
17
SPECIFYING A COLOR -OpenGL
glColor3f(0.0, 0.0, 0.0); draw_object(A); draw_object(B); glColor3f(1.0, 0.0, 0.0); draw_object(C); glColor3f(0.0, 0.0, 0.0); black glColor3f(1.0, 0.0, 0.0); red glColor3f(0.0, 1.0, 0.0); green glColor3f(1.0, 1.0, 0.0); yellow glColor3f(0.0, 0.0, 1.0); blue glColor3f(1.0, 0.0, 1.0); magenta glColor3f(0.0, 1.0, 1.0); cyan glColor3f(1.0, 1.0, 1.0); white
18
Supersampling (postfiltering)
Increase sampling rate, each pixel area is covered by a finer grid We can then use multiple sample points in a pixel that is within a line to determine an appropriate intensity level for the pixel. Supersampling algorithms often choose more weight to subpixels near the center of a pixel area: pixel- wighting masks
19
Area sampling (prefiltering)
Determine pixel intensity by calculating the areas of overlap of each pixel with the objects to be displayed Unweighted Area Sampling determines the pixel intensity by the overlap area only Weighted Area Sampling an area closer to the pixel’s center has greater influence on the pixel’s intensity than an equal area further away from the pixel’s center.
20
Supersampling Subpixels Increase resolution 22
(10, 20): Maximum Intensity (11, 21): Next Highest Intensity (11, 20): Lowest Intensity 21 20 10 11 12
21
Supersampling Subpixels (10, 20): Maximum Intensity –Level3
(11, 21), (12,21): Next Highest Intensity-2 (11, 20),(12,22): Lowest Intensity-1 Subpixels Increase resolution 22 21 20 10 11 12
22
Pixel-Weighting Masks
Give More Weight to Subpixels Near the Center of a Pixel Area Sum of the weights in the filter =1 Low pass Filtering 1 2 4 1/16 1/8 1/4
23
Area Sampling Set Each Pixel Intensity Proportional to the Area of Overlap of Pixel 2 adjacent vertical (or horizontal) screen grid lines trapezoid 22 (10, 20): 90% (10, 21): 15% 21 20 10 11 12
24
Filtering Techniques Filter Functions (Weighting Surface) Box Filter
Cone Filter Gaussian Filter
25
Character Generation Bitmapped Fonts:
Bitmapped Fonts: .Characters represented as a rectangular grid or bits. .Simple and quick to draw because character is mapped onto pixel positions in the frame buffer. .However, it needs a lot of space. Each variation in size and style needs to be stored separately in a font cache. .Can still generate different size and styles from a single bitmap but the results are poor quality because bitmap descriptions do not scale well.
26
Character Generation . Overall design or style for set of characters is called type-face. .Ex: Courier, Arial, Times New Roman. .Type-face are serif and san-serif (optima). .Font is originally referred to size and format.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.