Microsoft has just released a fantastic WPF Shader Effects library on CodePlex. Jaime Rodriguez posted more details about the library on his blog. Here are a couple samples effects from the library.
I encourage you to download a copy of the library and give it a try. Fun stuff.
Plus, keep your eyes open for more WPF Pixel shader news. Later this week there will be a new shader test harness released. One that makes it simple to test any DirectX shader snippet.
WPF and DirectX
It’s probably not a surprise to you that WPF uses the DirextX rendering engine. Building WPF on DirectX has many advantages for the framework. Ease of animation, rich color support and 3D support are just a few of the benefits that come to mind.
Microsoft is not sitting on it’s backside watching their competitors in the graphics field pass them by. Not at all. Microsoft is constantly improving the DirectX libraries. WPF, in turn, can use the new features of DirectX.
Shaders
A few years ago Microsoft add Shader support to DirectX. Shaders permit more flexibility in programming advanced GPU features. No longer is the graphic/game developer stuck with a few hard wired graphics algorithms encoded in the GPU. Instead you write a shader, have the GPU load the shader code and the GPU plugs your custom shader into the graphics pipeline.
Shaders come in a couple of flavors, pixel shaders which allow the manipulation of pixel data and vertex shaders with allow the manipulation of vertex data. Shaders are extremely fast, therefore modifying pixel data with a pixel shader is light years faster than prior methods.
WPF and ShaderEffects
Some of us were disappointed to find the the first release of WPF did not allow creation of shader or vertex effects. It took a couple of years, but Microsoft finally delivered on their promise to fix this oversight.
A DirectX shader can be written in assembly but in recent years shaders are more likely to be must be written in a C dialect known as HLSL (High-Level Shading Language). Note that there are other dialects for other graphic platforms (GLSL for OpenGL for instance). .NET 3.5 SP1 has magnificent support for shaders but first you must create the HLSL code. To use the shader in WPF you have to create a class that derives from System.Windows.Media.Effects.ShaderEffect.
See the CodePlex site for details on how to create a ShaderEffect class or follow Greg Schechter’s blog series.
Pixel Shader Effect Library
I’ve been working with the beta of the Pixel Shader Effect Library for a couple weeks now. There are some very nice effect included. I encourage you to download the effect library and give it a try.









…you may have realised that this is only part of the story…well to use your words part of that promise…
…currently only pixelshaders are supported…secondly only Version 2.0 is supported which has a lot of limitations (limited number of instructions is only one example)….furthermore you can have only one Effect at a time on each element ….hopefully this is going to change soon….
[...] effects were added in .NET 3.5 SP and they are getting some good comments in the blog world. The steps for creating a shader are somewhat confusing, [...]
I’m waiting for the day we can use Shaders in Silverlight so one can really start to port some of the small games in XNA over to the web too…