Search Unity

Over the NinjaCamp III week I (it’s-a me, Aras!) worked on implementing a Direct3D 11 renderer in Unity. At the beginning of the week I had a standalone player that creates a window, clears it to the correct camera background color and could draw a cube in magenta color. All in full glory of Direct3D 11, how cool is that?

At the end of the week it could do this however:
Bootcamp running on DX11

This is our Bootcamp demo, running in D3D11. So lots of the stuff is working: meshes, textures, shaders, shadows, deferred lighting, Image Effects, particles, skinned meshes, terrain and so on. For the reference, Bootcamp running on DX9:
Bootcamp running on DX9

As you can see, some of the stuff is not working on D3D11 yet. Fog is not working; there’s some lighting difference on grass. Some other things are not working, like fixed function shaders (VertexLit ones or any shaders that use SetTexture) but you can’t see much of those in Bootcamp.

Awesome? Yes and no.

For basically a week of work, I’d like to think this is very good progress.

Is our D3D11 renderer teh awsum yet? No. Currently it’s running slower than D3D9, and does not implement all the features of D3D9 one either (fog, fixed function etc.). And I haven’t even started exposing D3D11 specific things like Compute Shaders, Shader Model 4/5, Tessellation etc. And there are some unsolved workflow issues, for example: when someone is making a game on a Mac, how would we compile shaders for D3D11 renderer? With D3D9 we can do it because NVIDIA’s Cg compiler works both on Windows and Mac, but no such luck with D3D11 shader compiler…

So this is not shipping quite yet. Performance is not great at the moment – which is to be expected. D3D11 potentially can be faster than D3D9, but the path of getting there is not an easy one. We also need to actually expose compute shaders, tessellation and other goodies. And then think about how/if equivalent features would work on other platforms like Macs (DirectCompute on Windows, OpenCL on Mac? etc.).

But, so far it’s promising! Stay tuned, maybe someday we’ll ship this ;)

25 replies on “Ninja Camp III: Direct3D 11”

About the workflow issues (as you said, using directX 11 features and then hoping to port for mac, only to find out that most of the shaders won’t work there), if you somehow make it clear that “this feature is platform exclusive and for another platform you should do it all over again”, then it should be fine.

Or at least it would be better than feeling that my platform of choice (and I don’t necessarily mean windows), is being held back because you are only adding features that are useful on all platforms.

@Bianca: of course no one is going to make tessellation be forced on all objects. Tessellation is a feature that you can use if you want to. Tessellation scheme and amount of subdivisions would also be controlled by you. Yes, insane tessellation levels can be very heavy on the GPU, but so can be heavy pixel shaders. Should we disable pixel shaders just because they make it possible to make the game slow? I don’t think so.

Tessellation I’m very interested but should run on both Mac and PC :) June is not long off (Apple)!

Love to play with tessellation in Unity.

I would agree, tessellation or bust. The other features are great of course, I would love to see something in the direction of what the Unreal3 demo video was showing (we can’t do it all right now easily of course but in time no doubt). Though I think tessellation is one of the big impact points after watching an entirely flat environment demo completely pop out with it.

I think Dx11 is a far stronger sales pitch than Mac compatible. I’ve been doing development on a Mac which is nice, though I think now more people can run Dx11 than even own a Mac (just a guess). Though I thought at least tessellation could be done in OpenGL somehow as well. No expert here, I just thought some of Dx11’s functionality was in there as well. Of course I unrealistically want it both ways so appease me or else. Course I’ll be happy if I can work on a project from either long as the Dx11 version can use all of the functionality so I’m not terribly worried if the OpenGL can’t show it, bells and whistles anyway.

How about some linux support already.. sheesh is Unity’s primary focus going to remain on the windows platform forever?? BOOOOO!

@Ugur: agreed, improvements that matter on most platforms is something we’re always focusing on (watch out for Unity 3.4 and so on :)). However, keep in mind that a DX11 renderer will work on DX10 hardware as well. According to our web player stats, in 2011 Q1 there’s almost 30% users who have Vista or later and a DX10 or better GPU; and the number will only grow in the future. 30% is already quite a significant amount.

@tino: as far as I know, Apple plans to ship OpenGL 3.2 in OS X Lion, which will include DX11-like OpenGL extensions (with tessellation and so on). I don’t know when we’ll support either DX11 or GL3.2, so far we’re only experimenting with it. No promises ;)

Very impressive one weeks work :)

Direct x 11 although not available on mac is very strong sales pitch, and will surely available in unity sooner or later (hopefully sooner).

Tessellation is one of things I’m interested mostly, what the timespan you hope to implement it, and what are your ideas in how to close the gap between mac’s and pc?
presumably they use the same graphic hardware…

Congrats on the very nice achievement, not just regarding the short timespan in which you pulled it off =)
That said i personally way more prefer improvements from which several platforms benefit and also the weaker ones. I’d like AA support in deferred rendering, generally improved lighting and image effects performance etc which runs both on mac and pc, ideally also as nice as possible on mobiles, too, instead of something win only which even on that platform most non hardcore users won’t be able to run nicely for 2-3 more years. Once there’s a nice cross platform path available for this stuff it could look different of course. Hmnmmmh, hardware tesselation.. =)

@Ahmad: Multi-GPU rendering should just work out of the box. Unless you do something in your game that makes it not scale well (e.g. render into some textures in one frame and use results in the next frame etc.). Even then, it will still work, just won’t scale that well with more GPUs.

More efficient use of multicore CPUs for rendering purposes is something we have to do. And we’re on it.

@Aras, is multi-gpu/multi-core rendering something that has to do with DX11 by any chance? Can we take advantage of them in Unity somehow?

@Jorge: sure. We can also improve performance significantly by emulating “command buffers” by hand on D3D9 for example… That said, of course, D3D11 Deferred Contexts is something we’ll look into. Using them was somewhat out of the scope for one week of work ;)

Jeuh! Very nice to see you are working on this!! this is more the ninja stuff i was hoping to see!!

Keep up the good work and update this blog more!!!

Matrix, DX11 is the future for windows. If you start working on something today and want it to be finished in the next couple of years, you will want it to be DirectX 11. So the sooner Unity has it, the better.

Looks very promising, Aras – great work. I think the DX11 grass looks better, actually – less “glowy” – seems more grounded in the scene. Ninja Camp is a great idea – I certainly hope that we soon see some of those cool new features! :)

Although its a great work Aras. I keep wondering if this is something worth pursuing. I mean, Crysis 2 is a DX 9 game and so is Alan Wake and Splinter Cell Conviction. If a developer can’t get their game to look pretty using DX 9 then tesselation and the two other features of DX 11 is not gonna add that much to the experience.

In my opinion, I would prefer solutions like Real Time GI (well, Its not even GI per se. But something that does not require you to pre-bake your scene, instead everything is dynamic). This was present in CryEngine 2 on DX9, my guess is that its doable and will benefit a lot of people.

@Joris: that one is not DX11 at all; just the ability of some GPUs to do kind-of dithered transparency anti-aliasing. We should enable this at some point like I said above.

What is “DX11 transparency AA”? I know of one technique for that which looks great and kills your framerate really fast as well ;) I think to improve foliage transparencies, we’ll first do much simpler approaches that work on many platforms (there are various ways to improve the way vegetation mipmaps are computed, and to smooth out the alpha test outlines; all not necessarily requiring DX11)

Comments are closed.