Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Similar documents
Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Chapter 3. Sukhwinder Singh

Attributes of Graphics Primitives

Einführung in Visual Computing

Graphics (Output) Primitives. Chapters 3 & 4

CS 325 Computer Graphics

Unit 2 Output Primitives and their Attributes

CSCI 4620/8626. Computer Graphics Attributes of Graphics Primitives (Chapter 5)

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

Rasterization: Geometric Primitives

CSCI 4620/8626. Primitives and Attributes

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

COMP371 COMPUTER GRAPHICS

Computer Graphics. The Two-Dimensional Viewing. Somsak Walairacht, Computer Engineering, KMITL

Rasterization, or What is glbegin(gl_lines) really doing?

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Chapter - 2: Geometry and Line Generations

Computer Graphics Lecture Notes

Computer graphics 2 Marks 1. Define Computer graphics.

Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007

Computer Graphics Geometry and Transform

UNIT 2 GRAPHIC PRIMITIVES

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Overview of Computer Graphics

Graphics Output Primitives

Computer Graphics. - Rasterization - Philipp Slusallek

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Line Drawing. Foundations of Computer Graphics Torsten Möller

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

CS 543: Computer Graphics. Rasterization

(Refer Slide Time: 00:02:00)

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Chapter 8: Implementation- Clipping and Rasterization

Text in OpenGL and Windows. Computer Graphics Attributes. Computer Graphics. Binghamton University. EngiNet. Thomas J. Watson

Aliasing and Antialiasing. ITCS 4120/ Aliasing and Antialiasing

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

CS602 MCQ,s for midterm paper with reference solved by Shahid

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Adobe Photoshop Sh S.K. Sublania and Sh. Naresh Chand

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Scan Conversion. Drawing Lines Drawing Circles

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

Topic #1: Rasterization (Scan Conversion)

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

4.5 VISIBLE SURFACE DETECTION METHODES

1 Introduction to Graphics

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

CS6504 & Computer Graphics Unit I Page 1

Scan Converting Lines

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

