You are currently browsing articles tagged shaders.

Morgan McGuire’s page is the only twitter feed I follow (though Marc Laidlaw’s Trog Act Manly But is darn tempting), as he simply offers up worthwhile links on computer graphics and on game design. Strangely, though, some ideas cannot be expressed in 140 characters. So, here’s our first guest post, from Morgan:

When experimenting on a new algorithm, I have a zillion variations I’m testing packed into one shader and a lot of #ifdefs and helper functions to switch between them.  Often you need the invoking C++ code to line up, and I’m always forgetting to switch the routines in both the shaders and C++ to keep them in sync…

I just realized that I can put my #defines in a header and include the exact same header into HLSL, Cg, GLSL, CUDA, and C++ code, since they have exactly the same syntax.  So I now have both C++ and GLSL files that say #include “myoptions.h” at the top.  Cool!

(Ok, my GLSL infrastructure adds #include to the base spec, but I assume everyone else’s does too).

Tags: ,