Phong Lighting

Wednesday | Friday
Adding realism

Readings

Examples updates

Let's fetch this week's upstream changes.

$ cd ~/cs40/examples
$ git fetch upstream
$ git merge -X ours upstream/master

After this step, you will need to manually edit the top level CMakeLists.txt to add the new subdirectories.

$ tail ~/cs40/examples/CMakeLists.txt

add_subdirectory(w01-intro)
add_subdirectory(w02-opengl)
add_subdirectory(w03-cube)
add_subdirectory(w04-stack-texture)
add_subdirectory(w06-projection)
#add the lines below
add_subdirectory(common)
add_subdirectory(w06-lighting)

No texture symlink is required this week.

If everything went well, you should be able to go into your build directory and run make -j8 to compile the week 06 examples.

cd build
make -j8
cd w06-lighting
./lights

The L key toggles between per vertex and per framgent lighting. This uses two separate shader programs. The geometry is in a separate common folder and the Drawable base class has been modified slightly to support specular colors, drawing with multiple programs, and loading geometry data in a generic way. The Square and Sphere classes have been modified to add normal and tangent information per vertex. The tangent information is not used at the moment. A Cylinder class has also been added, but is relatively untested. Let me know if you experience problems with it.

Friday Examples

Let's fetch more upstream changes.

$ cd ~/cs40/examples
$ git fetch upstream
$ git merge -X ours upstream/master

After this step, you will need to manually edit the top level CMakeLists.txt to add the new subdirectories.

$ tail ~/cs40/examples/CMakeLists.txt

add_subdirectory(w01-intro)
add_subdirectory(w02-opengl)
add_subdirectory(w03-cube)
add_subdirectory(w04-stack-texture)
add_subdirectory(w05-projection)
add_subdirectory(common)
add_subdirectory(w06-lighting)
#add the nmap directory below
add_subdirectory(w06-nmap)

Before compiling, you will need to add a symlink in your w06-nmap source folder.

cd ~/cs40/examples/w05-nmap
ln -s /usr/local/doc/textures data
cd ..

If everything went well, you should be able to go into your build directory and run make -j8 to compile the week 06 examples.

cd build
make -j8
cd w06-nmap
./nmap
We didn't get a chance to talk much about normal mapping in class. The learn openGL tutorial has a good summary of the primary methods on normal mapping used in the demo.