From Ver(ces to Fragments: Rasteriza(on

CSCI 4620/8626. Coordinate Reference Frames

Scan Converting Text. Attributes of Output Primitives. CS 460/560 Computer Graphics. Binghamton University. EngiNet. Thomas J.

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

CS Rasterization. Junqiao Zhao 赵君峤

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k

INSTRUCTORS: A. SANPHAWAT JATUPATWARANGKUL A. NATTAPOL SUPHAWONG A. THEEPRAKORN LUNTHOMRATTANA COMPUTER AIDED DESIGN I AUTOCAD AND ILLUSTRATOR CS

How to draw and create shapes

CS 160: Lecture 10. Professor John Canny Spring 2004 Feb 25 2/25/2004 1

Display Technologies: CRTs Raster Displays

Scan Conversion of Polygons. Dr. Scott Schaefer

Layer Styles. Learning Objectives. Introduction

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2012 Lecture 5 September 13, 2012

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

8. Hidden Surface Elimination

Computer Graphics Geometry and Transform

5. Text CHAPTER HIGHLIGHTS 10/12/2016 CHAPTER. Text tradition. Codes for computer text. t. Font technologies. Multimedia text.

Rendering. A simple X program to illustrate rendering

CS354 Computer Graphics Sampling and Aliasing

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

IT82: Mul timedia. Practical Graphics Issues 20th Feb Overview. Anti-aliasing. Fonts. What is it How to do it? History Anatomy of a Font

Do Now # 1 Label the Photoshop Interface.

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

UNIT -8 IMPLEMENTATION

Prime Time (Factors and Multiples)

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

Prof. Feng Liu. Fall /25/2018

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

CS488 2D Graphics. Luc RENAMBOT

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

SE Mock Online Test 1-CG

Computer Graphics. Lecture 3 Graphics Output Primitives. Somsak Walairacht, Computer Engineering, KMITL

CSC Computer Graphics

anatomy cap height x-height baseline descender ligature finial terminal ascender spine small capital uppercase counter cross bar lowercase

Advanced Shading I: Shadow Rasterization Techniques

Time: 3 hours Max. Marks: 80. Note: Answer FIVE full questions, choosing one full question from each module.

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

Intro to Modeling Modeling in 3D

EF432. Introduction to spagetti and meatballs

Advanced Ray Tracing

Transcription:

Computer Graphics Chapter 4 Attributes of Graphics Primitives Somsak Walairacht, Computer Engineering, KMITL 1

Outline OpenGL State Variables Point Attributes t Line Attributes Fill-Area Attributes Scan-Line Polygon-Fill Algorithm Fill Methods for Areas with Irregular Boundaries Character Attributes Antialiasing 01074410 / 13016218 Computer Graphics 2

Introduction A parameter that affects the way a primitive i i is to be displayed d is referred to as an Attribute Parameter For example, lines can be dotted or dashed, fat or thin, and blue or orange Areas might be filled Text can appear from left to right, slanted diagonally, or in vertical 01074410 / 13016218 Computer Graphics 3

OpenGL State Variables For example, Color and other primitive attributes, the current matrix mode, the elements of the model-view matrix, the current position for the frame buffer, and the parameters for the lighting effects in a scene Remained in effect until their new values are specified We can query the system to determine the current value of a state parameter 01074410 / 13016218 Computer Graphics 4

Point Attributes Two attributes for points: color and size Color components are set with RGB values or an index into a color table Size is an integer multiple of the pixel size 01074410 / 13016218 Computer Graphics 5

Line Attributes Three basic attributes: color, width, and style Additionally, lines may be generated with other effects, such as pen and brush strokes 01074410 / 13016218 Computer Graphics 6

Fill-Area Attributes Most graphics packages limit fill areas to polygons, because they are described with linear equations Further restriction requires fill areas to be convex 01074410 / 13016218 Computer Graphics 7

Fill-Area Attributes (2) There are two basic procedures for filling an area on raster systems 1 (simple shape) Determines the overlap intervals for scan lines that cross the area Pixel positions along these overlap intervals are set to the fill color 2 (not so simple shape) Start from a given interior position and paint outward pixel-by-pixel until boundary 01074410 / 13016218 Computer Graphics 8

Fill-Area Attributes (3) The scan-line approach is usually applied to simple shapes such as circles or regions with polyline boundaries General graphics packages use this fill method While using a starting interior point, it is useful for filling areas with more complex boundaries and in interactive painting systems 01074410 / 13016218 Computer Graphics 9

Fill Styles 01074410 / 13016218 Computer Graphics 10

Color-Blended Fill Regions A pattern could be combined with background colors Using a transparency factor that determines how much of the background should be mixed with the object color 01074410 / 13016218 Computer Graphics 11

Color-Blended Fill Regions (2) Simple logical or replace operations 01074410 / 13016218 Computer Graphics 12

Color-Blended Fill Regions (3) Algorithm using color-blending Soft-fill or Tint-fill algorithms A foreground color F with a single background color B, where F = B The current RGB color P of each pixel within the area to be refilled is some linear combination of F and B P = tf + (1 t)b where the transparency factor t has a value between 0 and 1 P = (P R, P G G, P B B), F = (F R, F G G, F B B), B = (B R, B G G, B B B) t = P k B k / F k B k where k = R, G, or B; and F k B k Similarly, a foreground color is to be merged with multiple background color P = t 0 F+t 1 B 1 +(1 t 0 t 1 )B 2 01074410 / 13016218 Computer Graphics 13

General Scan-Line Polygon-Fill Algorithm A scan-line fill of a region is performed by first determining the intersection positions of the boundaries of the fill region with the screen scan lines Then the fill colors are applied to each section of a scan line that lies within the interior of the fill region The scan-line fill algorithm identifies the same interior regions as the odd-even rule 01074410 / 13016218 Computer Graphics 14

General Scan-Line Polygon-Fill Algorithm (2) Basic scan-line procedure: 2 steps 1. Edge intersections are sorted from left to right 2. Then the pixel positions between, and including, each intersection pair are set to the specified fill color จดร วมขอบอย ด านเด ยวก น จ ดรวมขอบอย ดานเดยวกน Sort x-intersection ascending จ ดร วมขอบอย คนละด าน 01074410 / 13016218 Computer Graphics 15

General Scan-Line Polygon-Fill Algorithm (3) To split those vertices that should be counted as one intersection When the endpoint y coordinates of the two edges are increasing, the y value of the upper endpoint for the current edge is decreased by 1 When the endpoint y values are monotonically decreasing, the y coordinate of the upper endpoint of the edge following the current edge is decreased by 1 next current current next 01074410 / 13016218 Computer Graphics 16

General Scan-Line Polygon-Fill Algorithm (4) Coherence properties can be used in computer-graphics algorithms to reduce processing It often involves incremental calculations l applied along a single scan line or between successive scan lines 01074410 / 13016218 Computer Graphics 17

Determining Fill-Area Edge Intersections Two successive scan lines crossing the left edge of a triangle The slope of this edge m = (y k+1 y k )/(x k+1 x k ) The change in y coordinates y k+1 y k = 1 Each successive x intercept can thus be calculated by adding the inverse of the slope and rounding to the nearest integer x k+1 = x k +1/m 01074410 / 13016218 Computer Graphics 18

Coherence Methods (Truncate) counter = 0 counter += dx If counter dy then { x++, counter -= dy } y++ Method 1 Method 2 (Rounding) counter = 0 counter += 2dx If counter dy then { x++, counter -= 2dy } y++ m=7/3 [1] [2] 01074410 / 13016218 Computer Graphics 19

Sorted Edge Table Proceeding around the edges in either a clockwise or a counterclockwise order, sorted on the smallest y value of each edge Only nonhorizontal edges are entered into the table For a particular scan line, the maximum y value for that edge, the x-intercept value (at the lower vertex) for the edge, the inverse slope of the edge For each scan line, the edges are in sorted order from left to right 01074410 / 13016218 Computer Graphics 20

Sorted Edge Table (2) 01074410 / 13016218 Computer Graphics 21

Sorted Edge Table (3) Process the scan lines from the bottom of the polygon to its top -> active edge list for each scan line For a scan line contains all edges crossed, uses iterative coherence calculations to obtain the edge intersections For each scan line, fill interior pixel at x-intercept values from left to right 01074410 / 13016218 Computer Graphics 22

Scan-Line Fill of Convex Polygons Uses coordinate extents to determine which edges cross a scan line Intersection calculations with these edges then determine the interior pixel span Any vertex crossing is counted as a single point Some graphics packages restrict fill areas to be triangles This makes filling even easier 01074410 / 13016218 Computer Graphics 23

Scan-Line Fill for Regions with Curved Boundaries For simple curves such as circles or ellipses, apply fill methods for convex polygons Each scan line cross just two boundary intersections Determine these two intersection points using the incremental calculations in the midpoint method Simply fill in the horizontal pixel spans Applies symmetric property between quadrants 01074410 / 13016218 Computer Graphics 24

Fill Methods For Areas with Irregular Boundaries Boundary-fill algorithm, is employed in interactive painting packages, where interior points are easily selected Select a fill color, specify the boundary color, and pick an interior i point 01074410 / 13016218 Computer Graphics 25

Fill Methods For Areas with Irregular Boundaries (2) Two methods for processing neighboring pixels from a current test position 4-connected : pixel positions that are right, left, above, and below the current pixel 8-connected : Neighboring positions to be tested includes the four diagonal pixels 01074410 / 13016218 Computer Graphics 26

Boundary Fill 01074410 / 13016218 Computer Graphics 27

Flood-Fill Algorithm Paints areas by replacing a specified interior color instead of searching for a particular boundary color Starting from a specified interior point (x, y) and reassign all pixel values to a given interior color Using either a 4-connected or 8-connected approach 01074410 / 13016218 Computer Graphics 28

Character Rendering Letters, digits, non-alphanumeric Font overall design style of a set of characters Times New Roman, Courier, Arial Fonts can vary in appearance Normal, Bold, Italic Rendering techniques Bitmap font Outlined fonts - Examples are PostScript Type 1 and Type 3 fonts, TrueType and OpenType. 01074410 / 13016218 Computer Graphics 35

Character Attributes Characters with attributes such as font, size, color, and orientation Color settings for displayed text can be stored in the system attribute list Adjusts text size by scaling the overall dimensions (height h and width) of characters or by scaling only the height or the width 01074410 / 13016218 Computer Graphics 36

Character Attributes (2) The orientation for a character string can be set according to the direction of a character up vector 01074410 / 13016218 Computer Graphics 37

About Point Font size usually denoted in point (e.g. 10-point, 12- point) Denotes height of the characters in inches Atermfromtypography typography Smallest unit of measure We are concerned with desktop publishing (DTP) point, also called the PostScript point Not the original typographical point 1 DTP point = 1/72 of an inch or approx 0.0139 inch 01074410 / 13016218 Computer Graphics 38

Antialiasing Jagged or stair-step appearance happens because the sampling process digitizes coordinate points on an object to discrete integer pixel positions This distortion ti due to low-frequency sampling (undersampling) is called aliasing 01074410 / 13016218 Computer Graphics 39

Aliasing Starting with a continuous signal, then sample the signal at discreet points Those samples are then used to reconstruct a new signal It is intended to represent the original signal However, the reconstructed signals are a false representation of the original i signals In the English language, When a person uses a false name, it is known as an alias So, it was adapted in signal analysis to apply to falsely represented signals Aliasing in computer graphics usually results in visually distracting artifacts A lot of effort goes into trying to stop it This is known as antialiasing 01074410 / 13016218 Computer Graphics 40

Nyquist Frequency Theoretically, in order to adequately reconstruct a signal of frequency x, the original signal must be sampled with a frequency of greater than 2x This is known as the Nyquist Sampling Frequency or Nyquist Limit However, this is assuming that we are doing a somewhat idealized sampling and reconstruction In practice, it s probably a better idea to sample signals at a minimum of 4x 01074410 / 13016218 Computer Graphics 45

Nyquist Sampling Frequency To avoid losing information from such periodic objects, we need to set the sampling frequency to at least twice that of the highest frequency occurring in the object f s = 2 f max 01074410 / 13016218 Computer Graphics 46

Nyquist Sampling Interval The sampling interval should be no larger than one-half the cycle interval x s = x cycle / 2 where x cycle = 1/ f max 01074410 / 13016218 Computer Graphics 47

Antialiasing (2) To increase sampling rate, simply displays objects at higher h resolution Limitations: How big the frame buffer Refresh rate 60 fps or more Modify pixel intensities Appropriately varying the intensities iti of pixels along the boundaries of primitives 01074410 / 13016218 Computer Graphics 49

Antialiasing (3) Pre-filtering Filter before sampling- determine pixels from the continuous signal Disadvantage: percent calculation introduces complexity Post-filtering Filter after sampling- determine e pixels from the discreet samples of the continuous signal 01074410 / 13016218 Computer Graphics 50

Antialiasing (4) Supersampling (or Post-filtering) use multiple sample points across the finer grid to determine an appropriate intensity level for each screen pixel Area sampling (or Pre-filtering) by calculating the areas of overlap of each pixel with the objects to be displayed Pixel phasing Hardware approach by shifting the display location of pixel areas ( micropositioning iti i the electron beam in relation to object geometry) 01074410 / 13016218 Computer Graphics 51

Supersampling p Straight-Line Segments Divide each pixel into a number of subpixels and count the number of subpixels that overlap the line path The intensity level for each pixel is then set to a value that is proportional to this subpixel count 1 2 2 3 1 01074410 / 13016218 Computer Graphics 52

Supersampling p Straight-Line Segments : Advantage Represent the line with finite width The number of possible intensity levels for each pixel is equal to the total number of subpixels within the pixel area 01074410 / 13016218 Computer Graphics 53

Supersampling p Straight-Line Segments : Advantage (2) Since a particular line might cross several different color areas We can average subpixel intensities to obtain pixel color settings Ex. 5 subpixels within a particular pixel area are determined to be inside a red line and the remaining 4 subpixels fall within a blue background pixel color = (5 red + 4 blue) / 9 01074410 / 13016218 Computer Graphics 54

Subpixel Weighting Mask By giving more weight to subpixels near the center of a pixel area Since these subpixels are to be more important in determining the overall intensity of a pixel Intensities calculated l for each of the 9 subpixels Center subpixel is weighted by a factor of 1/4 Top, bottom, and side subpixels are each of 1/8 Corner subpixels are each weighted by 1/16 01074410 / 13016218 Computer Graphics 55

Area Sampling Straight-Line Segments A method for estimating pixel overlap areas The pixel with grid coordinates (10, 20) is about 90% covered by the line area, so its intensity would be set to 90% of the maximum intensity Similarly (10, 21) would be set to 15% 01074410 / 13016218 Computer Graphics 56

Filtering Techniques A more accurate method for antialiasing lines Similar to those for applying a weighting mask, but now we integrate over the pixel surface to obtain the weighted average intensity 01074410 / 13016218 Computer Graphics 57

Pixel Phasing With the technique by moving (micropositioning) pixel positions closer to the line path The electron beam is typically shifted by ¼, ½, or ¾ of a pixel diameter to plot points closer to the true path of a line or object edge 01074410 / 13016218 Computer Graphics 58

Pixel Phasing (2) 01074410 / 13016218 Computer Graphics 59

Compensating for Line Intensity Differences The diagonal line is longer than the horizontal line by a factor of 22 By adjusting the intensity of each line according to its slope Horizontal and vertical lines would be displayed with the lowest intensity, while 45 lines would be given the highest intensity 01074410 / 13016218 Computer Graphics 60

Antialiasing Area Boundaries Smooth area boundaries by shifting pixel positions Adjust pixel intensity at a boundary according to the percent of the interior Adjustments, based on the percent of pixel area coverage 01074410 / 13016218 Computer Graphics 61

Antialiasing Area Boundaries (2) Supersampling methods Along the two scan lines, 3 of the subpixel areas are inside the boundary So we set the pixel intensity at 75% 01074410 / 13016218 Computer Graphics 62

Antialiasing Area Boundaries (3) Determining the percentage of pixel area within a fill region By Pitteway and Watkinson, based on the midpoint line algorithm 01074410 / 13016218 Computer Graphics 63

Overlap Area of the Pixel Parameter p y - y mid = p = [m(x k + 1) + b] (y k +0.5) + (1 m) Pixel at y k is nearer if p < 1 m, and at y k + 1 is nearer if p > 1 m The interior part of the pixel area = m x k + b y k + 0.5 By evaluating p, we also determine the percentage of area coverage for the current pixel 01074410 / 13016218 Computer Graphics 64

OpenGL Antialiasing Functions To activate the antialiasing routines glenable (primitivetype); where primitivetype is GL_POINT_SMOOTH, GL_LINE_SMOOTH, or GL_POLYGON_SMOOTH Color-blending operations glenable (GL _ BLEND); glblendfunc (GL _ SRC_ ALPHA, GL_ ONE_ MINUS_ SRC_ ALPHA); 01074410 / 13016218 Computer Graphics 65

End of Chapter 4 01074410 / 13016218 Computer Graphics 68