The previous post in this series began to talk about writing custom Effects for WPF. We looked specifically at ColorComplementEffect, an effect with no parameters. In upcoming posts, we'll get into the details of multi-parameter effects and other specifics. But in the meantime, I thought it would be useful to post a sample VS project and a ClickOnce application from that project for folks just itching to get going.
The app looks like this:
It's nothing fancy, mostly XAML and, in fact, the way the code and structure and UI are constructed are not conducive to hosting all effects now and forever (a more sophisticated hoster of effects would make a lot more use of metadata and reflection to allow arbitrary effects to be applied and parameters to be tweaked). However, this definitely does the job in terms of showing how Effects are used and written. There are two projects in the solution -- one is a MyEffects library, and the other just an EffectTest application that uses Effects from MyEffects.
Note that this code and app are specific to the .NET 3.5 SP1 Beta release. We already know of at least one breaking change in the RTM version that will require this code to be modified (just slightly).
Without further ado:
One thing to be aware of in the solution. The compiled pixel shaders are included as resources in the MyEffects library. I did the fxc.exe compilation outside of the project system. As mentioned in the last post, we have a VS BuildTask in the works that will let this be part of the project system, but until then, I included the compiled bytecode directly.
Have fun! More to come...