Workbook 10: Shaders

Workbook 10: Shaders

This week, we'll learn to program the graphics hardware. In many classes, you have to start with this (since you can't draw a triangle without writing two programs). So far, we've let THREE.JS program the graphics hardware for us. So, now we're learning what it is doing.

Because of the dependency of this workbook on lectures, we will have a non-standard deadline. We will accept assignments until Tuesday, April 23rd (rather than Monday April 22nd). We will not be able to grade assignments turned in after this date.

Learning Goals

Students should learn to:

  1. Understand the basic organization of graphics hardware, and how programmability fits into it.
  2. Appreciate why shaders are the ways that they are and what you can do with them.
  3. Understand how the shader programming paradigm leads to specific, real implementations.
  4. Be able to write shaders in a real shading language.
  5. See how shaders are managed and integrated into a graphics application.

In one week, you won't master shader programming. But you will get to read and write some actual shader programs. This means that you not only have to learn the concepts, but you'll need to work with a new programming langauge (we'll use GLSL)

Unfortunately, I don't have a great tutorial on how to write shaders. Things tend to spend too much time on the issues in connecting shaders to real programs (which is generally taken care of by a higher level API, such as THREE). So, I am giving you a bunch of alternatives. We'll rely on lectures a lot.

What I recommend: - Get the basic idea of how shaders work from lecture. You can add to it by reading Chapter 17 of Fundamentals of Computer Graphics (FCG4_Ch17.pdf), or Chapters 2 and 3 of the Orange Book (see below). - Get the basic ideas of the GLSL language by looking at examples. Reading through Chapter 3 of the Orange Book or the Shaderific documents can be helpful (see below). - Get ideas of what you can do with shaders by reading more examples. Reading through some of The Book Of Shaders can give you lots of ideas. - While you're programming, keep the reference card and the Shaderific reference handy.

Note that for class:

  1. You must write some shaders. For this, you need to understand the basic concepts, and a little bit of the GLSL language.
  2. You must understand shaders (for the exam). We won't test you on GLSL details, but you will need to know the key concepts and be able to read shader code.

Here are the readings. You will need to read some of this.

Some alternative readings...


Pages 5 and 8 have required exercises on them. Each require you to write shaders.

Rubric for Grading

Bonus Points

Page 6 has a bonus point only exercise. You can also earn bonus points for making very creative shaders on Page 5 and 8.

Questions and the Exam

For this workbook, we won't be grading questions. However, we wanted to give you some questions to think about to help you make sure you understand the concepts and are ready for the exam.

List of Pages

Get Started

Everything begins on Page One!