CSE 558 (Winter 2011) Beyond Programmable Shading

Beyond Programmable Shading

Homework 1 (due Monday January 24, 2011)

Note 1: The homework needs to be solved individually - no teamwork on this project.

Note 2: You may read/copy text and code from any source *except* other students in this class; however, you must cite all of your sources.

Note 3: Please subscribe to the class mailing list if you are not yet subscribed!

This is the "programmable shading" assignment that serves as a warm-up for the "beyond proragrammable shading" projects coming later in the term. The goals of this assignment are to give you experience using DirectX11's 3D rendering pipeline, writing shaders, and implementing a few rendering effects.

Starting / Skeleton Code

You will find starting code in /cse/courses/cse558/hw1_skeleton_cse558.zip. Everyone must use this code as a starting point. This zip file contains a complete Microsoft Visual Studio 2010 solution and project that should build-and-run on your course computer with no changes. This skeleton code is adapted from an introductory example in the Microsoft DirectX SDK.

Project Details

The project code provides a basic ambient-shaded scene and you add lighting, texture, shadows, etc:

1) Add per-pixel phong lighting. (15%)

2) Add a large ground plane under the character (10%)

3) Implement standard shadow mapping for a single light for all objects in the scene. You may implement either a directional light (orthographic projection) or spotlight (perspective projection). (50%)

4) Implement "poor-man's anti-aliasing" by implementing a post-process 3x3 Gaussian blur in a pixel shader. Add a control to the UI to enable/disable this feature. (25%)

Extra credit

- Add a high-frequency mipmapped texture to the ground plane (checkboard, small rocks, etc) and enable anisotropic trilinear filtering. (+5%)

- Add at least 10 spheres (that rest on the ground plane and are approximately half the height of the person. Implement an alternate shadow method (selectable via the UI) that ray traces shadows in pixel shaders instead of using a shadow map, where the spheres are the only shadowing/occluding geometry. Note that ray tracing is only to be used for shadow rays---all "eye rays" are to be rasterized using the same renderer as the main part of the assignment. (+10%)

- Implement ray-traced reflections of the entire scene (spheres, groundplane, and character) in a pixel shader. (+10%)

- Implement a basic post-process depth-of-field effect that uses the depth buffer to compute each pixel's blur size based on camera lens parameters (computing the circle-of-confusion), then performs a varying-width blur across the image to create the final defocus-blurred image. (+10%)

- Implement morphological anti-aliasing (another post-process anti-aliasing technique). The original paper is here, but there are a number of articles online about how to implement it. (+10%)

Submitting Your Homework

Please submit a zip file containing a screenshot image from your final renderer, a README.txt file that describes which features you've implemented and documents your sources (books, web pages, etc), prebuilt binaries and your buildable source code (MSVS solution/projects, shaders, including shaders, models, textures, etc.). Note that your binary will likely depend on external shaders, meshes, textures, etc. so make sure the directory structure is correct in your ZIP package such that double-clicking the binary runs correctly. Upload your zip file to the Catalyst DropBox for this course at https://catalyst.uw.edu/collectit/dropbox/summary/alefohn/13901.

Grading

I will evaluate your project by running your submitted executable on my "official CSE558 computer" and evaluate each of the features. I will also read your shader code and skim through your C++ code. The points for each portion of the assignment are listed above in the assignment description. Please test that your executable runs by double-clicking it before submitting.

Tips (especially for those use to OpenGL 1.x)

If this is your first experience with DirectX, read through the skeleton code carefully and look through some of the "resources" below before starting.

If you are used to OpenGL 1.x, one big change is that the matrix stack is gone. Instead you simply use C++ matrix/vector libraries to build your matrices, bind those matrices as shader arguments, and transform each vertex in the vertex shader. You'll notice that DX provides C++ matrix/vector classes for this purpose of setting up shader inputs.

If you are used to seeing glBegin(GL_TRIANGLE) and glEnd(GL_TRIANGLE), you won't find an equivalent to those constructs either. Instead you'll that all vertices for a mesh/model are stored in a single vertex buffer (a flat array), an index buffer is created to specify the triangles (indices into the vertex buffer), and then both of these are bound to the DX API before drawing. The actual work begins by calling d3dContext->DrawIndexed(...).

One nice thing about DirectX is that there is no hidden/global state retained by the API. All state is explicitly bound to C++ Direct3D objects, especially the D3D "context" object.

Get to know the DXUT toolkit (already included in the skeleton code). DXUT is the DX equivalent of GLUT (for OpenGL) but provides quite a bit more: camera classes, UI widgets, mesh classes, and more. The DX SDK samples (see next item) are a good way to learn DXUT.

Try one of the shader debuggers listed below (AMD's or Microsoft's)

Resources

The samples that come with DirectX SDK are a great resource. They are on your computers in "c:\program files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DirectX11\".

This online DirectX book has quite a bit of introductory information: http://wiki.gamedev.net/index.php/D3DBook:Book_Cover.

Microsoft's DirectX online documentation (reference, not tutorial): http://msdn.microsoft.com/en-us/library/ff476080(v=VS.85).aspx.

There are two different shader debuggers you can try: AMD's GPU PerfStudio 2 and Microsoft's PIX.

Basics of light shading and shadow mapping can be found in many introductory graphics books, including those by Akenine-Moller, Shirley, and others. And the web...

 

© 2011 Aaron Lefohn
Department of Computer Science and Engineering | University of Washington