Wednesday, July 22, 2009

23 Pixel Shader Effects in Silverlight 3.0

 

Hi All,

Yesterday, I was just going through the Pixel Shader Effects in Silverlight 3.0. and found one interesting video on Channel 9 about WPF Effects library on CodePlex. This library is modified for “Silverlight 3” and contains 23 effects for Silverlight 3 as well. Below is a link for the same-

Video Link- http://channel9.msdn.com/shows/Continuum/WPFFXDemo/

Library Link - http://codeplex.com/wpffx

So, Download this library. It’s a .ZIP file. Extract it as per your preferred location and you will see a Folder SL, which contains a Library -

1) SLShaderEffectLibrary.

To see these effects Live, below is a table which I made with all “23 Pixel Shader Effects” -

List of 23 Pixel Shader Effects-

SR.NO. Pixel Shader Effect Name Snapshot of the Effect
1 Banded Swirl Effect Effect1
2 Bloom Effect Bloom
3 Bright Extract Effect BrightExtract
4 Color Key Alpha Effect ColorKeyAlpha
5 Color Tone Effect ColorToneEffect
6 Contrast Adjust Effect ContrastAdjust
7 Directional Blur Effect DirectionalBlur
8 Embossed Effect EmbossedEffect
9 Gloom Effect GloomEffect
10 Growable Poisson Disk Effect GrowablePoissonEffect
11 Invert Color Effect InvertColor
12 Light Streak Effect LightStreakEffect
13 Magnify Effect MagnifyEffect
14 Monochrome Effect MonochromEffect
15 Pinch Effect PinchEffect
16 Pixelate Effect PixelateEffect
17 Ripple Effect RippleEffect
18 Sharpen Effect sharpenEffect
19 Smooth Magnify Effect SmoothMagnify
20 Swirl Effect SwirlEffect
21 Tone Mapping Effect ToneMappingEffect
22 Toon Shader Effect ToonShaderEffect
23 Zoom Blur Effect ZoomBlurEffect

To apply these effects, here is a step-by-step lab manual -

1) Create a Silverlight 3 project using Microsoft Expression Blend 3. Here I took a Sketch Flow project of Silverlight 3.0.

2) Once you are done with this, Add the project “SLShaderEffectLibrary” from the location where you have extracted the .ZIP file. My path where the “SLShaderEffectLibrary” is as below-

C:\WPFSLFx\WPFSLFx\SL\SLShaderEffectLibrary

3) Now compile the project “SLShaderEffectLibrary” and add the reference of this library into our Silverlight project as shown below-

AddRef

4) Now add a Image control in our Silverlight control. Set your favorite picture to the image. Once you are done with this, now let’s add a effect on this image.

5) Find the “Effect” property of the Image under Appearance section, and click the “New” button as shown below-

NewEffect

6) Now, You will see a “Select Object” Dialog box. Within this dialog box drill-down the “SLShaderEffectLibrary” and you will see all the shader classes which you can apply to your Image-

SelectObjectDialogBox

7) Now change the properties as per your requirement and see the effect on your image.

Note-: I have created a StoryBoard for each effect and applied it to different images. If you want to try out the same create a story board and change the properties of each effect.

8) So, what are you waiting for !! Try out all the effects by downloading the Library.

Enjoy!!

Pravinkumar

1 comment:

  1. Thanks a lot. Your article has been a real help. I found some other articles that describe how to do the same thing, but they are uch more complicated and need much more software that I dont have.

    Thanks a lot again !

    ReplyDelete