En Assignment4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Assignment 4: Shading

Knud Henriksen
Department of Computer Science
University of Copenhagen†

The topic of this assignment is to understand, explain, and implement an algorithm for
Phong shading of triangles. Phong’s reflection model has three terms: ambient, diffuse,
and specular reflection.
The assignment must address the following topics:
• Explain what is the contribution of the individual terms: ambient, diffuse, and
specular to the final reflection.
• Explain how one can express the factor cos θ as a dot product between two vectors.
• Explain what one must do if the above mentioned dot product becomes negative.
Given a point p with an associatd normal n. The point p is transformed by a matrix
matrix M .
• Derive the matrix by which the normal vector n must be transformed.
Your assigment must also:
• Explain how the vertex program is implemented, and which variables it uses.
• Explain how the fragment program is implemented, and which variables it uses.
• Explain how a variable in the main program on the CPU interacts with a variable
in the vertex program.
• Explain how a variable in the main program on the CPU interacts with a variable
in the fragment program.
• Explain how variables in the vertex and fragment programs are accessed, updated,
and changed.
• Explain how special cases are detected and handled. E.g. a normal pointing in the
wrong direction – how is that detected and how is it handled? Show examples of
the implementation.
• Analyze and design tests which show that the implemented Phong shading of a
triangle works correct, when the ‘specular highlight’ lies in the middle of the triangle.
The easiest way to document that the algorithm works as expected is to show images
of the results. Remember that a test must contain a description of what is to be
tested and how it is tested. It must also contain a description of the expected
results. If the test does not give the expected results, you must explain why there
are differences.
• Reflect on the results of the tests.
• Write a conclusion of the work you have done.

Address: Universitetsparken 3, DK-2100 Copenhagen Ø, Denmark
The program mitht be tested with the following data (but make your own tests, so you
show that your shading works as expected):
Geoetry of the Triangle:

V ertex1 = (−33.978017, −34.985076, 50.214926)


V ertex2 = (84.192943, −13.784394, −50.214926)
V ertex3 = (−16.236910, 83.754546, −50.214926)

The normal in the vertices is equal the the cross product of the two incident edges — that
is, same normal in all vertices.
Ambient Light Source

(Ia,red , Ia,green , Ia,blue ) = (0.5, 0.5, 0.5)

Point Light Source

Intensity = (Ip,red , Ip,green , Ip,blue ) = (1.0, 1.0, 1.0)


Position = (Lx , Ly , Lz ) = (266.395325, 274.291267, −43.696048)

Viewing Parameters

V RP = (0.0, 0.0, 125.0)


V P N = (0.0, 0.0, 1.0)
V U P = (0.0, 1.0, 0.0)
P RP = (0.0, 0.0, 50.0)
F = 10.0
B = −800.0
(Umin , Vmin ) = (−25.0, −25.0)
(Umax , Vmax ) = (25.0, 25.0)

Material Properties

Ka = 0.5
Oa = (0.0, 1.0.0.0)
Kd = 0.75
Od = (0.0, 1.0, 0.0)
Ks = 0.9
Os = (1.0, 1.0, 1.0)
Fatt = 1.0
n = 20
There is published some notes “Guidelines” on Absalon. These notes give some advice
about what to include in your mini report, and also a couple of things that you should
avoid.

Figure 1: Example of a specular highlight in the middle of a triangle.

You might also like