Create a gouraud light model - experiment with the


Task 1 - Setting up the space

Purpose:
a. Create a Gouraud light model
b. Experiment with the different component of light

To do:

1. Create a new project (you can use a project or code from previous assignments or tutorials.

Create three spheres close to each other so that you will be able to compare the results of the light models. For example positions the spheres at position 100, 0, 100 and at position 140, 0, 100. The radius of the spheres should be 10 or so, in order to be able to see the effect of the light models.

Colour the spheres red.

Set up a camera view position so that you can see the spheres. (e.g., 200,200,200) and set up the transformation matrix so that you can see the sphere.
Set up perspective projection (e.g., symmetric).

2. Create a camera class that will enable the user to manipulate the camera. You can use the camera code from the tutorial.
Keep with the camera three variables: position, look at vector, and up vector.

The user can manipulate the camera as follows:

Pitch operation - the up and down arrow keys will rotate the camera around the x- axis by +1 degree and -1 degree respectively.
Yaw operation - the left and right arrow keys will rotate the camera around the y- axis by +1 degree and -1 degree respectively.
Roll operation - the "a" and "d" keys will rotate the camera around the z-axis by
+1 degree and -1 degree respectively.
Forward motion - the "w" key will move the camera forward by 1 unit along the "look at" vector.
Backward motion - the "s" key will move the camera backward by 1 unit along the "look at" vector.
3. Display the spheres.


2. Task 2 - Create the Gouraud light model
1. Create the Gouraud light model
2. Use the Gouraud light model on the sphere at position (100, 0, 100)
3. Use the Object material
Material data is -
3.1.1. Ambient (0.2, 0.2,0.2)
3.1.2. Diffuse (0.75, 0.75, 0.75)
3.1.3. Specular (0.8, 0.8,0.8)
Level of shininess is 5 (allow user to change the level of shininess by)
„+? - increases the level of shininess by 2
„-? - decreases the level of shininess by 2 (note minimum should be 0)
4. Light source
Light source is white light
Light position is at 240,210,200

3. Task 3 - Create the Phong light model
1. Create the Phong light model
2. Use the Phong light model on the sphere at position (140, 0, 100)
3. Use the Object material
Material data is -
3.1.1. Ambient (0.2, 0.2,0.2)
3.1.2. Diffuse (0.75, 0.75, 0.75)
3.1.3. Specular (0.8, 0.8,0.8)
Level of shininess is 5 (allow user to change the level of shininess by)
„+? - increases the level of shininess by 2
„-? - decreases the level of shininess by 2 (note minimum should be 0)

4. Light source
Light source is white light
Light position is at 240,210,200

4. Light Models controls
1. Controls
Turning lighting model components on and off
„M? - turn ambient light off
„m? - turn ambient light on
„N? - turn diffuse light off
„n? - turn ambient light on
„B? - turn specular light off
„b? - turn specular light on

Scaling - enable scaling in the x and y directions using the i,j,k,l keyboard strokes -
Pressing on „i? means increment the scale in the x-direction by 0.5 increments;
Pressing on „j? means decrement the scale factor in the x-direction by 0.5. Min scale is 1;
Pressing on „k? means increment the scale in the y-direction by 0.5 increments;
Pressing on „l? means decrement the scale factor in the y-direction by 0.5. Min scale is 1;
Pressing on „r? resets the scale in the x,y,z directions to 1.

5. Task 3 - Compare the lighting models
1. Submit with the code project a short report about the two models:
What is the difference between the models with respect to computation
Compare the two models and state your opinion:
Which model has better visualization? Why?
Add image output of your assignment to demonstrate the differences.
To your opinion is it worth to use the Phong model from performance point of view and from programming efforts point of view?

6. Task 4 - Perform bilinear interpolation
2. Assume that vertex shader has computed the following values at vertices v1, v2, v3:
• V1 - position(5,1,0), (colour (0.9, 0.7, 0.1), normal(1, 3, 3)
• V2 - position(1,3,0), colour (1.0, 0.3, 0.9), normal( 2, 2, 2)

• V3 - position(6,5,0), colour (1.0, 1.0, 0.1), normal( 0, 2, 2)

Assume that:
• Colour and normal are declared as varying at the vertex shader and the fragment shader.
• The fragment shader is currently processing a fragment at position (4,2,0).

What values of colour and normal be transferred to the fragment shader by the GPU?

1786_Create the Gouraud light model.png

7. Bonus1 - Using half vectors
Modify your code in Tasks 2 and 3 and to show the models results when half vectors are used.
1. Controls
Switch to half vectors by using:
„H? - switch to half vector
„h? - switch back to normal view
2. Compare the results to those obtained in Tasks 2 and 3
Are you satisfied with the results
Add comparisons between the models.

8. Bonus2 - Create another light source
1. Create a second light source, which is a spot light.
2. The light cone angle should start at 35 degrees.
Allow the user to control the light cone by pressing
„0? - to increase the cone opening angle in increments of 1 degree. Max angle is 120.
„9? - to decrease the cone opening angle in increments of 1 degree. Min angle is 1
3. Allow the user to control the light focus intensity (angular attenuation)
„8? - to increase the light angular attenuation in increments of 3.
„7? - to decrease the light angular attenuation in increments of 3. Min value is 1 or 0
4. The spot light source should be aimed towards the centre of the sphere
5. The spot light should be positioned at (190, 200, 190)
6. Time permitted add radial attenuation

Request for Solution File

Ask an Expert for Answer!!
Computer Graphics: Create a gouraud light model - experiment with the
Reference No:- TGS01157969

Expected delivery within 24 Hours