Download presentation
Presentation is loading. Please wait.
1
Computer Graphics chapter 1
Dr. Jehad Q. O. Alnihoud Phone: 3354
2
Books F.S. Hill, Computer Graphics Using OpenGL, Prentice-Hall (2001).
Mason Woo, OpenGL Programming Guide, Addison Wesley (2000). Hearn and Baker, Computer Graphics, Prentice-Hall (1997). RM
3
Books (Supplementary reference)
Foley, V. Dam, Feiner, Hughes, Computer Graphics Principles and Practice, 2/e, Addison Wesley, Edward Angel, Interactive Computer Graphics, Addison Wesley, 1997. Zhigang Xiang, Schaum’s Outlines: Computer Graphics, McGrawHill, 2001. Shreiner D, OpenGL Reference Manual, Addison-Wesley, 2000. RM
4
Graphics Applications
Art and Entertainment Animations Movies Commercials Special Effects RM
5
Graphics Applications
Image Processing Analysis, Reconstruction Medical Imaging Movies RM
6
Graphics Applications
Simulation Modeling and Analysis Virtual Environments RM
7
Graphics Applications
Scientific Visualization Data Representation and Plotting 3D Views RM
8
Graphics Applications
CAD/CAM Industrial Design Structural Design Surface Modeling RM
9
Graphics Software Packages
Early graphics libraries: GKS (Graphical Kernel System) PHIGS OpenGL (Silicon Graphics) Java2D (Sun Microsystems) Java3D (Sun Microsystems) VRML (Silicon Graphics) RM
10
Graphics: Main Components
Theory Analytical Geometry Vectors and Matrices Algorithms Eg: Line drawing, Filling etc. Implementation Programming (OpenGL) RM
11
Graphics Hardware Line Drawing Devices: Eg. Pen Plotters
Advantages: Perfect lines, Sharp Diagrams Disadvantages: Not suitable for filled regions. RM
12
Graphics Hardware Raster Devices: Create pictures by displaying dots
Eg: Video monitor, dot-matrix printer, laser printer, ink-jet printer, film recorder Advantages: Filled, shaded regions are easily displayed Disadvantages: Jaggies Pixel RM
13
Pixel Depth Pixel depth refers to the number of bits used to represent a pixel value. 1 bit/pixel: 2 Levels (Bi-level image) 1 2 bits/pixel: 4 Levels 1 1 1 1 RM
14
Pixel Depth 1 bit per pixel produce 2 levels (bi- level image). 2 bits per pixel produce 4 levels. 8 bits per pixel produce 256 levels. In general, if the pixel depth is n, then it is possible to have 2n levels. RM
15
Raster Display Most display used for computer graphics nowadays are raster displays. Image presented in display surface that contains certain number of pixels. Eg. 480 x 640 (r x c). Frame buffer is a region of memory sufficiently large to hold all the pixel values for display. RM
16
Frame Buffer System with 64 color (3 DACs): Monochrome Video display:
Each DAC uses 2 bits/pixel. Total color: 4 x 4 x 4 = 64 If the display surface is 1024 x 1280, then the memory required for frame buffer is MB Monochrome Video display: Only one DAC required. 6 planes of memory in frame buffer gives 26 = 64 level of gray. RM
17
Frame Buffer System with 24 bit color (3 DACs):
Each DAC uses 8 bits/pixel. (Total 24 bits/pixel) Total color: 28 x 28 x 28 = 224 If the display surface is 1024 x 1280, then the memory required for frame buffer is 3.75MB RM
18
Color Models: RGB Diagram
RGB Model is used for colored light sources RGB Model is additive Basis colors: R, G, B R: Red=[1, 0, 0] G: Green=[0, 1, 0] B: Blue=[0, 0, 1] C: Cyan=[0, 1, 1] M: Magenta=[1, 0, 1] Y:Yellow=[1, 1, 0] W:White=[1,1,1] K: Black=[0,0,0] RM
19
Color Models: RGB Cube Complementary Colors: Two colors that combine to form White. Eg. Red, Cyan. Gray Values: Every point on the primary diagonal has equal values for all the components. RM
20
Color Models: CMY Diagram
CMY Model is used for colored pigments CMY Model is subtractive Basis colors: C, M, Y C: Cyan=[1, 0, 0] M: Magenta=[0, 1, 0] Y: Yellow=[0, 0, 1] R: Red=[0, 1, 1] G: Green=[1, 0, 1] B: Blue=[1, 1, 0] W:White=[0,0,0] K: Black=[1,1,1] RM
21
Color Models: RGB <-> CMY
(r, g, b)RGB = (1,1,1) (c, m, y)CMY Light A red colored surface absorbs cyan from a white light RM
22
Color Models: HSV HexCone
23
Color Models: HSV H (Hue): 0 to 360 degrees 0: Red, 60: Yellow ….
S (Saturation): 0 to 1 0: Axis, 1: Boundary V (Value): 0 to 1 0: Vertex, 1: Base Examples: Eg. Yellow: [60, 1.0, 1.0] Black: [ -, -, 0.0] White: [-, 0.0, 1.0] RM
24
RGB Color Definition (OpenGL)
RM
25
Computer Graphics Chapter 2 Input Devices
26
Input Devices Logical Input Devices Physical Input Devices
Categorized based on functional characteristics. Each device transmits a particular kind of data. The different types of data are called input primitives. Physical Input Devices Categorized based on the physical machine. RM
27
Logical Input Devices Locator Devices
Input Primitive: Coordinate position (x,y) Examples: Mouse, Keyboard (Cursor-Position Keys), Tablet(Digitizer), Trackballs, Lightpens. Applications: Interactive drawing and editing, Graph digitizing. RM
28
Digitizer RM
29
Joystick and Trackball
RM
30
Logical Input Devices String Devices
Input Primitive: A string of characters Example: Keyboard Applications: Text input RM
31
Logical Input Devices Valuator
Input primitive: Scalar values (typically between 0 and 1). Examples: Control Dials, Sensing devices, Joysticks Applications: Input of graphics parameters, Graphics representation of analog values, Process simulation, Games. RM
32
Logical Input Devices Choice
Input primitive: A selection from a list of options. Examples: Mouse, Keyboard (Function Keys), Touch Panel etc Applications: Interactive menu selection, Program control. RM
33
Logical Input Devices Pick
Input primitive: Selection of a part of the screen. Examples: Mouse, Cursor Keys, Tablet. Applications: Interactive editing and positioning. RM
34
Physical Input Devices
Keyboard (input functions: String, Choice, Locator). Mouse (input functions: Locator, Pick, Choice). Joystick (input functions: Locator, Valuator). Knob (Valuator). Tablet (Locator, Pick). RM
35
3D Interaction Devices (Recent additions)
These devices are used in advanced rendering methods and virtual reality systems for providing information about three dimensional positions and motion.Few examples are 1. DATA GLOVES 2 SPACE BALLS RM
36
Space Ball, Data Glove RM
37
Event Driven Programming
· Mouse clicked. · Mouse dragged. · A key is pressed. · The window is resized. · The window is moved. · Register. · Define. Call-back Functions Event Event Queue RM
38
Mouse Interaction Mouse Event Mouse Motion Event
Event that occurs when the mouse button is pressed or released. Mouse Motion Event Event that occurs when the mouse is moved while one of the buttons is pressed. RM
39
Mouse Event Contains the following information:
Button: The mouse button that is pressed – left, middle, right. State: The state of the button – up, down. Position: The position of the mouse when the event occurs (x, y). RM
40
Mouse Event (OpenGL) RM
41
Mouse Motion Event Contains the following information:
Position: The current position of the mouse as the mouse is being dragged holding one of the buttons pressed. The events are continuously generated as the mouse button is pressed and dragged. RM
42
Mouse Motion Event (OpenGL)
RM
43
Keyboard Event Contains the following information:
key: The ASCII value of the key pressed. Position: The current position of the mouse when the key is pressed. RM
44
Keyboard Event (OpenGL)
RM
45
Window Events The Window Redraw Event occurs whenever the window needs to be redrawn. This happens when the window is first opened and when the window is exposed by moving another window off of it. The Window Reshape Event is generated when the window is resized with the mouse. RM
46
Window Events (OpenGL)
RM
47
CHAPTER 3 2D GRAPHICS ALGORITHMS
COMPUTER GRAPHICS CHAPTER 3 2D GRAPHICS ALGORITHMS
48
2D Graphics Algorithms Output Primitives Line Drawing Algorithms
DDA Algorithm Midpoint Algorithm Bersenhem’s Algorithm Circle Drawing Algorithms Midpoint Circle Algorithm Antialising Fill-Area Algorithms
49
Output Primitives
50
Output Primitives The basic objects out of which a graphics display is created are called. Describes the geometry of objects and – typically referred to as geometric primitives. Examples: point, line, text, filled region, images, quadric surfaces, spline curves Each of the output primitives has its own set of attributes.
51
Output Primitives Points Attributes: Size, Color. glPointSize(p);
glBegin(GL_POINTS); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x3, y3); glEnd()
52
Output Primitives Lines Attributes: Color, Thickness, Type
glLineWidth(p); glBegin(GL_LINES); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x3, y3); glVertex2d(x4, y4); glEnd()
53
Output Primitives Polylines (open)
A set of line segments joined end to end. Attributes: Color, Thickness, Type glLineWidth(p); glBegin(GL_LINE_STRIP); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x3, y3); glVertex2d(x4, y4); glEnd()
54
Output Primitives Polylines (closed)
A polyline with the last point connected to the first point . Attributes: Color, Thickness, Type Note: A closed polyline cannot be filled. glBegin(GL_LINE_LOOP); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x3, y3); glVertex2d(x4, y4); glEnd()
55
Output Primitives Polygons A set of line segments joined end to end.
Attributes: Fill color, Thickness, Fill pattern Note: Polygons can be filled. glBegin(GL_POLYGON); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x3, y3); glVertex2d(x4, y4); glEnd()
56
Output Primitives Text
Attributes: Font, Color, Size, Spacing, Orientation. Font: Type (Helvetica, Times, Courier etc.) Size (10 pt, 14 pt etc.) Style (Bold, Italic, Underlined)
57
Output Primitives Images
Attributes: Image Size, Image Type, Color Depth. Image Type: Binary (only two levels) Monochrome Color. Color Depth: Number of bits used to represent color.
58
Output Primitives Output Primitive Attributes Point Size Color Line
Thickness (1pt, 2pt …) Type (Dashed, Dotted, Solid) Text Font (Arial, Courier, Times Roman…) Size (12pt, 16pt ..) Spacing Orientation (Slant angle) Style (Bold, Underlined, Double lined) Filled Region Fill Pattern Fill Type (Solid Fill, Gradient Fill) Fill Color Images Color Depth (Number of bits/pixel)
59
Line Drawing Algorithms
60
Line Drawing Line drawing is fundamental to computer graphics.
We must have fast and efficient line drawing functions. Rasterization Problem: Given only the two end points, how to compute the intermediate pixels, so that the set of pixels closely approximate the ideal line.
61
Line Drawing - Analytical Method
x y=mx+c ax bx A(ax,ay) B(bx,by)
62
Line Drawing - Analytical Method
double m = (double)(by-ay)/(bx-ax); double c = ay - m*ax; double y; int iy; for (int x=ax ; x <=bx ; x++) { y = m*x + c; iy = round(y); setPixel (x, iy); } Directly based on the analytical equation of a line. Involves floating point multiplication and addition Requires round-off function.
63
Incremental Algorithms
I have got a pixel on the line (Current Pixel). How do I get the next pixel on the line? Compute one point based on the previous point: (x0, y0)…….…………..(xk, yk) (xk+1, yk+1) ……. Next pixel on next row (when slope is large) Next pixel on next column (when slope is small)
64
Incrementing along x xk+1 = xk+1 Current Pixel (xk, yk) (6,3)
To find (xk+1, yk+!): xk+1 = xk+1 yk+1 = ? (5,2) (6,2) (6,1) Assumes that the next pixel to be set is on the next column of pixels (Incrementing the value of x !) Not valid if slope of the line is large.
65
Line Drawing - DDA Digital Differential Analyzer Algorithm is an incremental algorithm. Assumption: Slope is less than 1 (Increment along x). Current Pixel = (xk, yk). (xk, yk) lies on the given line. yk = m.xk + c Next pixel is on next column. xk+1 = xk+1 Next point (xk+1, yk+1) on the line yk+1 = m.xk+1 + c = m (xk+1) +c = yk + m Given a point (xk, yk) on a line, the next point is given by xk+1 = xk+1 yk+1 = yk + m
66
Line Drawing - DDA double m = (double) (by-ay)/(bx-ax); double y = ay;
int iy; for (int x=ax ; x <=bx ; x++) { iy = round(y); setPixel (x, iy); y+ = m; } Does not involve any floating point multiplication. Involves floating point addition. Requires round-off function
67
Midpoint Algorithm xk+1 = xk+1 yk+1 = Either yk or yk+1
Midpoint algorithm is an incremental algorithm Assumption: Slope < 1 Current Pixel xk+1 = xk+1 yk+1 = Either yk or yk+1
68
Midpoint Algorithm - Notations
Candidate Pixels Current Pixel ( xk, yk) Midpoint Line Coordinates of Midpoint = ( xk+1, yk+(1/2) ) ( xk+1, yk) ( xk+1, yk+1)
69
Midpoint Algorithm: Choice of the next pixel
Midpoint Below Line Midpoint Above Line If the midpoint is below the line, then the next pixel is (xk+1, yk+1). If the midpoint is above the line, then the next pixel is (xk+1, yk).
70
Equation of a line revisited.
Equation of the line: Let w = bx ax, and h = by ay. Then, h (x ax) w (y ay) = 0. (h, w , ax , ay are all integers). In other words, every point (x, y) on the line satisfies the equation F(x, y) =0, where F(x, y) = h (x ax) w (y ay). A(ax,ay) B(bx,by)
71
Midpoint Algorithm: Regions below and above the line.
F (x,y) > 0 (for any point below line) F(x,y) < 0 (for any point above line) F(x,y) = 0
72
Midpoint Algorithm Decision Criteria
Midpoint below line F(MP) < 0 Midpoint above line F(MP) > 0
73
Midpoint Algorithm Decision Criteria
Decision Parameter F(MP) = F(xk+1, yk+ ½) = Fk (Notation) If Fk < 0 : The midpoint is above the line. So the next pixel is (xk+1, yk). If Fk 0 : The midpoint is below or on the line. So the next pixel is (xk+1, yk+1).
74
Midpoint Algorithm – Story so far.
Midpoint Above Line Next pixel = (xk+1, yk) Fk < 0 yk+1 = yk Midpoint Below Line Fk > 0 yk+1 = yk+1 Next pixel = (xk+1, yk+1)
75
Midpoint Algorithm Update Equation
Fk = F(xk+1, yk+ ½) = h (xk+1 ax) w (yk+½ ay) Update Equation But, Fk+1 = Fk + h w (yk+1 yk). (Refer notes) So, Fk< 0 : yk+1 = yk. Hence, Fk+1 = Fk + h . Fk 0 : yk+1 = yk+1. Hence, Fk+1 = Fk + h w. F0 = h w/2.
76
Midpoint Algorithm int h = by-ay; int w = bx-ax; float F=h-w/2;
int x=ax, y=ay; for (x=ax; x<=bx; x++){ setPixel(x, y); if(F < 0) F+ = h; else{ F+ = h-w; y++; }
77
Bresenham’s Algorithm
int h = by-ay; int w = bx-ax; int F=2*h-w; int x=ax, y=ay; for (x=ax; x<=bx; x++){ setPixel(x, y); if(F < 0) F+ = 2*h; else{ F+ = 2*(h-w); y++; }
78
Circle Drawing Algorithms
79
Midpoint Circle Drawing Algorithm
To determine the closest pixel position to the specified circle path at each step. For given radius r and screen center position (xc, yc), calculate pixel positions around a circle path centered at the coodinate origin (0,0). Then, move each calculated position (x, y) to its proper screen position by adding xc to x and yc to y. Along the circle section from x=0 to x=y in the first quadrant, the gradient varies from 0 to -1.
80
Midpoint Circle Drawing Algorithm
8 segments of octants for a circle:
81
Midpoint Circle Drawing Algorithm
Circle function: fcircle (x,y) = x2 + y2 –r2 > 0, (x,y) outside the circle < 0, (x,y) inside the circle = 0, (x,y) is on the circle boundary { fcircle (x,y) =
82
Midpoint Circle Drawing Algorithm
yk yk-1 midpoint yk yk-1 midpoint Next pixel = (xk+1, yk) Fk < 0 yk+1 = yk Next pixel = (xk+1, yk-1) Fk >= 0 yk+1 = yk - 1
83
Midpoint Circle Drawing Algorithm
We know xk+1 = xk+1, Fk = F(xk+1, yk- ½) Fk = (xk +1)2 + (yk - ½)2 - r (1) Fk+1 = F(xk+1, yk- ½) Fk+1 = (xk +2)2 + (yk+1 - ½)2 - r (2) (2) – (1) Fk+1 = Fk + 2(xk+1) + (y2k+1 – y2k) - (yk+1 – yk) + 1 If Fk < 0, Fk+1 = Fk + 2xk+1+1 If Fk >= 0, Fk+1 = Fk + 2xk+1+1 – 2yk+1
84
Midpoint Circle Drawing Algorithm
For the initial point, (x0 , y0) = (0, r) f0 = fcircle (1, r-½ ) = 1 + (r-½ )2 – r2 = 5 – r 4 ≈ 1 – r
85
Midpoint Circle Drawing Algorithm
Example: Given a circle radius = 10, determine the circle octant in the first quadrant from x=0 to x=y. Solution: f0 = 5 – r 4 = 5 – 10 = -8.75 ≈ –9
86
Midpoint Circle Drawing Algorithm
Initial (x0, y0) = (1,10) Decision parameters are: 2x0 = 2, 2y0 = 20 k Fk x y 2xk+1 2yk+1 -9 1 10 2 20 -9+2+1=-6 4 -6+4+1=-1 3 6 -1+6+1=6 9 8 18 =-3 5 =8 12 16 =5 7 14
87
Midpoint Circle Drawing Algorithm
void circleMidpoint (int xCenter, int yCenter, int radius) { int x = 0; Int y = radius; int f = 1 – radius; circlePlotPoints(xCenter, yCenter, x, y); while (x < y) { x++; if (f < 0) f += 2*x+1; else { y--; f += 2*(x-y)+1; } }
88
Midpoint Circle Drawing Algorithm
void circlePlotPoints (int xCenter, int yCenter, int x, int y) { setPixel (xCenter + x, yCenter + y); setPixel (xCenter – x, yCenter + y); setPixel (xCenter + x, yCenter – y); setPixel (xCenter – x, yCenter – y); setPixel (xCenter + y, yCenter + x); setPixel (xCenter – y, yCenter + x); setPixel (xCenter + y, yCenter – x); setPixel (xCenter – y, yCenter – x); }
89
Antialiasing
90
Antialiasing Antialiasing is a technique used to diminish the jagged edges of an image or a line, so that the line appears to be smoother; by changing the pixels around the edges to intermediate colors or gray scales. Eg. Antialiasing disabled: Eg. Antialiasing enabled:
91
Antialiasing (OpenGL)
Antialiasing disabled Antialiasing enabled Setting antialiasing option for lines: glEnable (GL_LINE_SMOOTH);
92
Fill Area Algorithms
93
Fill Area Algorithms Fill-Area algorithms are used to fill the interior of a polygonal shape. Many algorithms perform fill operations by first identifying the interior points, given the polygon boundary.
94
Basic Filling Algorithm
The basic filling algorithm is commonly used in interactive graphics packages, where the user specifies an interior point of the region to be filled. 4-connected pixels
95
Basic Filling Algorithm
[1] Set the user specified point. [2] Store the four neighboring pixels in a stack. [3] Remove a pixel from the stack. [4] If the pixel is not set, Set the pixel Push its four neighboring pixels into the stack [5] Go to step 3 [6] Repeat till the stack is empty.
96
Basic Filling Algorithm (Code)
void fill(int x, int y) { if(getPixel(x,y)==0){ setPixel(x,y); fill(x+1,y); fill(x-1,y); fill(x,y+1); fill(x,y-1); }
97
Basic Filling Algorithm
Requires an interior point. Involves considerable amount of stack operations. The boundary has to be closed. Not suitable for self-intersecting polygons
98
Types of Basic Filling Algorithms
Boundary Fill Algorithm For filling a region with a single boundary color. Condition for setting pixels: Color is not the same as border color Color is not the same as fill color Flood Fill Algorithm For filling a region with multiple boundary colors. Color is same as the old interior color
99
Boundary Fill Algorithm (Code)
void boundaryFill(int x, int y, int fillColor, int borderColor) { getPixel(x, y, color); if ((color != borderColor) && (color != fillColor)) { setPixel(x,y); boundaryFill(x+1,y,fillColor,borderColor); boundaryFill(x-1,y,fillColor,borderColor); boundaryFill(x,y+1,fillColor,borderColor); boundaryFill(x,y-1,fillColor,borderColor); }
100
Flood Fill Algorithm (Code)
void floodFill(int x, int y, int fillColor, int oldColor) { getPixel(x, y, color); if (color != oldColor) setPixel(x,y); floodFill(x+1, y, fillColor, oldColor); floodFill(x-1, y, fillColor, oldColor); floodFill(x, y+1, fillColor, oldColor); floodFill(x, y-1, fillColor, oldColor); }
101
Filling Polygons (OpenGL)
Enabling polygon fill (Default): glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); Disabling polygon fill: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
102
Chapter 4 2D Viewing Algorithms
Computer Graphics Chapter 4 2D Viewing Algorithms
103
Coordinate Systems y v x u Device Coordinates: World Coordinates:
(u,v) (x, y) x u Device Coordinates: Device dependent Limits Positive Integer values World Coordinates: User-Defined Limits Floating point values RM
104
Window: A rectangular region in World Coordinate System.
Viewport: A rectangular region in Device Coordinate System. (0,300) (0,0) (360,0) RM
105
Window to Viewport Transformation
We denote the boundaries of the world window by four real values xmin, ymin, xmax, ymax denoting its left, bottom, right, top margins respectively. Similary the boundaries of the viewport on the screen are defined by four integer values umin, vmin, umax, vmax. When a graphics display is generated using arbitrary coordinates on the world window, the important problem encountered in viewing this display on the actual viewport on the screen is to have a function which maps every point (x,y) on the window to a corresponding point (u,v) on the viewport. The following window to viewport transformation achieves this relationship. RM
106
Window to Viewport Transformation
(xmax, ymax) (x, y) (umax, vmax) (u, v) (xmin,ymin) (umin, vmin) (x, y) (u, v) RM
107
Window to Viewport Transformation
u = c1 x + c2 v = d1 y + d2 RM
108
Window to Viewport Transformation
400 0.2 100 0.1 -0.05 +0.05 250 550 u = x + 400 v = y 200 RM
109
Aspect Ratio Aspect Ratio = Width/Height.
Aspect ratio of a world window = (xmax-xmin) / (ymax-ymin). Aspect ratio of the viewport = (umax-umin) / (vmax-vmin). The transformation from the window to viewport is said to preserve the aspect ratio, if both the above quantities are same. In such a case, we have c1 = d1. When this condition is satisfied, the mapping from the window to the viewport is distortion-free. RM
110
Window to Viewport Transformation
For distortion-free mapping from the window to the viewport, we must have c1 = d1 (in magnitude) 400 0.2 100 0.1 -0.05 +0.05 250 350 u = x + 300 v = y 200 RM
111
W-V Transform (OpenGL)
112
Line Clipping A line is required to be clipped against a rectangular clipping window such that the portion of the line that falls outside the window is not displayed. There are many possible arrangements of a segment with respect to the window. We therefore need an organized approach to identify the correct situation and to compute the new end points of each clipped segment. Efficiency is important because a typical picture contains thousands of line segments, each of which must be clipped against a window. RM
113
Line Clipping Window Clipping Window RM
114
Cohen-Sutherland Algorithm
A rapid divide-and-conquer approach to the line clipping Clipping window Trivial Accept: When both end points are inside the window, and therefore the line is completely visible. Trivial Reject: When both end points are outside the window and on the same side of the window. Then the line is completely outside, and hence can be rejected. RM
115
Region Codes A point is assigned a unique region code depending on the location of the point with respect to the window. A B R L 1001 1000 1010 0000 0001 0010 Clipping window 0101 0100 0110 RM
116
Region Codes Trivial Accept 0000 0000 r1 == 0000 and r2 == 0000
(r1 OR r2) == (OR: Bitwise) RM
117
Region Codes Trivial Reject 1010 0010
r1 and r2 have a common bit set to 1 (r1 AND r2) (AND: Bitwise) RM
118
Region Codes “Other Cases” 1001 1010 0000 0100 RM
119
Region Codes “Other Cases”
i. The point that lies outside the window is considered. (This is the point whose region code is non-zero). ii. For the above point, an edge outside which the point lies is identified. (If a particular bit is non-zero, the corresponding edge of the window is considered). iii. The intersection of the line with the edge is computed. The initial point in (i) is now replaced by the new intersection point. Its region code is computed. iv. The conditions for the “trivial accept” or “trivial reject” or “other case” is again checked for the new line segment. RM
120
Region Codes 1010 0000 Trivial Accept 0000 RM
121
Computing Intersection Point (Eg.)
Q A P x=xmin The equation of the line PQ is The intersection point A lies on the left edge and therefore its x-coordinate is x = xmin. To get the y-coordinate of A, we substitute for x in the above equation of PQ: y = RM
122
Computing Intersection Point (Eg.)
Q A P x=xmin Now P is replaced by the point A (effectively discarding the segment PA), and the whole process of checking is repeated for the segment AQ. Now both A, Q will have region codes 0000, and hence will satisfy the condition “trivial accept”. RM
123
Line Clipping (OpenGL)
RM
124
Chapter 5 Vector Based Algorithms
Computer Graphics Chapter 5 Vector Based Algorithms
125
2D Coordinate Systems RM
126
3D Coordinate Systems Y Y Z X Z X Right-handed System
Left-handed System RM
127
3D Coordinate Systems Right-handed System Left-handed System RM
128
Points and Vectors Y Y v = (x,y) (x,y) (x,y) X X
A point denotes a position in space. A vector is a directed line segment, having both magnitude and direction. RM
129
Addition and Subtraction of Vectors
Two vectors v1, v2 can be added to produce the diagonal vector v1+v2 according to the parallelogram rule. The result of vector subtraction produces v1v2 which is a vector directed from v2 to v1 . RM
130
Linear Combination of Vectors
A linear combination of vectors v1, v2 is given by v = a v1+ b v2, where a,b are constants. A linear combination of vectors v1, v2 always lies in the plane containing the vectors v1, v2. Z X Y v1 v2 v = a v1+ b v2 RM
131
Affine Combination of Vectors
An affine combination of vectors v1, v2 is given by v = a v1+ b v2, where a,b are constants, and a+b = 1. In particular, v = (1t) v1+ t v2 is an affine combination of vectors. Z X Y v = (1-t)v1+ t v2 v1 v2 RM
132
Linear Interpolation of Vectors
The affine combination v = (1t) v1+ t v2 performs a linear interpolation between vectors v1 and v2 , if 0 t 1. Z X Y v = (1-t)v1+ t v2 v1 v2 RM
133
Linear Interpolation of Vectors
Example: A color (r,g,b) can be treated as a vector. If C1 = (r1, g1, b1) and C2 = (r2, g2, b2) are two colors then, a linear interpolation between the two colors is given by C = (1t) C1+ t C2 , t 1. C1 C = (1t) C1+ t C2 C2 RM
134
Unit Vector The magnitude of a vector v is denoted by |v|.
If v=(x,y,z), then |v|= v/|v| is a unit vector. RM
135
Vector Dot Product The dot-product of two vectors
v1 =(x1, y1, z1) and v2 =(x2, y2, z2) is v1.v2 = x1 x2 + y1 y2 + z1 z2. The cosine of the angle between two vectors v1, v2 is computed as follows: cos = (v1.v2) / (|v1| |v2|). In particular, when the vectors are orthogonal ( = 90 deg), then v1.v2 = 0 RM
136
Vector Cross Product The cross-product of two vectors
v1 =(x1, y1, z1) and v2 =(x2, y2, z2) is v1 x v2 = Also, RM
137
Vector Cross Product The vector v1 v2 is orthogonal to both the vectors v1, and v2 . The three vectors v1, v2, v1 v2 form a right-handed system. (Note that v1 and v2 are not necessarily orthogonal. Hence the right-handed system is not mutually orthogonal.) RM
138
Planes Any three non-collinear points P1, P2, P3 will define a unique plane. Consider the vectors v1 = P2P1 , and v2 = P3P1. Both these vectors lie on the plane, and hence the vector n = v1 v2 is normal to the plane. RM
139
Chapter 6 2D Transformations
Computer Graphics Chapter 6 2D Transformations
140
Transformation Transform every point on an object according to certain rule. Q (x’, y’) P (x,y) T Initial Object Transformed Object x x’ y y’ The point Q is the image of P under the transformation T. RM
141
Translation (55,60) (20,35) (45,30) (65,30) (10,5) (30,5)
The vector (tx, ty) is called the offset vector. RM
142
Translation (OpenGL) RM
143
Rotation About the Origin
y (x’,y’) (x’,y’) (x,y) (x,y) q o x The above 2D rotation is actually a rotation about the z-axis (0,0,1) by an angle . RM
144
Rotation About the Origin
RM
145
Rotation About a Pivot Point
(x’,y’) (x,y) (xp , yp) Pivot Point Pivot point is the point of rotation Pivot point need not necessarily be on the object RM
146
Rotation About a Pivot Point
STEP-1: Translate the pivot point to the origin (x,y) (x1, y1) (xp , yp) RM
147
Rotation About a Pivot Point
STEP-2: Rotate about the origin (x2, y2) (x1, y1) RM
148
Rotation About a Pivot Point
STEP-3: Translate the pivot point to original position (x’, y’) (x2, y2) (xp, yp) RM
149
Rotation About a Pivot Point
RM
150
Scaling About the Origin
(x’,y’) (x,y) (x,y) (x’,y’) Uniform Non-Uniform The parameters sx, sy are called scale factors. RM
151
Scaling About the Origin
RM
152
Scaling About a Fixed Point
Translate the fixed point to origin Scale with respect to the origin Translate the fixed point to its original position. (x,y) (x’,y’) (xf , yf ) RM
153
Reflections y x = x x x = x y = y y = y Initial
Reflection about y x = x Initial Object x Reflection about origin x = x y = y Reflection about x y = y RM
154
Reflections RM
155
Shear A shear transformation in the x-direction (along x)
shifts the points in the x-direction proportional to the y-coordinate. The y-coordinate of each point is unaffected. RM
156
Matrix Representations
Translation Rotation [Origin] Scaling [Origin] RM
157
Matrix Representations
Reflection about x Reflection about y Reflection about the Origin RM
158
Matrix Representations
Shear along x Shear along y RM
159
Homogeneous Coordinates
To obtain square matrices an additional row was added to the matrix and an additional coordinate, the w-coordinate, was added to the vector for a point. In this way a point in 2D space is expressed in three-dimensional homogeneous coordinates. This technique of representing a point in a space whose dimension is one greater than that of the point is called homogeneous representation. It provides a consistent, uniform way of handling affine transformations. RM
160
Homogeneous Coordinates
If we use homogeneous coordinates, the geometric transformations given above can be represented using only a matrix pre-multiplication. A composite transformation can then be represented by a product of the corresponding matrices. Cartesian Homogeneous Examples: (5, 8) (15, 24, 3) (x, y) (x, y, 1) RM
161
Homogeneous Coordinates
Basic Transformations Translation P’=TP Rotation [O] P’=RP Scaling [O] P’=SP RM
162
Inverse of Transformations
If, then, Examples: RM
163
Transformation Matrices
Additional Properties: RM
164
Order of Transformations
Composite Transformations Transformation T followed by Transformation Q followed by Transformation R: Example: (Scaling with respect to a fixed point) Order of Transformations RM
165
Order of Transformations
In composite transformations, the order of transformations is very important. Rotation followed by Translation: Translation followed by Rotation: RM
166
Order of Transformations (OpenGL)
OpenGL postmultiplies the current matrix with the new transformation matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(tx, ty, 0); glRotatef(theta, 0, 0, 1.0); glVertex2f(x,y); Current Matrix [ I ] [ T ] [ T ] [ R ] [ T ] [ R ] P Rotation followed by Translation !! RM
167
General Properties Preserved Attributes RM
168
Affine Transformation
A general invertible, linear, transformation. Transformation Matrix: RM
169
Affine Transformation: Properties
Product of affine transformations is affine. Affine transformations preserve linearity of segments. Affine transformations preserve parallelism between lines. Affine transformations are invertible. RM
170
Chapter 7 3D Object Modeling
Computer Graphics Chapter 7 3D Object Modeling
171
3D Object Representation
A surface can be analytically generated using its function involving the coordinates. An object can be represented in terms of its vertices, edges and polygons. (Wire Frame, Polygonal Mesh etc.) Curves and surfaces can also be designed using splines by specifying a set of few control points. y = f(x,z) x y z
172
Solid Modeling - Polyhedron
A polyhedron is a connected mesh of simple planar polygons that encloses a finite amount of space. A polyhedron is a special case of a polygon mesh that satisfies the following properties: Every edge is shared by exactly two faces. At least three edges meet at each vertex. Faces do not interpenetrate. Faces at most touch along a common edge. Euler’s formula : If F, E, V represent the number of faces, vertices and edges of a polyhedron, then V + F E = 2.
173
3D Object Representation
The data for polygonal meshes can be represented in two ways. Method 1: Vertex List Normal List Face List (Polygon List) Method 2: Edge List
174
Vertices and Faces - E.g. Cube
2 5 4 3 1 1 5 6 7 2 3 4 Vertex Index Face Index
175
Data representation using vertex, face and normal lists:
176
Data representation using vertex, face and edge lists:
177
Normal Vectors (OpenGL)
178
Regular Polyhedra (Platonic Solids)
If all the faces of a polyhedron are identical, and each is a regular polygon, then the object is called a platonic solid. Only five such objects exist.
179
Wire-Frame Models If the object is defined only by a set of nodes (vertices), and a set of lines connecting the nodes, then the resulting object representation is called a wire-frame model. Very suitable for engineering applications. Simplest 3D Model - easy to construct. Easy to clip and manipulate. Not suitable for building realistic models.
180
Wire Frame Models - OpenGL
181
Wire Frame Model - The Teapot
182
Polygonal Mesh Three-dimensional surfaces and solids can be approximated by a set of polygonal and line elements. Such surfaces are called polygonal meshes. The set of polygons or faces, together form the “skin” of the object. This method can be used to represent a broad class of solids/surfaces in graphics. A polygonal mesh can be rendered using hidden surface removal algorithms.
183
Polygonal Mesh - Example
184
Solid Modeling Polygonal meshes can be used in solid modeling.
An object is considered solid if the polygons fit together to enclose a space. In solid models, it is necessary to incorporate directional information on each face by using the normal vector to the plane of the face, and it is used in the shading process.
185
Solid Modeling - Example
186
Solid Modeling - OpenGL
187
Surface Modeling Y y = f(x, z) X Z
Many surfaces can be represented by an explicit function of two independent variables, such as y = f(x, z).
188
Surface Modeling - Example
189
Sweep Representations
Sweep representations are useful for both surface modeling and solid modeling. A large class of shapes (both surfaces and solid models) can be formed by sweeping or extruding a 2D shape through space. Sweep representations are useful for constructing 3-D objects that posses translational or rotational symmetries.
190
Extruded Shapes - Examples
A polyhedron obtained by sweeping (extruding) a polygon along a straight line is called a prism.
191
Surface of Revolution A surface of revolution is obtained by revolving a curve (known as the base curve or profile curve) about an axis. In other words, a surface of revolution is generated by a rotational sweep of a 2D curve. The symmetry of the surface of revolution makes it a very useful object in presentation graphics.
192
Surface of Revolution Y y = f(x) y = f(r) y y x r X (x, z) Z
193
Surface of Revolution The three-dimensional surface obtained by revolving the curve y = f(x) about the y-axis is obtained by replacing x with sqrt(x*x + z*z). The surface of revolution is thus given by
194
Surface of Revolution
195
Quad trees Quad trees are generated by successively dividing a 2-D region(usually a square) into quadrants. Each node in the quadtree has 4 data elements, one for each of the quadrants in the region. If all the pixels within a quadrant have the same color (a homogeneous quadrant), the corresponding data element in the node stores that color. For a heterogeneous region of space, the successive divisions into quadrants continues until all quadrants are homogeneous.
196
Octrees An octree encoding scheme divide regions of 3-D space(usually a cube) in to octants and stores 8 data elements in each node of the tree. Individual elements of a 3-D space are called volume elements or voxels. When all voxels in an octant are of the same type, this type value is stored in the corresponding data element of the node. Any heterogeneous octant is subdivided into octants and the corresponding data element in the node points to the next node in the octree.
197
Octrees
198
Bezier Curves The Bezier curve only approximates the control points
and doesn’t actually pass through all of them.
199
Bezier Curves Inputs: n control points (xi, yi), i = 0, 1,2, …n-1 m = n1
200
Bezier Curves Inputs: n control points (xi, yi), i = 0, 1,2, …m
201
Properties of Bezier Curve
Bezier curve is a polynomial of degree one less than the number of control points p0 p2 p1 p0 p2 p1 p3 Quadratic Curve Cubic Curve
202
Properties of Bezier Curve (cont.)
Bezier curve always passes through the first and last points; i.e. and ,
203
Properties of Bezier Curve (cont)
The slop at the beginning of the curve is along the line joining the first two control points, and the slope at the end of the curve is along the line joining the last two points. p0 p2 p1 p0 p2 p1
204
Properties of Bezier Curve (cont)
Bezier blending functions are all positive and the sum is always 1. This means that the curve is the weighted sum of the control points.
205
Design Technique using Bezier Curves:
A closed Bezier curve can be generated by specifying the first and last control points at the same location p3 p0=p5 p1 p2 p4
206
Design Technique (Cont)
A Bezier curve can be made to pass closer to a given coordinate position by assigning multiple control points to that position. p0 p1 = p2 p3 p4
207
Bezier curve can be form by piecing of several Bezier section with lower degree.
p2= p’0 p’2 p’3 p’1
208
Bezier Surfaces (Not Important!)
209
Bezier Patch A set of 16 control points The Bezier Patch
210
Bezier Patch Utah Teapot Defined Using Control Points
211
Bezier Patch Utah Teapot Generated Using Bezier Patches
212
Chapter 8 3D Transformations
Computer Graphics Chapter 8 3D Transformations
213
Transformation in 3D space
Y Transformed Object (x’,y’,z’) X Z (x,y,z) Initial Object RM
214
3D Homogeneous Coordinates
Cartesian Homogeneous RM
215
Translation Y X Z Offset Vector = (tx, ty, tz) RM
216
Scaling About the Origin
Y X Z Scale Factors = (sx, sy, sz) RM
217
Rotation About Z-axis y y (x’,y’,z’) (x,y,z) q x x z RM
218
Rotation About X-axis z y (x’,y’,z’) (x,y,z) x q y z RM
219
Rotation About Y-axis x (x’,y’,z’) y (x,y,z) q x z z RM
220
Rotation Matrices RM
221
Reflection About XY Plane
Z RM
222
Reflections Reflection about xy plane: Reflection about yz plane:
Reflection about zx plane: RM
223
3D Affine Transformations
A general invertible, linear, transformation RM
224
Affine Transforms - Properties
Product of affine transformations is affine. Affine transformations preserve linearity of segments. Affine transformations preserve parallelism between lines. Affine transformations are invertible. RM
225
3D Transformations - OpenGL
226
3D Viewing RM
227
Planar Projections RM
228
Projection Geometry Plane of Projection Object Point P Projector P’
Center of Projection P (3D) P’ (2D) RM
229
Parallel and Perspective
Parallel Projections: The center of projection is at infinity. The projectors are parallel to each other. Perspective Projections: The center of projection is a finite point. The projectors intersect at the center of projection. RM
230
Orthographic Projection
The lines of projection are parallel, and at the same time orthogonal to the plane of projection. RM
231
Orthographic Projection
The lines of projection are parallel, and at the same time orthogonal to the plane of projection. RM
232
Orthographic Projection
Projection along z axis: Transformation: x’ = x y’ = y z-coordinate information is lost! Orthographic Projection Matrix: RM
233
Oblique Projection The lines of projection are parallel, but not orthogonal to the plane of projection. RM
234
Oblique Projection Transformation: x’ = x+k1z y’ = y+k2z
The z-coordinate value of the object point, leads to a shift of x, y coordinates of the projected point, proportional to z. Oblique Projection Matrix: RM
235
Perspective Projection
The projectors intersect at a Center of Projection C. RM
236
Perspective Projection
For convenience of deriving projection equations, we assume that the center of projection is at the origin. The object and the plane of projection are now on the negative z side. The distance D then refers to the z-coordinate of the object point (towards –z). The plane of projection has the equation z = N. RM
237
Perspective Projection
Perspective Projection Matrix: RM
238
Perspective Projection
The z-coordinate value of the object point leads to proportional scaling along x, y directions. Projections of objects located closer to the center of projection O, appear to be larger in size compared to objects that are farther away from O. RM
239
Perspective Transformation
a, b are arbitrary constants. The last term z’ is referred to as the pseudo-depth. Perspective Transformation Matrix: RM
240
Projections: Properties
Projections map points from one space to another coordinate space of lower dimension, and hence involves loss of information. Projections are not invertible. All projection matrices are singular. All points on a projector map to the same point on the plane of projection. RM
241
View Volumes A view volume refers to a region of interest in three-dimensional space which will be used to generate the display on the viewport. All points outside the view volume will not be displayed. The shape of the view volume depends on the projection used, and the limits specified by the user. RM
242
View Volume - Orthographic Projn
glOrtho(left, right, bottom, top, near, far); RM
243
View Volume - Orthographic Projn
glOrtho(left, right, bottom, top, near, far); RM
244
View Volume - Perspective Projn
glFrustum(left, right, bottom, top, near, far); RM
245
View Volume - Perspective Projn
gluPerspective(fovy, aspect, near, far); RM
246
Canonical View Volumes
The 3D object model is not actually clipped inside the projection view volume. The view volume is instead mapped to a canonical view volume (CVV) which is a cube that extends from 1 to +1 in each dimension, having center at the origin. The dimensions of the CVV facilitates a fast and efficient clipping. RM
247
Mapping to CVV Orthographic: Perspective: RM
248
RM
249
Computer Graphics Chapter 9 Rendering
250
Rendering Three dimensional object rendering is the set of collective processes which make the object model appear more realistic on the display screen. These processes include The elimination of surfaces (polygonal segments) on the object that are not visible with respect to the user’s view direction. Incorporating shading and shadowing effects. RM
251
Computing Surface Normal
V1 = P2P1 = (x2x1, y2y1, z2z1). V2 = P3P1 = (x3x1, y3y1, z3z1). N = V1 V2. Surface Normal: RM
252
Components of Surface Normal
Nx = (y2y1) (z3z1) (y3y1) (z2z1) Ny = (z2z1) (x3x1) (z3z1) (x2x1) Nz = (x2x1) (y3y1) (x3x1) (y2y1) OR Nx = y1(z2-z3)+ y2(z3-z1)+ y3(z1-z2) Ny = z1(x2-x3)+ z2(x3-x1)+ z3(x1-x2) Nz = x1(y2-y3)+ x2(y3-y1)+ x3(y1-y2) RM
253
Back-Face Culling Nz < 0 The polygon is hidden RM
254
Back-Face Culling - Limitations
Requires specific ordering of the vertices in the polygon table to determine the outward normal direction. The algorithm will work only with convex objects. A polygon is either completely displayed, or totally eliminated from the display. RM
255
Back-Face Culling (General Case)
V.N > 0 The polygon is hidden RM
256
Back-Face Culling (Example)
RM
257
Back-Face Culling (OpenGL)
RM
258
Painter’s Algorithm RM
259
Painters Algorithm Basic Steps:
Sort polygons in the ascending order of z-coordinates Fill polygons in the sorted order. RM
260
Painters Algorithm - Limitations
Requires sorting of polygons. All polygons must be necessarily filled. May lead to erroneous images if a failure condition (see below) occurs. RM
261
Painters Algorithm Failure Conditions (1)
Polygons with depth and region overlap. (1) Z Polygons having both depth-overlap and region overlap may require re-sequencing of the polygons in the sorted list. (2) RM
262
Painters Algorithm Failure Conditions (2)
Polygons with cyclic overlap. RM
263
Painter’s Algorithm Illustration of failure conditions Correct Wrong
RM
264
Depth-Buffer Algorithm
Z Minimum Depth Value Color Value RM Frame Buffer Depth Buffer
265
Depth-Buffer Algorithm
For each pixel (i, j), a line passing through the pixel and the viewer is considered, and the depths of the polygons on this line are computed. The value d(i, j) in the depth buffer contains the pseudo-depth of the closest polygon encountered at pixel (i, j). The value p(i, j) in the frame buffer (the color of the pixel) is the color of the closest polygon. RM
266
Depth-Buffer Algorithm
Limitations: The algorithm requires a large amount of additional memory to store the pseudo depth at each pixel value. Since the analysis is based on a point by point test, the algorithm is time consuming. RM
267
Shading Models A shading model dictates how light is scattered or reflected from a surface. A surface is shaded by adjusting the color intensity value of each polygon according to the shading algorithm. Main components: Light source vector, surface normal vector, viewer direction. Material characteristics of the surface The illumination model. RM
268
Shading Models Vectors
RM
269
Shading Models Surface Properties (1)
abs (Coeff. of absorption): Specifies how much of the incident light is absorbed. If all of the incident light is absorbed, the object appears black. spec (Coeff. of specular reflection) Specifies how much of the incident light is specularly reflected in one direction. For a highly reflective surface such as a mirror, the value is close to 1.0 RM
270
Shading Models Surface Properties (2)
diff (Coeff. of diffuse reflection): Diffuse scattering occurs when the incident light is re-radiated uniformly in all directions. For a rough non-reflective surface, the value is close to 1.0. amb (Coeff. of ambient reflection): Specifies how much of the ambient light is reflected by the surface. Often this is same as the diffuse reflection coefficient diff. abs + spec +diff = 1.0 RM
271
Surface Properties I If I is the incident light intensity,
then I abs is absorbed by the surface. I spec is specularly reflected. I diff is diffusely reflected. RM
272
Illumination Models Point Source Ambient Light Ambient Light
Surface Element RM
273
Illumination Models Ambient Light
Produces uniform illumination (also known as background light). Has no spatial or directional characteristics. Assumed to be incident from all directions with constant intensity Ia. Ambient light reflection from a surface is constant along all visible directions, and does not depend on the surface orientation. RM
274
Illumination Models Point Light Source
Defined in terms of both the position of the source, and the intensity of the source Is. The reflection from a point light source depends on the surface orientation, and varies with respect to the view direction. Light source reflection consists of both specular reflection and diffuse reflection. RM
275
Light Perceived by the Viewer Diffuse Reflection
Point Source Id = Is diff cos Since diffuse scattering is uniform in all directions, the orientation of the polygon relative to the viewer is not significant. RM
276
Light Perceived by the Viewer Specular Reflection
Isp = (Is spec cos f ) The vector h = s + v is known as the half-way vector. f is an experimentally determined constant RM
277
Light Perceived by the Viewer Specular Reflection
f is specular reflection parameter determine type of surface. (in OpenGL the value range 0 to 128). A very shiny surface is modeled with a large value, and smaller value (down to 0) are used for dull object. RM
278
Light Perceived by the Viewer Ambient Reflection
Ambient reflection is independent of surface orientation. Ambient reflection is independent of viewers position. The ambient light Ia is uniformly reflected with intensity Ia amb. This is denoted as the ambient reflection Iamb. Iamb = Ia amb RM
279
Computation of Total Reflected Light
Total light intensity perceived by the user = Iamb+ Isp + Id = (Ia amb) + (Is spec cos f ) + Is diff cos RM
280
Shading (OpenGL) RM
281
Flat and Smooth Shading
Flat Shading Gouraud Shading The entire polygon is drawn with the same shade or color. The shades at the vertices are interpolated to determine the shade at an interior point RM
282
Gouraud Shading The color at P1 is obtained by linearly interpolating the colors C1 and C2. Similarly, the color at P2 is found by linearly interpolating the colors C3 and C4. Having found P1 and P2, the algorithm then fills along the scan line by linearly interpolating between P1 and P2 to determine the color at an intermediate pixel Q. RM
283
Flat and Smooth Shading (OpenGL)
RM
284
Flat and Smooth Shading
Flat Shading Gouraud Shading Gouraud shading provides a much smoother appearance of surfaces. RM
285
Texture Mapping (Examples)
RM
286
Texture Mapping The basic techniques begin with some texture functions, texture(s,t),in texture space which is traditionally marked off by parameters named s and t. The function texture(s,t) produces a color or intensity value for each value of s and t between 0 and 1. Texture mapping is the process of mapping a region in the 2D texture space to a region in the 3D space defined by the boundary points. RM
287
Texture Mapping Texture Space RM
288
Texture Mapping (OpenGL)
RM
289
Texture types Bitmap Textures: Often formed from bitmap representations of images. Defined by a mathematical function or procedure. RM
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.