Wolfgang F. Engel
Welcome to the latest volume of ShaderX! This all-new collection is packed with insightful new techniques, innovative approaches to common problems, and practical tools and tricks that will help you in all areas of shader programming. All of the articles evolved from the work and experiences of industry pros, and all of the sections were edited by shader programming experts. With the rapid advances in DirectX, OpenGL, and graphics cards, vertex and pixel shaders are becoming more widely used in high-end graphics and game development. The challenges of mastering these techniques can be daunting for new programmers, but with this comprehensive collection of ready-to-use techniques, they'll get up to speed quickly. And for the more experienced programmers, they'll find insights and tricks that will improve their efficiency and prevent redundancy. If you are involved in shader programming, this is a must-have reference for your collection.
I want to get started doing some game development using Microsoft's XNA. Part of that is Shader development, but I have no idea how to get started. I know that nVidia's FX Composer is a great tool to develop shaders, but I did not find much useful and updated content on how to actually get started.
What tutorials would you recommend?
SAMS's XNA Unleashed by Chad Carter is a great starting point for XNA and assumes little knowledge of game development practices or hard maths before you start. It has two chapters on basic and advanced shaders.
As a sidenote, keep an eye out on Google for WPF Shader tutorials, it now uses the same technology to allow customer shaders in WPF applications and tutorials for that I believe are largely compatible with XNA.
Development of shaders in XNA (which obviously uses DirectX) requires knowledge of HLSL or shader assembly. I'd recommend getting familiar with the former before diving into the latter.
Before writing any shaders, it's a good idea to get solid understanding of the shader pipeline, and attempt to get your mind around what is possible when using programmable shaders. When you're familiar with the life of a pixel (from source data all the way through to the screen) then understanding examples of shaders becomes a lot easier.
Next make an attempt to write your own HLSL which does what the Fixed T&L pipeline used to do, just to get you hands dirty. This is the equivalent of a "hello world" program in vertex/pixel shader world. When you're able to do that and you understand what you've written you're ready to go onto the more fun stuff.
As a next step you might want to simulate basic sepcular lighting in one of your shaders from a single light source. You can then adapt this down the track to use multiple lights. Play with colours, and movement of lights. This will help get familiar with the use of shader constants as well.
When you have a couple of basic shaders together, you should attempt to make it so that your game/engine uses multiple/different shaders on different objects. Start adding some other bits like basic bump or normal maps.
When you get to this stage, the world is your oyster. You can start diving into some funky effectcs, and even consider using the GPU for more than it was originally intended.
Good luck. If you get some shaders going, I'd love to see them :)