Download presentation
Presentation is loading. Please wait.
1
Computer Graphics Chapter 9 Rendering
2
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
3
Computing Surface Normal
V1 = P2P1 = (x2x1, y2y1, z2z1). V2 = P3P1 = (x3x1, y3y1, z3z1). N = V1 V2. Surface Normal: RM
4
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
5
Back-Face Culling Nz < 0 The polygon is hidden RM
6
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
7
Back-Face Culling (General Case)
V.N > 0 The polygon is hidden RM
8
Back-Face Culling (Example)
RM
9
Back-Face Culling (OpenGL)
RM
10
Painter’s Algorithm RM
11
Painters Algorithm Basic Steps:
Sort polygons in the ascending order of z-coordinates Fill polygons in the sorted order. RM
12
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
13
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
14
Painters Algorithm Failure Conditions (2)
Polygons with cyclic overlap. RM
15
Painter’s Algorithm Illustration of failure conditions Correct Wrong
RM
16
Depth-Buffer Algorithm
Z Minimum Depth Value Color Value RM Frame Buffer Depth Buffer
17
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
18
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
19
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
20
Shading Models Vectors
RM
21
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
22
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
23
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
24
Illumination Models Point Source Ambient Light Ambient Light
Surface Element RM
25
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
26
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
27
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
28
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
29
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
30
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
31
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
32
Shading (OpenGL) RM
33
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
34
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
35
Flat and Smooth Shading (OpenGL)
RM
36
Flat and Smooth Shading
Flat Shading Gouraud Shading Gouraud shading provides a much smoother appearance of surfaces. RM
37
Texture Mapping (Examples)
RM
38
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
39
Texture Mapping Texture Space RM
40
Texture Mapping (OpenGL)
RM
41
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.