WPF, Experiments with the CodePlex Shader Library

I took the Pixel Shader library from CodePlex which has a bunch of WPF 3.5 Service Pack 1 Pixel Shaders and I built a little toy application from it.

What the application does is to try and enumerate all the  ShaderEffects in the library and then take a picture of your desktop and apply the effects to it one at a time.

It does this by overlaying a full screen, top-most window which it then paints with an image which is a copy of the desktop. The current effect is then applied to that image.

You can see some examples below;

imageimage image

That’s a snapshot of my desktop with swirl, ripple and zoom blur applied.

In order to move to the next effect you hit SPACE and in order to quit the application you hit ESC.

For each effect I make an attempt to reflect on to the effect and try and guess what properties it has that might be parameters to the effect. Specifically, I try and find double, int, Color, Point and Size properties.

For each of those, I dynamically create a control which will bind to that property ( mostly using sliders ) so that you can manipulate that property whilst the effect is on the screen.

In quite a few places I end up using UI like this;


which is a bit clumsy but what it’s saying is;

I have no idea what a sensible max value is for the sliders below so I’ve guessed at “0 to 1” whereas if “0 to 100” or “0 to 360” seems to make more sense to you then tick that radio button to use that maximum value instead

I’ve dropped the source code here for download. Unusually, I’ve included the binaries as well to try and avoid you having to build them yourself. Some notes;

  1. This is distributed under the Microsoft Public License which you can read here. I don’t usually do this but I’ve included the pixel shader library from CodePlex as a binary reference and hence I’m passing on the license that comes with it. If you clear out the bin folder then this library will probably get deleted and you’ll then need to go get the source and build it yourself from CodePlex.
  2. This is using some C++/CLI so if you rebuild it you’ll need a C++ compiler for one project.
  3. This uses some databinding that feels a bit “wrong” to me but seems to work so if you were to pore over the source code (unlikely, I know) then bear that in mind.
  4. Sometimes my C++/CLI code to grab an image from the desktop fails with a GDI error. I’ve not figured that out but it seems to be a 5% case on my machine.

What I’d like to do is to add some buttons that automatically cause properties to be animated – I might post an update if I get that done.