[SOLVED] Instruction

$25

File Name: Instruction.zip
File Size: 103.62 KB

5/5 - (1 vote)

Instruction
For this project, you need to do the coloring on the object surface to make a more realistic 3D look. Recall what we have learned in the class, there are three types of illumination models: diffuse, ambient, and phong terms. So you need to apply these three illumination principles to generate a plausible RGB color for each 3D unit. Since the bunny object consists of multiple triangles. For this assignment, you need to use the flat shading mode to render the Bunny object. In other word, the shading unit is a triangle. All the surface points from the same triangle have the same RGB color. Here are some example pictures:
plaster version (diffuse + ambient) class version (diffuse + ambient + phong = 50)
gold version (diffuse + ambient + phong = 0.5 )

Requirements:
(1) Correct computation on cross-product between vectors to obtain the normal for each triangle (10%)
(2) Correct computation on view, light, and normal vectors (10%)
(3) Correct illumination model for the ambient term (10%)
(4) Correct illumination model for the diffuse term (15%)
(5) Correct illumination model for the phong term (20%)
(6) Correct keyboard callback function to switch between different views (15%)
hit 0 to show the Bunny with no shading at all (a single color for all the triangles).
hit 1 to show the Bunny with only diffuse and ambient terms. The result looks like a plaster material.
hit 2 to show the Bunny with diffuse, ambient, and phong terms. The result may look like different types of materials, depending on your choice of the exponential p for the phong terms, e.g. china material (p = [55, 100], metal material p = [0.1, 1.0]).
hit key M or m only to show the mesh lines (no triangle surface).
(7) Implement the normal interpolation for each vertex by using all the adjacent
triangles (20%)
Hints:
void SetColors(Mesh mesh)
{
Color[] colors = new Color[mesh.vertexCount];
for (int i = 0; i < colors.Length; i += 3){colors[i] = color_white;colors[i + 1] = color_white;colors[i + 2] = color_white;}mesh.colors = colors;}The SetColors() function code above is the key function you will modify to assign the color for each vertex. mesh.colors stores an array of Color objects, which each corresponding to the mesh.vertices array. As mentioned in the class, the mesh.vertices array is already sorted according to the triangle array. In other words, every 3 vertices with sequential indices correspond to the same triangles three vertices. Your job is to assign all the vertices color by using the illumination model described in the class. The main variable you will modify is the mesh.colors. The other two variables mesh.vertices and mesh.triangles are read-only. You really dont need to modify these two variables in your code.Vector3 light_p = new Vector3(0, 0, 5);Vector3 camera = new Vector3(1, 1, 5);Color color_light = new Color(0.8f, 0.8f, 0.8f);Color color_ambient = new Color(0.9f, 0.9f, 0.9f);Color color_phong = new Color(0.2f, 0.2f, 0.2f);Color color_white = new Color(0.5f, 0.5f, 0.5f);Color color_gold = new Color(0.9f * 0.8f, 0.7f * 0.8f, 0.1f * 0.8f);Color color_obj = new Color(0.5f, 0.5f, 0.5f);These variables in the beginning of the code are examples of different color and position settings. Feel free to change them to generate different color. Also, you need to define the phong exponent p, e.g. p = 0.5 or p = 100.Attention: your code should compute the triangle normal by yourself using the cross-product as mentioned in the class.Steps:Below are the snapshots on the project setup (as described in the class)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Instruction
$25