Thursday, 26 March 2009

Silverlight: GPU reverts to CPU Screencast

In my previous screencast, i showed you the benefits of GPU acceleration in Silverlight 3 and how to make use of it, as well of an instance where enabling GPU acceleration will harm performance.

In this screencast, I will show you that in certain scenarios even though you have enabled GPU acceleration, Silverlight will revert to the CPU.  Specifically we cover RenderTransforms, Pixel Shader Effects and 3D Perspective (Plane Projections).  Video is below.

 

Wednesday, 25 March 2009

Silverlight: GPU Acceleration Screencast

I wanted to do a screencast on Silverlight GPU Acceleration

Hopefully this video should show how to use GPU acceleration and when to use it, and an instance of when you might not want to use it.

There are lots of other instances of when you would want to, and not want to use GPU acceleration (and I will probably cover them in future videos), as I like to keep the screencasts short.

Tuesday, 24 March 2009

Silverlight: SL3 WriteableBitmap Video

I've spent a little time now with the Silverlight 3 WriteableBitmap stuff (playing with my Spectrum Emulator).  So I thought I'd make a little video going through using it.

I show you how to use WriteableBitmap to generate some random noise, some gotchas and show how the emulator makes use of WriteableBitmap.

Silverlight 3 WriteableBitmap can be viewed from here or below

Monday, 23 March 2009

Silverlight: SLLauncher

This is just a quick post about debugging in Silverlight 3 “Out of Browser” mode.

Your offline Silverlight application does not run in Internet Explore but will run in the a standalone executable called “SLLauncher.exe” which ships with Silverlight.  SLLauncher is essentially a windows application which hosts a browser control (and on the Mac it hosts webkit).  In windows look at (C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe).

This means that is you were to look for your “out of browser” silverlight application in Task Manager it will be listed as “SLLauncher.exe”.  The bad new is that (for the beta) it does not list in taskmanager any details of the application running, it will just show as “sllauncher.exe”, this means you can’t distinguish between multiple “out of browser” applications running on your machine.

Debugging

This means if you wish to debug your SLOOB application, then you will need to attach to the sllauncher process.  Visual Studio will not automatically attach to your SLOOB application.

Saturday, 21 March 2009

Silverlight: Web Pixel Shader Compiler

So I've built a very quick silverlight application (I will tidy it up later), that will compile your pixel shader code for you.  This saves you from downloading the DirectX SDK.

The url to use the compiler is here: http://www.voxpeeps.com/slpixelshadercompiler/

A little screenshot is below:

image

In the first textbox, enter the name of your .ps file (do not include the .ps extension).

In the second textbox, enter the contents of your .fx file.

Click on the compile button, and it will give you a link to download your .ps file.

You can the include your .ps file into your silverlight 3 application.

For more details on creating custom pixel shaders see this blog entry from Andy Beaulieu 

I will probably do a quick video on using this tool soon, and will tidy it up to make it look a little more professional at a later date.

In the mean time, feel free to go to: http://wpffx.codeplex.com/ and compile them for use in Silverlight at http://www.voxpeeps.com/slpixelshadercompiler/

Silverlight: WriteableBitmap Gotchas

So I updated my Silverlight Spectrum Emulator to work with Silverlight 3 and in this process I used the new WriteableBitmap class.

I just wanted to make you aware of a few gotchas that I experienced whilst working with this.

Set the Image Source everytime

Gotcha number 1, for some reason after updating a bitmap, you must reset the source of the image to your bitmap.  If you don't then you will get very jerky updates (it won't re-render every time).

Out of Memory Exceptions

Due to gotcha number 1, you may be tempted touse a local variable for the WriteableBitmap, and then set the source of the image.  DO NOT do this, as it will steal all your memory, and you will get an out of memory exception.

To get around this you should scope your WriteableBitmap to your page, and thus you will avoid the out of memory exception

Silverlight: Pixel Shader Libraries

So I absolutely love the support for pixel shaders in Silverlight 3.  You can apply some pretty cool effects (DropShadow and Blur are built in), or you can apply custom effects.

The method for producing custom shaders in SL3 is the same as WPF, which means that any custom shaders that are produced for WPF should work for Silverlight (this is a big assumption as I haven't tried it yet)

Creating custom pixel shaders is not the sort of task that everyday coders (including me), do.  However any shaders produced by other people, we are quite happy to use.

In codeplex there is a nice custom shader library for WPF (for which I see no reason wouldn't work for silverlight 3, caveat is I haven't tried it yet).

http://www.codeplex.com/wpffx/

Effects include

Effects: BandedSwirl, Bloom, BrightExtract, ColorKeyAlpha, ColorTone, ContrastAdjust, DirectionalBlur, Embossed, Gloom, GrowablePoissonDiskEffect, InvertColor, LightStreak, Magnify, Monochrome, Pinch, Pixelate, Ripple, Sharpen, SmoothMagnify, Swirl, Tone, Toon, and ZoomBlur

I will try and grab some time, and try sticking one of the effects on SL3, and let you know the results