Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective...
-
Upload
edwin-black -
Category
Documents
-
view
223 -
download
1
Transcript of Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective...
![Page 1: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/1.jpg)
Review on Graphics Basics
![Page 2: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/2.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 3: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/3.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 4: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/4.jpg)
Polygon Rendering Pipeline
• Process objects one at a time in the order they are generated by the application
• Pipeline architecture
• All steps can be implemented in hardware on the graphics card
application program display
![Page 5: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/5.jpg)
Vertex Processing
• Much of the work in the pipeline is in converting object representations from one coordinate system to another– Object coordinates– Camera (eye) coordinates– Screen coordinates
• Every change of coordinates is equivalent to a matrix transformation
• Vertex processor also computes vertex colors
![Page 6: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/6.jpg)
Projection
• Projection is the process that combines the 3D viewer with the 3D objects to produce the 2D image– Perspective projections: all projectors meet at the
center of projection– Parallel projection: projectors are parallel, center
of projection is replaced by a direction of projection
![Page 7: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/7.jpg)
Primitive Assembly
Vertices must be collected into geometric objects before clipping and rasterization can take place– Line segments– Polygons– Curves and surfaces
![Page 8: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/8.jpg)
Clipping
Just as a real camera cannot “see” the whole world, the virtual camera can only see part of the world or object space– Objects that are not within this volume are said to
be clipped out of the scene
![Page 9: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/9.jpg)
Rasterization• If an object is not clipped out, the appropriate pixels
in the frame buffer must be assigned colors• Rasterizer produces a set of fragments for each
object• Fragments are “potential pixels”
– Have a location in frame buffer– Color and depth attributes
• Vertex attributes are interpolated over objects by the rasterizer
![Page 10: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/10.jpg)
Fragment Processing
• Fragments are processed to determine the color of the corresponding pixel in the frame buffer
• Colors can be determined by texture mapping or interpolation of vertex colors
• Fragments may be blocked by other fragments closer to the camera – Hidden-surface removal
![Page 11: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/11.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 12: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/12.jpg)
Affine Transformations
• Line and parallelism preserving• Affine transformations used in Graphics
– Rigid body transformations: rotation, translation– Scaling, shear
• Importance in graphics is that we need only transform endpoints of line segments and let implementation draw line segment between the transformed endpoints
![Page 13: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/13.jpg)
Homogeneous CoordinatesThe homogeneous coordinates form for a three dimensional
point [x y z] is given as
p =[x’ y’ z’ w] T =[wx wy wz w] T
We return to a three dimensional point (for w0) byxx’/wyy’/wzz’/wIf w=0, the representation is that of a vectorNote that homogeneous coordinates replaces points in three
dimensions by lines through the origin in four dimensionsFor w=1, the representation of a point is [x y z 1]
![Page 14: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/14.jpg)
Homogeneous Coordinates and Computer Graphics
• Homogeneous coordinates are key to all computer graphics systems– All standard transformations (rotation, translation,
scaling) can be implemented with matrix multiplications using 4 x 4 matrices
– Hardware pipeline works with 4 dimensional representations
![Page 15: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/15.jpg)
Translation MatrixWe can also express translation using a 4 x 4 matrix T in homogeneous coordinatesp’=Tp where
T = T(dx, dy, dz) =
This form is better for implementation because all affine transformations can be expressed this way and multiple transformations can be concatenated together
1000
d100
d010
d001
z
y
x
![Page 16: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/16.jpg)
Rotation (2D)
Consider rotation about the origin by q degrees– radius stays the same, angle increases by q
x’=x cos q –y sin qy’ = x sin q + y cos q
x = r cos fy = r sin f
x’ = r cos ( + )f qy’ = r sin ( + )f q
![Page 17: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/17.jpg)
Rotation about the z axis
• Rotation about z axis in three dimensions leaves all points with the same z– Equivalent to rotation in two dimensions in planes
of constant z
– or in homogeneous coordinates
p’=Rz(q)p
x’=x cos q –y sin qy’ = x sin q + y cos qz’ =z
![Page 18: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/18.jpg)
Rotation Matrix
1000
0100
00 cossin
00sin cos
R = Rz(q) =
![Page 19: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/19.jpg)
Scaling
1000
000
000
000
z
y
x
s
s
s
S = S(sx, sy, sz) =
x’=sxxy’=syxz’=szx
p’=Sp
Expand or contract along each axis (fixed point of origin)
![Page 20: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/20.jpg)
Reflection
corresponds to negative scale factors
originalsx = -1 sy = 1
sx = -1 sy = -1 sx = 1 sy = -1
![Page 21: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/21.jpg)
Shear
• Helpful to add one more basic transformation• Equivalent to pulling faces in opposite directions
![Page 22: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/22.jpg)
Shear Matrix
Consider simple shear along x axis
x’ = x + y cot qy’ = yz’ = z
1000
0100
0010
00cot 1
H(q) =
![Page 23: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/23.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 24: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/24.jpg)
Affine vs. Projective Transformation
• Difference is in the last line of the transformation matrix. – Projective transformation preserves collinearity but not
parallelism, length, and angle. – Affine transformation is a special case of the projective
transformation. However, it preserves parallelism.
1000
lkji
hgfe
dcba
Ma = Mp =
1onm
lkji
hgfe
dcba
![Page 25: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/25.jpg)
Projections and Normalization
• The default projection in the eye (camera) frame is orthogonal
• For points within the default view volume
• Most graphics systems use view normalization– All other views are converted to the default view by
transformations that determine the projection matrix– Allows use of the same pipeline for all views
xp = xyp = yzp = 0
![Page 26: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/26.jpg)
Homogeneous Coordinate Representation
xp = xyp = yzp = 0wp = 1
pp = Mp
M =
1000
0000
0010
0001
In practice, we can let M = I and set the z term to zero later
default orthographic projection
![Page 27: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/27.jpg)
Simple Perspective
• Center of projection at the origin• Projection plane z = d, d < 0
![Page 28: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/28.jpg)
Perspective Equations
Consider top and side views
xp =
dz
x
/
dz
x
/yp =
dz
y
/zp = d
![Page 29: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/29.jpg)
Homogeneous Coordinate Form
M =
0/100
0100
0010
0001
d
consider q = Mp where
1
z
y
x
dz
z
y
x
/
q = p =
![Page 30: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/30.jpg)
Perspective Division
• However w 1, so we must divide by w to return from homogeneous coordinates
• This perspective division yields
the desired perspective equations • We will consider the corresponding clipping
volume with the OpenGL functions
xp =
dz
x
/yp =
dz
y
/zp = d
![Page 31: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/31.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 32: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/32.jpg)
Phong Model
For each light source and each color component, the Phong model can be written as
I = (a+bd+cd2)-1[ kd Id l · n+ks Is (v · r ) a +kaIa]
For each color componentwe add contributions fromall sources
![Page 33: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/33.jpg)
Example
Only differences in these teapots are the parametersin the modifiedPhong model
![Page 34: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/34.jpg)
Outline
• Polygon rendering pipeline• Affine transformations• Projective transformations• Lighting and shading• From vertices to fragments
![Page 35: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/35.jpg)
Pipeline Clipping of Polygons
• Three dimensions: add front and back clippers• Strategy used in SGI Geometry Engine• Small increase in latency
![Page 36: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/36.jpg)
Scan Conversion and Interpolation
span
C1
C3
C2
C5
C4
scan line
C1 C2 C3 specified by glColor or by vertex shadingC4 determined by interpolating between C1 and C2
C5 determined by interpolating between C2 and C3
interpolate between C4 and C5 along span
![Page 37: Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.](https://reader036.fdocuments.in/reader036/viewer/2022062322/5697bfab1a28abf838c9ae86/html5/thumbnails/37.jpg)
Hidden Surface Removal
• z-Buffer Algorithm– Use a buffer called the z or depth buffer to store the depth of
the closest object at each pixel found so far– As we render each polygon, compare the depth of each pixel
to depth in z buffer– If less, place shade of pixel in color buffer and update z buffer