![Page 1: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/1.jpg)
1
Computer Graphics
Chapter 9Rendering
![Page 2: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/2.jpg)
[9]-2 RM
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.
![Page 3: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/3.jpg)
[9]-3 RM
Computing Surface Normal
P3
P1 P2
V1
V2
N V1 = P2P1 = (x2x1, y2y1, z2z1).
V2 = P3P1 = (x3x1, y3y1, z3z1).
N = V1 V2.
131313
121212
zzyyxx
zzyyxx
kji
Surface Normal:
![Page 4: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/4.jpg)
[9]-4 RM
Components of Surface Normal
Nx = (y2y1) (z3z1) (y3y1) (z2z1)
Ny = (z2z1) (x3x1) (z3z1) (x2x1)
Nz = (x2x1) (y3y1) (x3x1) (y2y1)
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)
OR
![Page 5: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/5.jpg)
[9]-5 RM
Back-Face Culling
ZViewer
Back faces
Nz < 0 The polygon is hidden
![Page 6: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/6.jpg)
[9]-6 RM
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.
+Viewer
![Page 7: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/7.jpg)
[9]-7 RM
Back-Face Culling (General Case)
Viewer P1
P2V
N
V.N > 0 The polygon is hidden
![Page 8: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/8.jpg)
[9]-8 RM
Back-Face Culling (Example)
![Page 9: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/9.jpg)
[9]-9 RM
Back-Face Culling (OpenGL)
Defining a front face as the face with CCW ordering of vertices(Default):
glFrontFace(GL_CCW);
Enabling polygon culling:
glEnable(GL_CULL_FACE);
Discard back facing polygons:
glCullFace(GL_BACK);
![Page 10: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/10.jpg)
[9]-10 RM
Painter’s Algorithm
![Page 11: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/11.jpg)
[9]-11 RM
Painters Algorithm
Basic Steps:
Sort polygons in the ascending order of z-coordinates
Fill polygons in the sorted order.
![Page 12: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/12.jpg)
[9]-12 RM
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.
![Page 13: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/13.jpg)
[9]-13 RM
Polygons with depth and region overlap.
Z
(1)
(2)
Polygons having both depth-overlap and region overlap may requirere-sequencing of the polygonsin the sorted list.
Painters AlgorithmFailure Conditions (1)
![Page 14: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/14.jpg)
[9]-14 RM
Polygons with cyclic overlap.
Painters AlgorithmFailure Conditions (2)
![Page 15: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/15.jpg)
[9]-15 RM
Painter’s AlgorithmIllustration of failure conditions
Wrong Correct
![Page 16: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/16.jpg)
[9]-16 RM
Z
Depth-Buffer Algorithm
Frame Buffer Depth Buffer
Color ValueMinimum Depth Value
![Page 17: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/17.jpg)
[9]-17 RM
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.
![Page 18: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/18.jpg)
[9]-18 RM
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.
![Page 19: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/19.jpg)
[9]-19 RM
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.
![Page 20: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/20.jpg)
[9]-20 RM
Shading ModelsVectors
ms
v
Polygon
![Page 21: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/21.jpg)
[9]-21 RM
Shading ModelsSurface 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
![Page 22: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/22.jpg)
[9]-22 RM
Shading ModelsSurface 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
![Page 23: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/23.jpg)
[9]-23 RM
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.
Surface Properties
![Page 24: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/24.jpg)
[9]-24 RM
Surface Element
AmbientLight
AmbientLight
Point Source
Illumination Models
![Page 25: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/25.jpg)
[9]-25 RM
Illumination ModelsAmbient 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.
![Page 26: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/26.jpg)
[9]-26 RM
Illumination ModelsPoint 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.
![Page 27: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/27.jpg)
[9]-27 RM
Light Perceived by the ViewerDiffuse 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.
![Page 28: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/28.jpg)
[9]-28 RM
Light Perceived by the ViewerSpecular Reflection
The vector h = s + v is known as the half-way vector.
f is an experimentally determined constant
Isp = (Is spec cos f )
![Page 29: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/29.jpg)
[9]-29 RM
Light Perceived by the ViewerSpecular Reflection
f is specular reflection parameter determine is specular reflection parameter determine type of surface. (in OpenGL the value range 0 type of surface. (in OpenGL the value range 0
to 128). A very shiny surface is modeled with a to 128). A very shiny surface is modeled with a large value, and smaller value (down to 0) are large value, and smaller value (down to 0) are
used for dull object.used for dull object.
![Page 30: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/30.jpg)
[9]-30 RM
Light Perceived by the ViewerAmbient 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
![Page 31: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/31.jpg)
[9]-31 RM
Computation of Total Reflected Light
Total light intensity perceived by the user
= Iamb+ Isp + Id
= (Ia amb) + (Is spec cos f ) + Is diff cos
![Page 32: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/32.jpg)
[9]-32 RM
Shading (OpenGL)
Setting material properties in OpenGL:
glMaterialfv(GL_FRONT, refl, iarray);
where, refl = GL_AMBIENT :Sets ambient reflection coefficients.GL_DIFFUSE : Sets diffuse reflection coefficients.GL_SPECULAR : Sets specular reflection coefficients.
iarray : Array of coefficients in RGBA format.
![Page 33: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/33.jpg)
[9]-33 RM
Flat and Smooth 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
Flat Shading Gouraud Shading
![Page 34: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/34.jpg)
[9]-34 RM
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.
y C1
C2
C3
C4
P1 P2Q
yk
x
![Page 35: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/35.jpg)
[9]-35 RM
Flat and Smooth Shading (OpenGL)
Setting flat shading:
glShadeModel(GL_FLAT);
Setting Gouraud shading:
glShadeModel(GL_SMOOTH);
![Page 36: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/36.jpg)
[9]-36 RM
Flat and Smooth Shading
Gouraud shading provides a much smoother appearance of surfaces.
Flat Shading Gouraud Shading
![Page 37: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/37.jpg)
[9]-37 RM
Texture Mapping (Examples)
![Page 38: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/38.jpg)
[9]-38 RM
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.
![Page 39: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/39.jpg)
[9]-39 RM
Texture Mapping
Texture Space
![Page 40: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/40.jpg)
[9]-40 RM
Texture Mapping (OpenGL)
Associating a point (s,t) in texture space with avertex V(x,y,z) of a polygon:
glTexCoord2f(s, t);glVertex3f(x, y, z);
![Page 41: 1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object](https://reader035.vdocuments.us/reader035/viewer/2022062515/56649ce35503460f949aec1f/html5/thumbnails/41.jpg)
[9]-41 RM
Texture types
Bitmap Textures: Often formed from bitmap representations of images.
Defined by a mathematical function or procedure.