Saturday, July 11, 2009

Silverlight 3 WriteableBitmap is unwriteable

So I downloaded Silverlight 3 RTW(the real one, not Silverlight 3 beta) today getting all excited to try out the new stuff offered by Silverlight 3, and found that WritableBitmap does not exactly work like it does in Silverlight 3 beta. The problem? You can’t directly write the pixels, yeah so it’s basically unwritable. Then why not call it UnwriteableBitmap?

Maybe I’m doing something wrong in my code, or maybe there are ways to really write a WritableBitmap in Silverlight 3. I’ve been searching everywhere on the web but all the examples / codes only work in Silverlight 3 beta, and it seems that Silverlight 3 was released so hastily that there is not much documentation provided for this particular class. Well I hope more information will be available soon by Microsoft.

Microsoft does provide a documentation of breaking changes from Silverlight 3 Beta to Silverlight 3 RTW, but all it says are Lock() and Unlock() have been removed and does not say anything about writing Pixel data into WriteableBitmap.

What does WriteableBitmap (supposedly) do?

WritableBitmap lets you manipulate each pixel in a bitmap to generate customizable images. An example image that is generated through Silverlight 3 Beta WriteableBitmap is shown below.

WritableBitmap Does Not Work

If you know how to make WritableBitmap work, please let me know / post comments below. I’m really eager to try this out and use it for my next project. If the WriteableBitmap does work, it will be really useful for visual effects and game design. Right now the search engine is flooded by Silverligth 3 Beta examples that I can’t find any useful resources for the actual Silverlight 3 release.

What’s new with Silverlight 3

The wait is over. On July 10, 2009 Microsoft officially announced the release of Silverlight 3. So what’s new with Sliverlight 3 and why is it awesome?

Hardware Acceleration

This makes Silverlight applications run much faster because it utilizes your graphics hardware. A few occasions  where hardware acceleration is used are:

  1. Playing video, now supports full screen High Definition (720p).
  2. 3D image rendering – Expect real 3D games available soon on Silverlight 3.
  3. Pixel Sahder effects, create shadows, blurring, explosions and others definitely improves gaming visual effects.
  4. Writable bitmap where you can directly modify each pixel of an image. Great for creating particle effects.
  5. Text rendering and animation.

Example of writable bitmap

Example of pixel shader effect

Video and Audio

In addition to native support for VC-1/WMA, Silverlight 3 now offers native support for MPEG-4-based H.264/AAC Audio. With the new Raw AV pipeline, Silverlight can easily support a wide variety of third-party codecs. Audio and video can be decoded outside the runtime and rendered in Silverlight, extending format support beyond the native codecs. Videos can also be played full screen at 720p high definition.

Out of Browser?

Silverlight 3 applications now pops out of your browser, so you can run your application without those annoying “file, edit, view” and navigation buttons on top… This basically makes Silverlight 3 applications run on your desktop, with or without internet connection. You can make shortcuts / place and item in the start menu that links to your Silverlight 3 application. This opens up a great potential to create large scale full screen games.

Example out of browser application

Improved Data Support

Although less relevant to Silverlight game design, this is nevertheless a great improvement in Silverlight 3. New features include:

  1. Data forms control which provides data validation, better layout controls, and paging through data.
  2. Element to element binding – lets you manage UI element properties to data more effectively.

What to expect for Silveright 3 games?

First off, hardware acceleration definitely helps make Silverlight 3D games much smoother. With custom pixel shader effects and writable bitmaps to create particle effects, we can expect awesome visual effects in Silverligth 3 games.

Also, with out of browser support, games and run on your desktop (and I think this would increase performance as it reduces the overhead of browser processing?) in full screen. As such Silverlight 3 games could extend out of the boundary of online casual games into real serious hardcore games.

Wednesday, July 8, 2009

Featured Game: Silverlight Breakout

