{Solved} Lighting and shading Solution

$35.00 $24.00

  Study the given code. Note that the camera can be rotated around the central object using mouse drag. Observe how screen coordinates from the mouse are converted into rotations. The exercises below ask you to implement simple lighting computations in OpenGL.   Switch on lighting in the given program.   (a) Add 1 point…

You’ll get a: . zip file solution

 

 
Categorys:

Description

5/5 – (2 votes)

 

Study the given code. Note that the camera can be rotated around the central object using mouse drag. Observe how screen coordinates from the mouse are converted into rotations. The exercises below ask you to implement simple lighting computations in OpenGL.

 

  1. Switch on lighting in the given program.

 

(a) Add 1 point light source [2 marks]

 

In programmable OpenGL, lighting computations are done entirely in the shaders. A point light source is identified by the location of the light and its color. Add these variables to your vertex shader as uniforms and pass-on certain values from your C-program.

 

  • Replace the cube object with a sphere object. Also generate normals. [4 marks]

 

Lighting computations (e.g. in the Phong model) require normals along with vertex data. Replace the cube object with a sphere object. Use spherical parameterization to compute vertices. Also compute per-vertex normals (remember to normalize the normals – i.e. make sure normals are unit vectors in all your computations).

 

  • Use Gouraud shading for diffuse lighting. [4 mark]

 

Gouraud shading is per-vertex lighting. Add lighting computations in your vertex shader to perform diffuse shading. Also add a small ambient component so that perfectly black regions can be seen.

 

  1. (a) Use Phong lighting to render the sphere with specular highlights. [5 marks]

 

Modify your vertex shader to include all three lighting components: ambient, diffuse, and specular. Use Phong exponent = 128.

 

  1. (a) Modify your shaders to render the sphere using Phong shading. [5 marks]

 

Use per-fragment Phong shading to generate a better looking Sphere. Again use the Phong lighting model with all three components.

 

 

Deliverables

 

  • C/C++ code (make sure to upload full Cmake Project).

 

  • 2~3 page PDF Report written with Latex/MS Word. Use the acmlarge option (single column) (see sample-acmlarge.tex if writing with Latex).

 

 

 

 

 

 

Total marks for this assignment: 20 marks

 

 

 

Bonus (bonus marks to a maximum of 5 will be awarded for the following features. This part is completely optional)

 

  1. Create a Toon shader for artistic rendering (refer to section 10.3 in the course book). [3 marks]

 

  1. Include two light sources in your program and show the effect using specular highlights. [2 marks]

 

 

 

 

 

 

 

Note: Your code should be written by you and be easy to read. You are NOT permitted to use any code that is not written by you. (Any code provided by the TA can be used with proper credits within your program)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 2″ of 2″