Happy Silverlight 5 Beta day! The biggest additions to Silverlight 5 are certainly the support for GPU accelerated video and 3D graphics and the SDK team has been hard at work trying to get samples and documentation together for today. If you’re a developer, after downloading the Silverlight 5 beta runtime, SDK, and developer tools, you’ll probably want to start playing with the 3D features. In this blog post, I’ll point you to the resources we created to help get you started.
1) The XNA Math Helper DLL
We expect that the math functions from XNA will be integrated into the Silverlight namespaces in the future, but for Silverlight 5 beta, you’ll want to make use of this library instead. Add a reference to this DLL by right-clicking references in your Visual Studio project, clicking “Add Reference,” selecting the “Browse” tab and navigating to this DLL’s location. Then you can use the original XNA documentation to make use of the math functions contained within. These are a real lifesaver when doing matrix math, creating camera views, changing object positions, etc.
2) 3D Graphics Overview Topic
A high-level overview of the basics, explaining the capabilities provided in this beta release.
3) Textured 3D Cube Walkthrough and Downloadable Source Code
This walkthrough and sample demonstrates how to create a complete Silverlight 5 beta 3D application, including the use of textures, the use of shaders, integration with Silverlight UI elements, and cross-thread synchronizing (between the rendering thread and main UI thread). When completed, you will have created a textured cube that can be manipulated with ordinary Silverlight UI elements (in this case, sliders).
Already have the runtime installed? Here’s the Textured Cube sample running live!
4) Reference documentation for the new API areas: Microsoft.Xna.Framework (Silverlight Version), Microsoft.Xna.Framework.Graphics (Silverlight Version), Micrososft.Xna.Framework.Silverlight, and the appearance of DrawingSurface in the System.Windows.Controls namespace.
While XNA developers have enjoyed being able to use managed code to create and apply 3D effects for awhile now, in Silverlight 5 beta, effects are the purview of shaders. This is because the effects APIs from XNA haven’t been integrated yet. For now, just as you must workaround the limitations of the beta release by manually importing the XNA math library, so must you write and compile shaders to have effects in Silverlight 5 beta. A minimum of a vertex shader and a pixel shader is required, but as you will see in the textured cube sample, they need not do anything terribly fancy.
We are working on posting some other samples that demonstrate 3D use, and look forward to posting them very soon. Hopefully you got to see the “Babylon” demo (showing the interior of a cafe) during the MIX presentation, featuring full-scene, full-screen, GPU-accelerated 3D. It is really amazing to have an in-browser experience that feels so much like a modern 3D game; truly an example of trailblazing plug-in technology at work!