This post is about silverlight breakout game. I try to collect all Silverlight breakout applications and post their links here. Some of these games even provide full source codes!

Top pick: Chaos Ball Extreme – Hypnosis

This game is my top pick for Silverlight breakout games because it is made by me lol. Features 3D particle effects. Prototype source code available at Play it fullscreen here.

Second: Chaos Ball Extreme

Also another breakout game made by me. Features parallax effects and elegant graphics. Prototype source code available at Play it here.


Nice music and playable in full screen. Full source code available at

Silver Arcanoid

Very nice graphics with particles and real physics. Also features nice music and sound effects.

Vectorform Breakout

This breakout game is pretty professionally made. With a multiple full levels. Made in Silverlight 1.1. Source code available at

Monday, July 6, 2009

Creating Particle Effects in Silverlight

This is a tutorial about Spectrum particles 3D engine. Spectrum is a Silverlight 2.0 particles system that is in full 3d and is extremely easy to use. The following tutorial shows 10 lines of codes that will allow you to create 3D particles effect using this engine (written in C#).

Official site for Spectrum 3D Particle System is here.


1. To use Spectrum particles 3D engine, first download the assembly (Spectrum.dll file).
2. Next open up your Silverlight project, click Project -> Add Reference.
3. Click "Browse" tab, then find the .dll file to add into the reference.
Now you can use the functions in Spectrum class.


1. First we have to instantiate a camera and a normal particle generator.

Spectrum.Camera3D camera = new Spectrum.Camera3D();
Spectrum.ParticleGeneratorNormal pgNormal;

2. Next we initialize the camera and the particle generator

camera.setView(new Vec3(0,0,0), 1000, new Vec3(0,1,0), new Vec3(1,0,0), new Vec3(0,0,1));
pgNormal = new Spectrum.ParticleGeneratorNormal(camera, null, Spectrum.Globals.ParticleShape.smoke);

Camera.setView has the following arguments:
-focus is where your camera is looking at
-dist is the distance from your view point to the focus
-down is the down vector of your view point
-right is the right vector of your view point
-front is the front vector of your view point

ParticleGeneratorNormal has the following arguments:
-the camera
-a XML file name for particles effect. null for no effect
-particle shape. Only 2 choices available: Star or Smoke

3. Add particles.

for (int i = -3; i <= 3; i++)
for (int j = -3; j <= 3; j++)
for (int k = -3; k <= 3; k++)
pgNormal.createAndAdd(new Spectrum.Vec3(i * 50, j * 50, k * 50), new Spectrum.Vec3(0, 0, 0), new Spectrum.Vec3(0, 0, 0));

3 nested loops to create a 3D array of particles. The arguments for createAndAdd are:
-position of particle, in 3D coordinates.
-velocity of the particle. Here we just use 0,0,0.
-acceleration of the particle. Here we just use 0,0,0.

4. Finally, run the update method inside your game loop.

pgNormal.update(new Spectrum.Vec3(0, 0, 0));

That is all. You will be able to see particles in 3D space. Other functions like moving the camera and zooming in and out are demonstrated in this project available for download with full source code. The preview of this project is shown below.

Friday, July 3, 2009

Spectrum Particles 3D Engine Released

The wait is over. Now you can download and try out the Spectrum Particles 3D Engine at AquoSGameS.

What is Spectrum?

Spectrum Particles 3D is a full 3D particles engine written in C# for Silverlight. Particle effects like fire effects, blurring cloud, exploding stars are built into Spectrum and can be used in less than ten lines of codes.

Spectrum is still in initial testing phase, so some of the customization variables are not released.

Game Design

The main application of Spectrum 3D Particles Engine would be to make games. An example of a game created using Spectrum is Chaos Ball Extreme – Hypnosis. This games features full 3D graphics and tons of special particle effects. A Silverlight visualization application made using Spectrum can be seen here.


You may download the Spectrum Assembly and a Demo Project from here. the compiled and running project is shown below: