Tribhuwan University

Institute of Science and Technology

Model

Bachelor Level / Third Year / Fifth Semester / Science

Bachelors in Information Technology (BIT304)

(Computer Graphics)

Full Marks: 60

Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as for as practicable.

The figures in the margin indicate full marks.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
Differentiate between ambient light and diffuse reflection. Write algorithm for Phong Shading.[10]

Differentiate Between Ambient Light and Diffuse Reflection & Phong Shading Algorithm

Part A: Difference Between Ambient Light and Diffuse Reflection

Parameter Ambient Light Diffuse Reflection
Definition Constant background illumination that uniformly lights all surfaces regardless of position or orientation Light reflected equally in all directions from a surface based on the angle of incoming light
Direction Dependency Independent of light source direction and viewer position Depends on the angle between light source direction and surface normal
Formula Iambient=KaIaI_{ambient} = K_a \cdot I_a Idiffuse=KdIlcosθ=KdIl(N^L^)I_{diffuse} = K_d \cdot I_l \cdot \cos\theta = K_d \cdot I_l \cdot (\hat{N} \cdot \hat{L})
Surface Normal Not required for computation Required to calculate the angle of incidence
Appearance Produces flat, uniform illumination with no shading variation Produces shading that varies across the surface based on orientation
Realism Low — no depth perception Moderate — gives sense of 3D shape
Light Source Simulates indirect/scattered light in environment Simulates direct light hitting a rough/matte surface
Shadow Effect No shadows produced Surfaces facing away from light appear darker
Example Light in a room with no visible source A chalk piece or matte wall under a bulb

Part B: Algorithm for Phong Shading (Per-Pixel Shading)

Phong Shading is an interpolation method where the surface normal is interpolated across the polygon, and the illumination model is applied at each pixel to produce smooth, realistic highlights.

Steps of the Algorithm:

  • Step a: For each polygon, compute the normal vectors at each vertex ($\hat{N}_1, \hat{N}_2, \hat{N}_3$) using the average of normals of adjacent polygons.

  • Step b: For each scan line that intersects the polygon, determine the boundary edges (left and right intersection points).

  • Step c: Interpolate normals along polygon edges — For each edge, linearly interpolate the vertex normals to get the normal at each edge intersection point on the scan line:

N^a=yy2y1y2N^1+y1yy1y2N^2\hat{N}_a = \frac{y - y_2}{y_1 - y_2} \hat{N}_1 + \frac{y_1 - y}{y_1 - y_2} \hat{N}_2

  • Step d: Interpolate normals along the scan line — For each pixel between left and right edge, interpolate the normal:

N^p=xrightxxrightxleftN^a+xxleftxrightxleftN^b\hat{N}_p = \frac{x_{right} - x}{x_{right} - x_{left}} \hat{N}_a + \frac{x - x_{left}}{x_{right} - x_{left}} \hat{N}_b

  • Step e: Normalize the interpolated normal at each pixel: N^p=N^pN^p\hat{N}_p = \frac{\hat{N}_p}{|\hat{N}_p|}

  • Step f: Apply the Phong illumination model at each pixel using the interpolated normal:

I=KaIa+KdIl(N^pL^)+KsIl(R^V^)nI = K_a I_a + K_d I_l (\hat{N}_p \cdot \hat{L}) + K_s I_l (\hat{R} \cdot \hat{V})^n

Where:

  • Ka,Kd,KsK_a, K_d, K_s = ambient, diffuse, specular reflection coefficients

  • R^\hat{R} = reflection vector

  • V^\hat{V} = viewer direction vector

  • nn = shininess exponent

  • Step g: Assign the computed intensity value to the pixel and move to the next pixel.

  • Step h: Repeat for all scan lines until the entire polygon is rendered.

Advantages of Phong Shading:

  • Produces realistic specular highlights that appear smooth and correctly positioned
  • Eliminates Mach band effect seen in Gouraud shading
  • Gives high-quality rendering for curved surfaces

Disadvantage:

  • Computationally expensive since illumination model is evaluated at every pixel

Conclusion: Ambient light provides basic uniform visibility while diffuse reflection adds depth based on surface orientation. Phong Shading combines both along with specular reflection at every pixel to produce the most realistic rendering among polygon shading methods.

2.
Define Hermite interpolation in defining a curve. Draw a line with end points (2, 3) and (12, 8) using DDA.[10]
3.
Obtain perspective projection co-ordinates for the pyramid with vertices of base (15, 15, 10), (20, 20, 10), (25, 15, 10), (20, 10, 10) and apex (20, 15, 2), given that Zprp = 20 and Zvp = 0.[10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
How much time is spent scanning across each row of pixels during screen refresh on a raster system with resolution 1024*768 and refresh rate of 60 frames per second? [5]
5.
Write mid point circle drawing algorithm. [5]
6.
Derive the Bresenham's decision parameter to draw a line with negative slope. [5]
7.
Differentiate between parallel and perspective projection. [5]
8.
Differentiate between vector and raster scan systems. [5]
9.
Prove that successive rotation is equal to addition of angles. [5]
10.
What are the disadvantages of flat shading? How they can be eliminated? [5]
11.
What are the conditions for error free generation of polygon table? [5]
12.
Write short notes on a. Vertex table b. Key frame [5]