Recent Changes - Search:

CS679-2007 Web

Login

Shaders

1.  Shaders and Shading Languages

The goal of this part of the class is to get you to think about using the graphics hardware by writing shaders (which will require you to learn a bit about a shading langauge, or two).

Rather than doing long lectures in class, we'll try more of a "student directed learning" approach, where we'll let you play around more, and listen less.

Also, the idea here is that you can figure out the basics yourself, and we'll use class time at the end of the assignment to learn about fancier stuff that people figured out.

2.  Tools

We recommend that you use the GLSL shading langauge, since its easier and we can recommend readings. However, if you want to use HLSL shading language (which is more common in the gaming industry), you can do that - you'll just be on your own.

In fact, if you pick one shading language, we will FORCE you to look at another one!

We strongly encourage you to use the "RenderMonkey" shader IDE (which is available on the CSL computers, or is available free from ATI). RednerMonkey lets you experiment with shaders without having to build up an C++ program to set up the universe. It does take a little getting used to. RenderMonkey works for both GLSL and HLSL, and has a ton of examples to look at.

3.  Recommended Readings

You need to read about 2 things: 1) an overview of shaders and what they can do and how they do it, and 2) the nuts and bolts of using a specific, real, shading language to actually get your shaders on the screen.

  • The OpenGL Shading Language by Randy Rost, et. al. This book is the reference for one particular shading language that (arguably) is not the one in widest use. However, the book is an excellent resource at not only describing how shaders work, but also at discussing a lot of good real-time rendering tricks.
  • The LighHouse3D tutorial on GLSL http://www.lighthouse3d.com/opengl/glsl/ There are probably a zillion "here's how to write a shader tutorials" out there on the web, but this one is very thorough covering both the basic concepts as well as the nitty gritty details of getting one into a program.

These references are more general technical:

  • John Montrym and Henry Moreton, The GeForce 6800, IEEE Xplore link
  • John Owens, Streaming Architectures and Technology Trends (Chapter 29) GPU Gems 2, Online PDF
  • Emmett Kilgariff and Randima Fernando. The GeForce 6 Series GPU Architecture (Chapter 30). GPU Gems 2 Online PDF.
  • Andrews J. and Baker N., Xbox 360 System Architecture IEEE Micro March-April 2006 IEEE Explore
  • Owens et al., A Survey of General-Purpose Computation on Graphics Hardware, Computer Graphics Forum", Volume 26, 2007. Download link

The following is an out of date description of rendermonkey (talking about doing assembly language programming with it). It does not count as one of your two readings, but you can flip through it since it might help give you some ideas as to how RenderMonkey works.

4.  A note on terminology

In the assignment, I refer to writing a "shader". Technically, you usually don't write one shader, you write at least 2 (a vertex shader and a fragment shader), and maybe more (one for each pass). Plus, very often with a shader, you also need to make textures and have some code logic to achieve the multi-pass drawing.

So, when I say "write a shader" I really mean "write a set of shaders, and the accompanying other stuff that together achieves an effect."

5.  A cautionary note...

This assignment requires you to look at other people's code (tutorials, sample code, a shader to translate, ...) Remember to give proper attribution!

6.  The Assignment

This assignment has 3 small pieces, and an extra piece.

  1. A warmup - where we ask you to just write a simple shader (or 2) just to see what its all about.
  2. A translation - where you find a shader written in some other shading language and translate it to work in the shading language that you have picked. The goal of this part is to force you to read a more complicated shader to understand it, and also to see that the shading languages are not that different.
  3. A contest - where you need to make the most creative shader that you can think of - we'll give a prize for the most creative one. the goal of this part is to let you really think about what you can do with Shaders, and to be creative. Remember, the focus here is on creativity, so simply copying (or re-implementing) an existing thing you find on the net isn't as valuable.
  4. The extra piece - in looking around, you will probably discover some really cool uses of shaders out there. You need to make a list of the (at least) 5 coolest uses of shaders that you can find.

For each parts, you may turn in either a rendermonkey project file (be sure to include all the associated assets, such as models and textures), or a complete visual studio project with all the source code and everything we need to build and run it (including documentation).

You may choose to do the assignment in GLSL or HLSL. All of your shaders must be in this language, and the language you choose to translate from (in 2) must be different).

You must turn everything in to the TA by 1pm on Tuesday, April 24th. If your assignment isn't turned in by then, you will not be considered in the contest, and your grade will be penalized.

