Sierra Bravo Corp
On This Page
Html Agility Pack
Visual Studio 2010
Visual Studio Extensions
Scott Guthrie (msft)
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way
Copyright © 2013
This work by
is, unless explicitly stated in the article, available under the
Creative Commons Attribution 3.0 United States License
Pick a theme:
Discreet Blog Blue
Movable Radio Blue
Movable Radio Heat
Wednesday, March 18, 2009
Silverlight 3 Shader Effects
- Wednesday, March 18, 2009 5:41:54 PM (Central Standard Time, UTC-06:00)
With the release of Silverlight 3 Beta we can now run PixelShader effects on any control. This can produce some powerful stuff as shown during the Mix 09 Keynote this morning. I delved in as fast as I could to find out how to make your own and work with them in VS.
I downloaded the WPF shader library from
. I only imported the ShaderEffectLibrary so far, I have not tried the transition one.
I simply copied the EffectFiles, ShaderSource and EffectLibrary.cs files into my project and tried to compile. Issues I ran into
UIPropertyMetadata needs to be replaced with PropertyMetadata
Color.FromScRgb needs to be replaced with Color.FromArgb and it's inputs run through Convert.ToByte
MagnifyEffect.cs and SwirlEffect.cs reference classes that do not exist in Silverlight like the Vector class. I could have got them from reflector but in sake of time I didn't (that and being able to release this code)
Getting the ps resources required a minor change to the Global static class. Basically changing the path to do a Relative URI lookup.
The basics here for doing your own shader effects is included save 1 thing. You need the DirectX SDK to compile your HLSL code. You can add a new build event or do it from the commandline. This is a good tutorial on how to do it
So the basics of doing your own Pixel shader in Silverlight is damn near identical as WPF. You inherit from the ShaderEffect class, load your compiled HLSL bytecode resource and expose any properties you need to modify as dependency properties.
Attached is my ugly but working example. I couldn't find anyway to bind to properties on an effect so I had to just do it by event.
Wednesday, March 18, 2009 9:03:53 PM (Central Standard Time, UTC-06:00)
Where is the main RSS feed for this site? I'm just seeing the blog roll and the categories.
Wednesday, March 18, 2009 10:15:29 PM (Central Standard Time, UTC-06:00)
It's in the meta data. I guess I'm so used to having it in the URL bar in firefox I forgot to put an actual link in.
All comments require the approval of the site owner before being displayed.
(will show your
Comment (Some html is allowed:
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u
) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.
Enter the code shown (prevents robots):
Live Comment Preview