assignments-shaderpractice

Shader Practice

Since we’re learning about shaders in class, we figure that you want an opportunity to try writing them. There’s something particularly fun about making a whole bunch of processors on the GPU do a lot of computation for you.

Besides, for project 4, you will need to make use of shaders. This practice assignment is meant to give you practice working with them, and to make sure you have the mechanics ironed out.

By Tuesday (11/18) you need to send Blayne an email with the following 4 things attached:

  1. A vertex shader that you’ve written (as a text file)
  2. A fragment shader that you’ve written (as a text file)
  3. A screen shot of your shader in action
  4. A screen shot of an OpenGL program that you’ve compiled yourself that uses a shader.

Number 4 is meant to make sure you can actually get the libraries to work. Its pretty trivial since you can look at Main.ShaderTools and just download my program and compile it.

You can just write the shaders in a text editor and try them out with my sample program. However, we recommend that you try using RenderMonkey (see below) since it can make shader development easier. Also, it will give you lots of example shaders to look at and learn from.

Note: if you want to write your shaders in a language other than GLSL, you’re kindof on your own. And you’ll need to figure out how to make a program use them. And the shading languages are very similar: there isn’t enough difference between GLSL and HLSL or Cg (as far as doing things for this class)

For this assignment, we don’t care too much what your shader does. It has to be different than the simple example shader that I gave in the sample code. Try to do something cool. We recommend you try something that involves lighting, since you’ll need to do that for the project. A good thing to try: make a pattern (like a checkerboard) that is properly affected by the light.

Chapter 15 of the OpenGL red book gives a very basic introduction to GLSL. (if you don’t have a 6th edition red book, a scan of Chapter 15 is available on Learn@UW). We’ll also provide Appendix I of the Redbook (also in the readings directory and Learn@UW) which is a reference for GLSL.

You’ll probably want to look at example programs / web tutorials. Here are some that I’ve found (if you find others that you think are good, let us know)

The GLSL course at typhoonlabs is good - almost as good as having the GLSL book.

RenderMonkey

RenderMonkey is an IDE (integrated development environment) for writing shaders. It has a text editor, an integrated compiler, and a preview window. It makes it easier to experiment with shaders - all you need to do is write the shader code, and RenderMonkey lets you experiment with different geometry easily. It also lets you control the parameters of the shader (like colors) interactively.

There are other shader IDEs, many of which seem to have better features. But the reason we’re recommending RenderMonkey is that 1) its free, and 2) it supports GLSL. It also comes with a library of examples to look at.

On the down side, there have been stability problems in the past, and it doesn’t have lots of features to help you write the shaders.

RenderMonkey is installed on the CSL Windows machines. You can download a copy for your own computer from http://developer.amd.com/gpu/rendermonkey/Pages/default.aspx. Even though RenderMonkey comes from ATI (now part of AMD), it seems to work fine on NVidia hardware.

We had some advice on getting started with RenderMonkey on last spring’s course web.

Note: you don’t have to use RenderMonkey. In fact, even if you use rendermonkey, eventually you will need to copy your shader code into your own OpenGL program.

We strongly recommend that you at least try RenderMonkey to see if you like it as a way to experiment with shader programming.

Page last modified on November 12, 2008, at 10:13 AM