Introducing StereoKit

-2020.1.6 3:00pmStereoKit

I started working on a Mixed Reality (AR and VR) library called StereoKit in July of 2019, and I'm finally ready to release it into the wild! It's still early days for this tool, but it has already brought joy back into HoloLens development for me. Every time I sit down to write a StereoKit demo, or add features to one of the StereoKit based applications I'm developing, it just feels like magic! It has been a long time since I've had this feeling, and I hope it can do the same for you too :)

StereoKit is a Mixed Reality library for C#, inspired by things like XNA, Dear ImGui, and Processing. It provides an extremely simple interface over graphics, physics, UI, and other functionality needed to make an MR application! You don't need a game engine to build an app, nor should you need to become a graphics programmer to get your models onto a headset! All you need is an easy way to build a UI, and design interactions! So StereoKit does just that. A single line of code can accomplish a pressable UI button, load a .gltf model, play a sound and plenty more!

Hello world for StereoKit, extremely easy and short!

If this sounds interesting, here's the getting started guide! You can also find the raw source for StereoKit on Github here.

Features!

Iteration time! My first experience building a demo for the HoloLens was a nightmare, I spent a whole month repeatedly making 15-20 minute builds. I promised myself never again, and so StereoKit builds are lightning fast! Worst case is the Release mode C# UWP .Net Native build for HoloLens 2 deploy, at around 15-20 seconds, and best case is C# .Net Core for desktop VR at around... zero seconds. It compiles, builds, and runs in less time than it takes for Unity to even recognize you pressed play!

And, wouldn't it be nice to load a 3D model at runtime? I think you'd probably agree, there's a lot of use-cases for that, especially when you're making an application and not a game! Pretty much every client I've helped while working at Microsoft has had a 3D .obj loader in their project. Many of them had issues, and I guarantee you all of them were missing out on important optimizations! Which is why StereoKit's asset pipeline works at runtime! Any format StereoKit supports, can be loaded from a file picker, a string, or a web request. Handy! Right?

Using a file picker to open a .gltf object from Sketchfab! The file picker isn't built in yet, but can be found in the samples.

I've writen a few graphics pipelines before, but not everyone can say that. There's nothing wrong with that, realtime graphics programming is arcane, and for the most part, unnecessary outside of game development! Most people end up using a game engine for this reason. A game engine provides anyone with hundrededs of ways to make their experience fast, stylized, photoreal, and breathtakingly beautiful! But all that power to build cutting edge visuals also provides you with a lot of opportunities to mess up your performace! An MR application development tool needs to be 90-frames-per-second-fast on mobile hardware, without any graphics knowledge whatsoever! These objectives can often sound similar, but they're ultimately very different.

StereoKit handles this by focusing on a smaller subset of rendering! It uses an instanced rendering pipeline with a simplified lighting model that makes performance a default, rather than an ambitious target! You won't be able to toss in 100 poorly performing point lights to light up your scene, instead, StereoKit uses a single fast spherical harmonics lookup for lighting. It looks great, serves plenty of use-cases, and is impossible to get wrong! But it does still let you write shaders if you want to, and at some point I'll also have a visual shader editor for that.

25 instances * 15k verts * 2 screens = 750k verts in 1 draw call on a HoloLens 2! I haven't done a serious optimization pass yet, but this is a pretty solid base to work from.

Try it out!

StereoKit is based on OpenXR, and is currently limited to HoloLens 2 and WMR headsets. If that sounds like you, I would love for you to give it a try! I think you'll enjoy it too. I'll be bringing StereoKit to more platforms as OpenXR support broadens, so if you're working with other headsets, keep your eyes open for that!

And regardless of whether you try it or not, I would love to hear what you think about it! I'll be writing a lot more about StereoKit, so if you want to hear about specific pieces, let me know that too! Poke me on twitter, send me an email, or file an issue on the StereoKit repository!