In response to some people asking me how to start learning shader programming, I made a list of some resources that could prove helpful when learning HLSL:
The Shader Series, found on creators.xna.com are a very good set of articles and samples, that explain the basic knowledge needed to understand and write shaders in HLSL.
- Shader Series – Introduction
- Shader Series – Fixed Function to Programmable Pipeline
- Shader Series – Coordinate Systems
- Shader Series 1 – Vertex Lighting
- Shader Series 2 – Textures and Colors
- Shader Series 3 – Per-Pixel Lighting Sample
- Shader Series 4 – Materials and Multiple Light Sources
Riemer Grootjans also has a series of tutorials on HLSL, which can be found on his site.
A good book on shaders is The Microsoft DirectX 9 Programmable Graphics Pipeline by Kris Gray. I found this book extremely useful, with very good explanations, and nicely structured. The code samples, however, are in C/C++, but for most people that shouldn’t be a problem.
Another good place to find information on shaders are the web pages of the two big GPU manufacturers, NVIDIA and ATI. Each site has a section devoted to developers, which are great places for everyone, beginners are advanced users alike. Both sites provide code samples, documentation, tools and SDK’s. Out of these, my favorites are NVIDIA Shader Library, NVIDIA SDK and ATI SDK. Most important, these site contains lots of articles and presentations from various conferences, which explain a wide range of effects and techniques, and how they are achieved on the GPU. Admittedly, most of them do not provide HLSL code, but the idea and algorithm is almost always more important than the code itself.
Finally, as a recommendations for those who want to learn HLSL, try to examine as many samples as possible, and play with the HLSL code to see what happens when changing values, until you understand why things happen the way they do. Don’t start by doing HDR Lighting, or Relief Mapping. Start with the small tutorials, and understand what happens and why before going on to the more spectacular samples. Last, but not least, don’t be afraid to look at C/C++ samples. The DirectX SDK contains some very good samples of HLSL. I know, they’re written in C/C++, but the shader code stays the same when going from C++ to XNA.