Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Programming Assignment #3 (20 marks)

Problem (20 marks): Shading Stanford Bunny

In this assignment you are going to render the Stanford bunny with two light sources. Do not use any other third party libraries other than the bunny.js, the Common folder, and the Tutorial folder, provided within the assignment zip file.

(a) [3 marks] Drawing the bunny using perspective projection

There are two functions in the bunny.js provided with this assignment. get_vertices returns an array of vertex positions; get_faces returns an array of vertex indices starting from 1. The perspective camera is at (0, 0, 10), and the initial position of the bunny is at (0, 0, 0). You can assign an arbitrary uniform color for each vertex for now. We suggest to use a field of view of 60 degrees or larger for the camera in order to see the lights at their initial positions in the next steps.

 

(b)  [2 marks] Interactively translating the bunny

Implement  translation  of the  bunny  along  the  global  X,  Y  and  Z  axes.  The horizontal  and  vertical  movement  of the  mouse  when  the  left  mouse button  is pressed  should  correspond  to  X  and  Y  translation.  The  Z  translation  can  be implemented by either the up and down arrows on your keyboard, or the wheel on your mouse ifyou have one.

(c)  [4 marks] Interactively rotating the bunny

Implement rotation of the bunny around the global X and Y axes. The horizontal and vertical movement of the mouse when the right mouse button is pressed should correspond to Y and X rotations respectively. Also implement a reset function so that whenever the user press key r”, the bunny returns to its initial location and orientation.

(d) [2 marks] Draw an auto rotating point light as a wireframe cube

The point light is at (5,5,0) initially. The point light auto rotates counter-clockwise above the bunny in a constant speed. The rotation of the light can be turned on and off by pressing key p” .

(e)  [3 marks] draw an auto panning spotlight as a wireframe cone

The spotlight is located at (0, 4, 2) and aims at (0,0,0) initially. The spotlight auto pans side to side (i.e., light position fixed but rotates from left to right and then from right to left continuously). The panning of the light can be turned on and off by pressing key s” . The spotlight has a cutoff angle of 30 degrees and an angular attenuation coefficient e= 1.

(f)  [3 marks] Phong reflection and shading

Implement the Phong reflection model and Phong Shading so that the bunny looks realistic and 3D. You need to compute vectors such as normals yourself.

(g) [3 marks] Tuning the light and material parameters

Experiment with different material and light parameters so that your bunny looks similar to the bunny below. Save one screenshot of your whole scene in which your bunny looks the closest to the bunny below. Don’t worry about the soft shadows and reflections in the example image. Just worry about how the bunny itself looks like.

 

Note that the above steps build on top of each other, in order. You need not  submit individual programs to correspond to these steps. If you can implement all the required parts, a single, complete program is sufficient. No skeleton code is provided.                     Submission:  Please  submit  a  zip  file  with  student  number  and  your  name  (i.e., 300000001_TerryFox.zip).  The  zip  file  contains  an  HTML,  a JavaScript, your best rendered  image  in  jpeg  format  .jpg,  and  a  README  file.  The  README  should acknowledge any help you have received and any discussion you have participated, and document any steps not completed, additional features, and any extra instructions needed for the TA to mark your assignment.