Assignment 2: Normal Mapping

CMSC 491/691, Spring 2012

Due Tuesday, March 13, 2012

Assignment

For this project, you should create a simple OSG test of flowing water. Use the normal map flow technique described by Alex Vlachos in his SIGGRAPH 2010 course notes on Water Flow in Portal 2, coupled with Mikkelson's derivative map technique to avoid needing model tangent vectors. Use a physically-based Blinn-Phong shading model with a Fresnel-modulated environment reflection for your water surface. I'm expecting "programmer art", not a full artist-quality game level.

691 students

Your project should include some ability to interact with the water, either by changing the flow field or the normals. For example, flow changes or ripples for an object moving through the water, or response to something dropped into the water, bullets shot into the water, ... You can decide the kind of interaction and the implementation method. Be sure to describe it clearly in your readme.

What to turn in

Submit your work to your class bitbucket repository. Submit your project source, along with any textures or models I will need. If it'll be recreated if you move or delete it, don't check it in. I recommend doing a pull/update of the directory, locally checking in working or partially working files early and —I'll grade the final verison.

Check in a readme.txt file telling me what external sources you used, what you did for your assignment, and what I should notice. Check in all of your source code files, and anything else that cannot be regenerated from them, including any external textures or models. Do not include any compiled object files, libraries or executables. They won't do me any good, and can lead to strange hard to find bugs when compiled code not corresponding to your current source is resurrected from the repository. Do not package all of your files up into a single archive. CVS has limited ability to deal with binary files, and you'll quickly end up using more space than you think you're saving.

If you need your quota increased (now, or at any time during the semester), let me know.

External help

Like the last assignment, I am expecting you will need make heavy use of web resources and sample code. As always, document your sources.

Tips

Most of the work in this assignment is in constructing a fragment shader for your water. Development will go much easier if you have a way to reload your shader without restarting your application. My sandbox applicaton has an UpdateCallback that watches for changes to the shader source file, but a far easier approach is to just have an event handler that reloads the shader when you press a key.

There are many sites on the web with information about writing GLSL shaders, and samples you can use. In addition, you may want to refer to the GLSL specification.

There are a couple of simple but particularly effective shader debugging techniques I use all the time. The first is to copy some vector value into the output color and return, then try to interpret what the colors mean. It is often helpful to scale or bias the vector to get meaningful colors, since anything below 0 will look the same as 0, and anything larger than 1 will look the same as 1. The second method is particularly effective for float data, using something like this for the output color: vec4(-sign(x), sign(x), abs(x), 1). This will be green to cyan if the number is positive, red to magenta if it is negative, and black only if it is exactly 0. By subtracting constants from x, you can tell more about its value that pure color alone.

Objective

One common approach when faced with a new problem is to see if there are other ideas out there that can be combined to do what you need. In this assignment, you will be combining the Valve water flow method with tangents computed with the GPU derivative instructions and a physically based shading model. In addition, some of these presentions tell you what they did, but sometimes glossing over significant details. You may need to do some additional research to figure out exactly how it is supposed to work. No one has combined these pieces in this way before, so learning from others is normal and expected. Just be sure to document what sources you used.