Silverlight 5 brings XNA 3D to the web

Silverlight 5 brings XNA 3D to the web

  • Comments 21

I have been remiss in not mentioning this on my blog before, but if you are an XNA developer who hasn't been paying attention to Silverlight 5, now might be a good time to start!

A quick history:

  • At the MIX11 conference in April, we announced that Silverlight 5 was adding a new 3D API.  This is based on XNA, so included familiar types such as GraphicsDevice, VertexBuffer, and Texture2D, but it was not a full port of XNA.  In particular it did not include many of the higher level helper features, so there was no BasicEffect, no SpriteBatch, no math library, and no Content Pipeline.  It did support custom shaders, but using a low level DX9 style constant register API as opposed to the friendlier Effect system used by XNA.  This beta release made it possible to use high performance 3D in a Silverlight web app, but it wasn't exactly easy to do so!

  • In September, the Silverlight 5 RC added new features including the same five built-in effects as XNA 4.0, plus an XNA compatible math library.  David Catuhe writes about these changes.

  • Now, the Silverlight Toolkit provides vastly improved XNA compatibility, including ContentManager, Model, SpriteBatch, Mouse, Keyboard, custom effects, and new Visual Studio templates for getting started with Silverlight 3D.  Again David has a great intro.

This is still not all of XNA (for instance there is no Game class) but with this new toolkit, enough pieces are the same that porting existing Xbox or Windows Phone games to the web can be quite easy.  It took us just a few hours to port several existing XNA samples, which are included in the toolkit (Toolkit/Sep11/Source/Sample source code.zip):

image

If you want to use the Content Pipeline in a Silverlight 5 app, you will also need to install XNA Game Studio 4.0 on your development PC.  But don't worry, this doesn't mean you will have to redistribute XNA to your web clients, or have it installed on every computer that runs the app.  Remember this diagram from an old article about the Content Pipeline:

Untitled_959e27ef-8b80-42e7-b2df-102e4f20199c

The way this works with Silverlight 5 is that the blue boxes, which run at build time on your development PC, use the original XNA Game Studio 4.0 Content Pipeline assemblies.  Only the red boxes, which execute at runtime on the client machine, use the new code from the Silverlight Toolkit.  This is similar to when you build an XNA game for Xbox or Windows Phone, but the remote device is now a web browser.  If you are extending the Content Pipeline to add new types, you will need to provide both an XNA version of these types for use at build time, and also a Silverlight version for runtime.  Check out the Silverlight port of the Skinning sample for an example of how to set this up.

