Advanced Computer Graphics: Laboratory Project

<< PREV | INDEX | NEXT >>

Task 1: Lighting

In this first part you will be implementing the lighting equation. Before starting on the solution, read through chapter 4 of the course book (Real-Time Rendering) for a thorough explanation of how lighting and shading works. Refer to the book as you work through this exercise if you get stuck.

You are to complete three tasks:

  1. Calculate the ambient lighting term.
  2. Calculate the diffuse lighting term.
  3. Calculate the specular lighting term.

Preparation

Build/run the application and familiarize yourself with the controls.

Open ‘carscene-1.fx’ in a text editor of your choice or double click the file in the solution view in Visual Studio under fxstudio/fx. The .fx file is physically located at:

(Working directory)/fxstudio/fx/

Description

Note that there are several techniques described in the effect;

The fragment shader ‘psLighting’ is used in all techniques applying lighting. This fragment shader computes the lighting equation by evaluating the functions ‘calculateAmbient’, ‘calculateDiffuse’ and ‘calculateSpecular’ and adding the results together. Since you will be implementing the lighting equation in this exercise, the terms are currently calculated using placeholder values; therefore, your render view should show a flat, white car:

Figure 1: Result of running the application with unmodified effect file.

<< PREV | INDEX | NEXT >>