Starting from:

$30

CS680- Assignment 04: Shaded Rendering Solved

. Overview
In this assignment you will use OpenGL Shading Language(GLSL) to write your own vertex and fragment shaders to compute illumination and shading of meshes.

Basic Requirements
Generate Triangle Meshes (TODO 1):Use Element Buffer Object (EBO) to draw the cube. The cube provided in the start code is drawn with Vertex Buffer Object (VBO). In the DisplayableCube class draw method, you should switch from VBO draw to EBO draw. To achieve this, please first read through VBO and EBO classes in GLBuffer. Then you rewrite the self.vertices and self.indices in the DisplayableCube class. Once you have all these down, then switch the line vbo.draw() to ebo.draw().
Generate Displayable classes for an ellipsoid, torus, and cylinder with end caps. These classes should be like the DisplayableCube class and they should all use EBO in the draw method. PS: You must use the ellipsoid formula to generate it, scaling the Displayable sphere doesn't count
Set Normal Rendering (TODO 2): As a visual debugging mode, you’ll implement a rendering mode that visualizes the vertex normals with color information. In Fragment Shader, use the vertex normal as the vertex color (i.e. the rgb values come from the xyz components of the normal). The value for each dimension in vertex normal will be in the range -1 to 1. You will need to offset and rescale them to the range 0 to 1.
Illuminate your meshes (TODO 3): Use the illumination equations we learned in the lecture to implement components forDiffuse
Specular
Ambient
You’ll implement the missing part in the Fragment shader source code. This part will be implemented in OpenGL Shading Language. Your code should iterate through all lights in the Light array.

Set up lights (TODO 4): Set up lights:Use the Light struct which is defined above and the provided Light class to implement illumination equations for 3 different light sources.
Point light

Infinite light

Spotlight with radial and angular attenuation

In the Sketch file Interrupt_keyboard method, bind keyboard interfaces that allow the user to toggle on/off specular, diffuse, and ambient with keys S, D, A.
Create your scenes (TODO 5):We provide a fixed scene for you with preset lights, material, and model parameters. This scene will be used to examine your illumination implementation, and you should not modify it.
Create 3 new scenes (can be static scenes). Each of your scenes must have at least 3 differently shaped solid objects
each object should have a different material at least 2 lights

All types of lights should be used

Provide a keyboard interface that allows the user to toggle on/off each of the lights in your scene model: Hit 1, 2, 3, 4, etc. to identify which light to toggle.
6. Texture Mapping 
Set up each object's vertex texture coordinates(2D) to the self.vertices 9:11 columns (i.e. the last two columns). Tell OpenGL how to interpret these two columns: you need to set up attribPointer in the Displayable object's initialize method.
Generate texture coordinates for the torus and sphere. Use “./assets/marble.jpg” for the torus and “./assets/earth.jpg” for the sphere as the texture image. There should be no seams in the resulting texture-mapped model.
Extra Credit 
7. Normal Mapping 
Perform the same steps as Texture Mapping above, except that instead of using the image for vertex color, the image is used to modify the normals.
Use the input normal map (“./assets/normalmap.jpg”) on both the sphere and the torus.
8. Artist Rendering (advanced) 
Look at Section 10.3, “Artistic Shading” in Shirley/Marschner (4th ed.).

Implement line drawing in shader code
Implement cool-to-warm shader code
Programming Style
For any modified or newly added source file, you should include a brief explanation about what you did in this file at the file heading and add your name to the author list. Your code should be readable with sufficient comments. You should use consistent variable naming and keep reasonable indentation. In python, we prefer to use reStructuredText format docstring, for more details about this format, please check here.
2. Resources
2.1 Start code
A Python Program skeleton, which includes basic classes, methods, and main pipeline, is provided for you. You are expected to complete the parts marked with TODO. There are comments in the skeleton code that will help guide you in writing your own subroutines.

2.2 Environment Setup
Installing the appropriate programming environment should be covered in a lab session. For more step-bystep instructions, please check the environment set up on Blackboard.

2.3 User Interface
The user interface to the program is provided through mouse buttons and keyboard keys.

Left Mouse Dragging: Rotate the camera

Middle Mouse Dragging: Translate the camera

A: Toggle Ambient Light

D: Toggle Diffuse Light

S: Toggle Specular Light

Left Arrow: Go back to last scene

Right Arrow: Next Scene

1,2,3, ...: Toggle lights in current scene

2.4 Video Demo
We prepared a video demo for you, hope this can help you better understand your tasks and speed up your debugging process. Please check it on the Blackboard.

More products