Silverlight 3.0 Pixel shaders

rippleeffect Silverlight 3.0 beta1 was released today. One of the new cool features is the pixel shader support, allowing you to make some really cool effects. I managed to fairly quickly convert the WPF Pixel Shader library to a Silverlight library (except a couple of effects), and successfully apply them to any UIElement.

To save you the trouble, you can grab the source for the library from here: ShaderEffectLibrary.zip (44.65 kb)

To use it, simply import the assembly namespace:

xmlns:fx=”clr-namespace:ShaderEffectLibrary;ShaderEffectLibrary"

and then apply any effect to your elements by setting the Effect property:

<Grid>
    <Grid.Effect>
        <fx:RippleEffect />
    </Grid.Effect>
</Grid>

The supported effects are: BandedSwirl, Bloom, BrightExtract, ColorKeyAlpha, ColorTone, ContrastAdjust, DirectionalBlur, Embossed, Gloom, GrowablePoissonDiskEffect, InvertColor, LightStreak, Magnify, Monochrome, Pinch, Pixelate, Ripple, Sharpen, SmoothMagnify, Swirl, Tone, Toon, and ZoomBlu.

Note that you will need to have the Silverlight 3.0 bits installed to use this.

UPDATE: The WPF Pixel Shader library has now added support for Silverlight as well: http://wpffx.codeplex.com/

Also note that if you want to take advantage of the new GPU hardware acceleration to further enhance performance, this is an opt-in feature! To get it, you have to go to the hosting html page and set the following object parameter (update: This doesn't apply to pixel shaders which are software only):

      <param name=”enableGPUAcceleration” value=”true” />

Also note that pixel shaders are software only, and if you add a shader to your hardware accelerated element, it will switch back to software.

Comments (2) -

  • Hi Morten,  thanks for doing this..  I maintain he codeplex site for WPF effects and will be of course be merging it asap ( as soon as MIX is over) ...  I started yesterday, while at MIX and I am 2/3 of the way through,  I wonder why you did not do Magnify and Swirl, was there issues???   Feel free to ping me directly to discuss...  
  • I also had ported the library yesterday to test it out. There are only minor changes needed for most of them. Some rely on 3d classes that Silverlight doesn't have but could be added by hand.

    Check out my blog, I detailed the changes I had to make

Pingbacks and trackbacks (4)+

Add comment