Tuesday, March 29, 2011

GPU Course Projects

This semester I am teaching GPU Programming and Architecture at the University of Pennsylvania. My students have chosen some interesting projects ranging from rendering to simulation to GPU computing and beyond. Here are their blogs:
I'm sure they would love to hear ideas from outsiders so don't be shy!

Wednesday, March 9, 2011

Our Book Cover

We are pumped that the cover for our book is ready:

When you work out a book contract, one thing you can negotiate is say on the cover. We did not negotiate for this - thankfully, we didn't need to. Our publisher was nice enough to take our suggested cover pretty much as is. We, of course, can't take credit for the work; I would be quite embarrassed to reveal the original artwork I created. Instead, two of our fellow AGIer's, Fran Kelly and Jason Martin, did a bang up job designing the cover and creating the artwork. Even cooler, they used a product we work on, STK, to create the visuals. Total overkill perhaps, but cool nonetheless.

Friday, March 4, 2011

GLSL Engine Uniforms Revisited

Game Engine Gems 2
A few months back, I mentioned my two articles in Game Engine Gems 2. Now that the book is available, I want to revisit a piece of advice in one article, A Framework for GLSL Engine Uniforms.

This article is about implementing a framework for GLSL uniforms that are automatically set by the engine. A shader author simply declares the uniform to use it. Since the engine has a list of names for all engine uniforms, it can identify what engine uniforms a shader uses, and track them accordingly. A shader author is ensured that the engine will update a uniform to the appropriate value before the shader is invoked. In addition to standard stuff like transformation matrices, these uniforms are also used for more engine-specific values, e.g., time, sun position, etc.

At the end of the article I suggest:

If you are up for parsing GLSL code, you could also eliminate the need for
shader authors to declare engine uniforms by carefully searching the shader's
source for them. This task in nontrivial considering preprocessor transformations,
multiline comments, strings, and compiler optimizations that could eliminate
uniforms altogether

Well, I should have thought more about this because you do not need to parse GLSL for uniform names to eliminate the need to declare engine uniforms. Foruntently, it is much easier; since glShaderSource takes an array of strings, just have one string contain the declarations for all the engine uniforms and let the compiler throw out the unused ones.

I've used this approach for a few months now and am quite happy with it. At first, I was not sure about how useful it would be, but I've found it makes copying and pasting code among shaders much easier because I don't have to remember to declare engine uniforms.