Upload
phungdat
View
215
Download
0
Embed Size (px)
Citation preview
Gopi -ICS186AW03 - Slide2
Graphics Pipeline: First passGraphics Pipeline: First pass
• Object representation (triangles) and computation Object representation (triangles) and computation of vertex attributesof vertex attributes
• Model-view transformationModel-view transformation
• Projection transformationProjection transformation
• Clipping and vertex interpolation of attributesClipping and vertex interpolation of attributes
• Rasterization and pixel interpolation of attributesRasterization and pixel interpolation of attributes
Gopi -ICS186AW03 - Slide3
Object RepresentationObject Representation
• Most common: TRIANGLESMost common: TRIANGLES
• Advantages:Advantages:– Consistently planarConsistently planar– Rotationally-invariant interpolation during Rotationally-invariant interpolation during
rasterizationrasterization– Easy definition of topology as well as geometryEasy definition of topology as well as geometry– Easy hardware implementationEasy hardware implementation
Gopi -ICS186AW03 - Slide4
Object RepresentationObject Representation
• Other representations:Other representations:
– Points (no connectivity information)Points (no connectivity information)
– Quadrilaterals (non-planarity, inconsistent Quadrilaterals (non-planarity, inconsistent interpolation of attributes) interpolation of attributes)
– Images (no geometry: not useful in simulations)Images (no geometry: not useful in simulations)
– Splines (to be converted to polygons for Splines (to be converted to polygons for rasterization)rasterization)
Gopi -ICS186AW03 - Slide5
AttributesAttributes
• Color (Red, Green, Blue)Color (Red, Green, Blue)• Normal vectorNormal vector• Texture coordinateTexture coordinate• Transparency valueTransparency value
..
..
..
Gopi -ICS186AW03 - Slide6
Graphics Pipeline: First passGraphics Pipeline: First pass
• Object representation (triangles) and computation Object representation (triangles) and computation of vertex attributesof vertex attributes
• Model-view transformationModel-view transformation
• Projection transformationProjection transformation
• Clipping and vertex interpolation of attributesClipping and vertex interpolation of attributes
• Rasterization and pixel interpolation of attributesRasterization and pixel interpolation of attributes
Gopi -ICS186AW03 - Slide7
Model-view transformationsModel-view transformations
• Model transformationModel transformation
• View transformationView transformation
Gopi -ICS186AW03 - Slide8
Model transformationsModel transformations
• Transform the object to the required position, size Transform the object to the required position, size and orientation.and orientation.– Can use any transformation to achieve this.Can use any transformation to achieve this.– In graphics library/hardware only linear In graphics library/hardware only linear
transformations like rotate, translate, scale, transformations like rotate, translate, scale, shear are supported.shear are supported.
Gopi -ICS186AW03 - Slide9
View transformationView transformation
• Viewing parameters: (9 parameters)Viewing parameters: (9 parameters)
– View POINT (x,y,z), View POINT (x,y,z),
– Viewing direction (VECTOR): (vx,vy,vz), Viewing direction (VECTOR): (vx,vy,vz),
– View-up VECTOR: (ux,uy,uz). View-up VECTOR: (ux,uy,uz).
– Default: (0,0,0), (0,0,-1), (0,1,0)Default: (0,0,0), (0,0,-1), (0,1,0)
• Transforming the scene such that the view point is at the Transforming the scene such that the view point is at the origin, viewing direction is aligned with the negative Z axis, origin, viewing direction is aligned with the negative Z axis, and the view-up vector is aligned with the positive Y axis.and the view-up vector is aligned with the positive Y axis.
– Uses rotation and translation to achieve this transformation.Uses rotation and translation to achieve this transformation.
Gopi -ICS186AW03 - Slide10
Graphics Pipeline: First passGraphics Pipeline: First pass
• Object representation (triangles) and computation Object representation (triangles) and computation of vertex attributesof vertex attributes
• Model-view transformationModel-view transformation
• Projection transformationProjection transformation
• Clipping and vertex interpolation of attributesClipping and vertex interpolation of attributes
• Rasterization and pixel interpolation of attributesRasterization and pixel interpolation of attributes
Gopi -ICS186AW03 - Slide11
Projection TransformationProjection Transformation
• Define the “view frustum” (6 parameters)Define the “view frustum” (6 parameters)
– Assume origin is the view pointAssume origin is the view point
– Near and far planes (planes parallel to XY plane Near and far planes (planes parallel to XY plane in the negative Z axis)in the negative Z axis)
– Left, right, top, bottom rectangle defined on the Left, right, top, bottom rectangle defined on the near plane.near plane.
X
Y-Z
near far
Gopi -ICS186AW03 - Slide12
Projection TransformationProjection Transformation
• Transforming the view frustum (along with the Transforming the view frustum (along with the objects inside it) into a cuboid with unit square objects inside it) into a cuboid with unit square faces on the near and far planes and with the faces on the near and far planes and with the negative Z axis passing through the center of these negative Z axis passing through the center of these two faces.two faces.
• Consists of a “shear” and a “perspective Consists of a “shear” and a “perspective projection” operations. projection” operations.
Gopi -ICS186AW03 - Slide13
Graphics Pipeline: First passGraphics Pipeline: First pass
• Object representation (triangles) and computation Object representation (triangles) and computation of vertex attributesof vertex attributes
• Model-view transformationModel-view transformation
• Projection transformationProjection transformation
• Clipping and vertex interpolation of attributesClipping and vertex interpolation of attributes
• Rasterization and pixel interpolation of attributesRasterization and pixel interpolation of attributes
Gopi -ICS186AW03 - Slide14
Clipping and Interpolation of Clipping and Interpolation of AttributesAttributes
• Clipping:Clipping: Removing the portions of the polygon Removing the portions of the polygon that is outside the view frustum. If the polygon that is outside the view frustum. If the polygon spans inside and outside the view frustum, spans inside and outside the view frustum, introduce new vertices on the boundary to remove introduce new vertices on the boundary to remove the outside portion of the polygon.the outside portion of the polygon.
• Interpolation:Interpolation: For the new vertices introduced, For the new vertices introduced, compute all the attributes of the original vertices compute all the attributes of the original vertices by interpolation.by interpolation.
Gopi -ICS186AW03 - Slide15
Window coordinate transformationWindow coordinate transformation
• After clipping, scale the square faces of the unit After clipping, scale the square faces of the unit cuboid (square faced on the near and far planes) cuboid (square faced on the near and far planes) such that it represents the (relative) pixel such that it represents the (relative) pixel coordinates. (You don’t consider the Z value).coordinates. (You don’t consider the Z value).
• Then translate these coordinates to the position of Then translate these coordinates to the position of the window on the monitor screen to represent the the window on the monitor screen to represent the absolute pixel coordinates.absolute pixel coordinates.
• This is called window coordinate transformation.This is called window coordinate transformation.
Gopi -ICS186AW03 - Slide16
Graphics Pipeline: First passGraphics Pipeline: First pass
• Object representation (triangles) and computation Object representation (triangles) and computation of vertex attributesof vertex attributes
• Model-view transformationModel-view transformation
• Projection transformationProjection transformation
• Clipping and vertex interpolation of attributesClipping and vertex interpolation of attributes
• Rasterization and pixel interpolation of attributesRasterization and pixel interpolation of attributes
Gopi -ICS186AW03 - Slide17
Rasterization and Pixel Attribute Rasterization and Pixel Attribute InterpolationInterpolation
• Rasterization is a process of generating pixels in Rasterization is a process of generating pixels in the scan (horizontal) line order (top to bottom, left the scan (horizontal) line order (top to bottom, left to right). (Also called “scan conversion”.)to right). (Also called “scan conversion”.)
• While generating pixels, the colors and other While generating pixels, the colors and other relevant attributes of the pixels are found by relevant attributes of the pixels are found by interpolating the attributes of the left and right interpolating the attributes of the left and right extent of the scan line that lie on the polygon edge.extent of the scan line that lie on the polygon edge.
left rightright left
Scan Line