I don't normally name names, as I'm lucky to work with so many talented people and this blog is my chance to take credit for all their hard work :-)  But in this case I want to give a shout out to Aaron Oneal and David Catuhe, who went above and beyond to pull all the pieces together and make this happen.  Nice job guys!

  • "This is still not all of XNA (for instance there is no Game class) but with this new toolkit, enough pieces are the same that porting existing Xbox or Windows Phone games to the web can be quite easy."

    Silverlight isn't the web. It's a browser plugin. Not only that, it's a browser plugin that won't work in IE on Windows 8 (under Metro, anyway).

    Regardless, it's nice to see you guys unify the XNA and Silverlight APIs some. One less target to consider when building a game is a good thing.

  • Will the 3D support work on the Mac (i.e., be a viable Flash 11, Unity, etc. competitor)?

  • > Will the 3D support work on the Mac (i.e., be a viable Flash 11, Unity, etc. competitor)?

    The Silverlight plug-in is used by Netflix, so I imagine that any desktop computer that can view Netflix in a browser will be able to view Silverlight 3D content.

  • This is pretty sweet stuff - great to see another outlet for XNA skills that's widely available. But I certainly echo the worries about Windows 8 - until it's really clear what direction that's going to be taking, and with the state of XBLIG, I can't see my hobbiest self investing in further XNA development. Which is a real shame as I love the tools (the content pipeline is so very awesome) and still actively lurk on excellent blogs like this one! Well done to the technical teams behind this though :)

  • What happen with XNA? It even missing from Visual Studio 2011 Developer Preview and I cannot use this ToolKit in

    Please admit dead on it so we can move out in time

  • Thaina, XNA versions are usually tied to a specific edition of Visual Studio. XNA 3 was tied to VS2008 and XNA 4 to VS2010, and since there's no XNA 5, it's logical there's no XNA for VS2011 yet.

    Since this toolkit builds on XNA4, you probably need 2010.

    Jon W: I think Netflix degrades to non-Silverlight solutions in other platforms... On the other hand, there's Moonlight.

  • @Kyte

    The problem is now we don't have any future plan of XNA release from MS

    Where is XNA 5 news? do you have any glimpses?

    And that ridiculous, VS 2010 can use previous version of XNA so it should be a common sense that Visual Studio MUST provide backward compatibility

    If not, there are something weird happen, such as XNA will be disposed in the future

    Also this toolkit doesn't work in Express, Visual Web Develop cannot open XNA project

    And it complicated that SilverLight 5 RC does not come with Content Pipeline from the first place

    Which should be whenever SilverLight can use custom effects, why it cannot make

    Actually, nowaday we should be able to compile raw text to shader at runtime for many years. and SilverLight is the most benefit technology to do, I don't know why they not do but this is the cause of SilverLight is a junk technology that cannot compete with flash and WebGL

  • > And that ridiculous, VS 2010 can use previous version of XNA so it should be a common sense that Visual Studio MUST provide backward compatibility

    All XNA versions are tied to a particular release of Visual Studio.  Since we have released XNA versions with a higher frequency than Visual Studio releases, there is more than one version of XNA that can install into VS 2010, but you cannot use earlier VS 2008 versions of XNA with VS 2010, no more than you can use the 2010 version of XNA with VS 2011.

    There's no backward compatibility involved. The two products are strongly tied together so you cannot mix different versions.

    > And it complicated that SilverLight 5 RC does not come with Content Pipeline from the first place

    We could have included a copy of all of XNA in the Silverlight SDK, sure, but that would have been rather wasteful for the majority of Silverlight customers who don't use 3D stuff and have no interest in XNA.  I think it makes more sense that only the people who want to use this stuff can choose to download it.

    > Actually, nowaday we should be able to compile raw text to shader at runtime for many years

    Actually, runtime compilation of shaders is not considered a good practice by most game developers. The shader compiler is very big, complicated, memory hungry, and slow, so it doesn't make sense to do this on the fly any more than it would make sense to compile your C# code at runtime inside the browser!

  • I've been trying to poke around to see if it would be possible to use the GPU in Silverlight 5 for general-purpose calculations (see gamedev.stackexchange.com/.../using-gpu-on-silverlight-5-for-a-fast-fourier-transform). But it seems like one of the major differences between regular XNA and Silverlight XNA is that the Texture and VertexBuffer classes don't have a GetData() method. Why is that? Is there any other way to do this sort of thing? And are there any plans to make this possible and/or easier? It's supposedly possible with Flash - it seems silly to have this sort of thing restricted in Silverlight.

  • Ken - that's right, Silverlight doesn't support CPU readback from GPU resources.  I'm not sure what the technical reasons for this are but I know that readbacks aren't well supported by all driver architectures.

    My knowledge of GPGPU is more as an observer than expert, but my impression is that people trying to do GPGPU via general purpose 3D graphics rendering APIs generally haven't had that great success. It's the sort of thing that can make impressive standalone demos, but tends to run into a lot of issues when you try to productize it across a range of different hardware and use it inside an app that does other things as well.

    All the really successful GPGPU implementations that I have seen were made using dedicated GPU programming technologies (Direct Compute, OpenCL, CUDA, etc).

  • Shawn - it seems like there are a number of interesting scenarios that could be newly open for Silverlight developers if MS was willing to expose either the GPU or, at least, SSE/SIMD in some fashion (e.g., Mono.SIMD). There are a lot of folks who want to do realtime audio and video on Silverlight, but we're limited right now by CPU (and the limited access which .NET gives us to hardware acceleration features). Just saying that if you get a chance to push for some intelligent way to access these features in Silverlight 6, it would be helpful.

  • Shawn, there will be an XNA 5 for VS2011?

  • I am fully agree with Ken

    Web technology need flexibility over performance, If it can did without security flaw then it should be able to do

    This also imply with compile shader at runtime, it can generate many possibility in the web application world

    With what? just because it's not a good practice? The shader compiler is very big, complicated, memory hungry, and slow but is it really big issue? If it big then it reflect DirectX team low competency, while OpenGL can do it

    We can make a very cool application not just game(and making game using runtime shader compiling as a feature is possible)

    SilverLight should be the first technology to introduce 3D into web since version 3 but you miss this chance once. And if you still miss a chance to let SilverLight have more feature than WebGL then you will miss second chance to Google's NaCl who will introduce full performance to Web world in place of SilverLight

    PS

    I would suggest that Microsoft should make nothing but XNA interop API with SilverLight for the SilverLight3D. When user missing XNA then SilverLight with XNA cannot load and show the link to load XNA and that's all

    PS2

    If you still try to against me and Ken then I have no hope anymore

    SilverLight will just lost to HTML5 WebGL and it's a time to find new technology

    Good bye

  • bla bla bla above here

    Silverlight 5 is awesome, and I'm going to use it a lot :D

  • Just one more thing, I loved WebGL when I saw it, but the GREATEST samples suck(the best sample I saw was of a snake, pretty much realistic, only).

    Imagine running SunBurn Engine there. XNAnimation, BEPU... THIS WILL BE AWESOME!

Page 1 of 2 (21 items) 12
Leave a Comment
  • Please add 1 and 3 and type the answer here:
  • Post