There is a preliminary milestone: before class on Tuesday, April 17th you must send email to the TA describing your progress in writing the first shaders for part 1. You must attach a picture of the output of a shader that you wrote. It doesn't have to be complete, it just has to show us that you really have begun working on shading.

Your list of cool shaders should also be started (and have at least 3 things on it) before class on April 17th.

6.1  Part 1 - Shading Warmup

For this part, we ask that you write a "shader" (really a set of shaders) that does the following:

  1. does something in both the vertex and fragment shader that is different than the standard pipeline
  2. uses (at least one) texture map
  3. does some procedural texturing (even if this is mixed in with the texture)
  4. is effected by the lighting (even if it has its own light controls)

If you prefer to turn in 2 different "shaders", that's OK (i.e. that uses the texture map, and one that uses procedural texturing).

Remember, you must send your signs of life to the TA by April 17th.

This part will be evaluated by seeing how completely you meet the requirements, as well as how interesting your shaders are (both technically and artistically).

Your shader must work on both a simple object (a sphere) and complex objects.

6.2  Part 2 - Translating Shaders

For this assignment, you need to find some shader written in another shading language, and translate it to the shading language you have chosen to use.

Here's a great source of a lot of HLSL and CG shaders ready to be translated to GLSL:

This part will be evaluated by how well your shader works, and how complicated it is. If you translate a really complex shader (which would force you to figure it out), it will be worth more than a simpler one.

The major shading languages are not that different. Once you've learned one, its easy to read another. You might need to read up a little on the second one.

Note: the shading languages are similar enough that there are automatic translation programs. You shouldn't try to use one. The purpose here is for you to learn to read a second shading languages, and to look at a complex shader that someone else wrote.

Be warned: a lot of shaders out there are not well documented, so you'll need to think through how they work.

If you make simplifying assumptions on your shader, be sure to state them in your documentation.

6.3  Part 3 - The contest

Here's your chance to make something cool - come up with the coolest shading effect you can think of! Your effect should work on a variety of geometry, but you can tell us what the assumptions are (be sure to give us at least a simple object and a complex object to test it on).

Note: if your shader is a "full-screen" shader (e.g. it works to a screen aligned polygon that is the size of the screen), that is an OK special case. Be sure to explain

We will give a prize to the most creative shader. We may give out more than 1 prize, and we might give out special prizes for technical and artistic merit, independent of creativity.

In terms of evaluation, we will give your grade based on how creative and technically challenging your shader is (with an emphasis on the latter). Your documentation is also very important: you will need to explain your shader well. This will include describing it in an in-class presentation.

6.4  Part 4 - The Cool Ideas list

Make a list of the coolest shaders that you come across while doing this assignment. We'll want to talk about them in class.

You should make a Wiki page in your personal space with the list on it. Keep the list ordered by coolness (the coolest one at the top). Please put links to where these shaders came from if possible so we can check them out too.

By April 17th, you should have at least 3 cool shaders listed. Send email to the TA with a link to your Wiki page.

6.5  What to turn in

Prior to class (9:30) on Tuesday, April 17th:

Send email to the TA with your signs of life of your own shader (including a picture). Also, include a link to your cool shaders list.

By the final deadline (April 24th, 1pm):

  • Everything needed for us to run your shaders (there should be at least 3). You may turn this in by placing it in the Wiki pub directory and linking to it, or putting it in some other directory readable by the TA and telling her how to get it.
  • Documentation for your shaders. (you can put this on the Wiki, or put files in with the shaders themselves.
  • Your Cool Shaders list (that you have already described to the TA by the 17th) should be fully populated.

Before the deadline, you must send email to the TA explaining where all this stuff is.

6.6  Collaboration

Everyone must do this assignment, and turn in their own work. You may discuss the assignment with others, and help each other out.

7.  The Shader Jam Session

One class (tentatively Thursday, April 26th), we will devote class to looking at people's shaders. Come to class prepared to explain your shaders.

A jury (including the TA and instructor and some others) will pick a subset of the shaders as contest finalists. Each finalist will have 3-5 minutes to explain how their shader works to the class.

Note: you must be in class on the Shader Jam Session day in order to win the contest.

We will also pick some of the other shaders (from parts 1 and 2) for people to explain to class.

History - Print - Recent Changes - Search
Page last modified on January 16, 2008, at 05:29 PM