Inspiration

We were experimenting with WebXR and AI code generation to create my own "VR experiences", and we thought to myself, that it is a bit awkward to keep on removing the glasses and tweaking the code for every small thing we want to be changed.

We wanted to create an engine, that allows building the scene from inside the VR.

We think there are also non-functional issues to solve with such an application, and we wanted to create something that was secure, and also optimised for most possible FPS. My experience with AI code generation is that it is often very bad at being efficient, and when you try to scale it up, it starts to jitter and slow down.

Our primary concern was to be able to bring this to the device, so you don't need cables, or another computer to use the app.

What it does

SPATIO allows users to enter rooms. Users can create their own rooms, and build its content from inside the room, by speaking out loud their wishes in the VR.

  • Pinch at a location, or summon the AI by speaking out loud the wake word,
  • Say out loud your wish (e.g. "we would like a table here")
  • The AI breaks down your request and resolves each task concurrently
  • You instantly see the changes in the room, assets are streamed in the background as they are finished

SPATIO does not only handle 3D model generation, it also generates sounds, skyboxes, animations. The engine supports scripting any behaviour, and your rooms can be made fully interactive: you can build reactive experiences or even full-featured games inside a room.

The application also features a version control system complete with branching, so you can experiment with changes in your room without being super destructive. we also built fully automatic refactoring capabilities into the app, so you can optimise your rooms if they get too complex.

SPATIO builds upon reusability: you can share assets and even behaviour between rooms, or use elements from public rooms in yours at anytime!

How we built it

We have been thinking a lot about renderer efficiently in the last few months, but for this project we finally decided to code a renderer!

It was not easy to reach the current state, we hit many dead-ends during experimentation, and the entire codebase was written from scratch three times in total.

First, we wanted to experiment with how native applications work on the Quest 2. we wanted to create a simple renderer using C++ and Vulkan. After understanding how such an app is structured, we failed miserably with getting the renderer to actually work, and after about 2 days of tweaking we decided to abandon that project, and start from scratch.

We created a roadmap, which incorporated roughly all features we had in mind to incorporate. we tried thinking in major steps and versions, to see how to build it exactly. We decided, that we will first create a WebXR-based client, and later transition to a native Vulkan + OpenXR client once the web application works perfectly. In the end unfortunatelly we did not have time to make that transition, but a stable WebXR client was created.

We implemented a proof-of-concept version, featuring a single server workload with some API endpoints and a WebSocket server, and also the WebXR client. Voice commands and world building were working end-to-end, but we had a problem: the entire codebase was captured in 3 files, that were 30.000 lines long each.

At this point, we had to sit down again, and think about the project structure. we decided to make some ground rules to guide the structuring of the code, and from scratch created all boilerplate necessary for the final architecture. we were also thinking about how we will deploy this in the end, so this time we also incorporated changes to make sure everything will run in the cloud as well.

This third major architectural version went through 3 major internal iterations on its own. After the initial room database structure we decided that the AI is not good enough, and wanted to adopt a different pipeline. Then we also realised that the initial plans were a bit too inefficient in terms of AI tokens, so we refactored everything again to make it faster, and cheaper.

We deployed everything to Google Cloud, configured all the necessary small things like login secrets and captcha site keys, and it was done!

AI agents were heavily used during the development for coding and automation of builds and deployments. we created a handful of skills and documentation for the AI to make sure we did not have to review every single line of code.

Challenges we ran into

There were many issues along the way, most of them arising from our prior inexperience with the device and the VR-specific web technologies.

AI agents helped tremendously in implementing tens of thousands of lines of code, but generated code had to be cleaned up a lot. It took a lot of time to lock in all specific code style requirements, and poorly written code also was the root cause of many bugs.

We had to bisect deep down what was happening inside the application, and research a lot about the possible causes of our issues. Finding all bottlenecks in the renderer took days.

It was also very hard to fine-tune the interfaces, and especially the voice commands so it works for everyone, not just the developers. After testing for a lot of time, we became biased and started automatically correcting our "input mistakes", which is not something to expect from a user at the moment they start using the app.

To get Meta and Google login working in production, compliance features had to be developed, including the ability to remove the user's own data. We also had to come up with a compliant privacy policy and terms of service document, because without these the application cannot be launched.

We also learned a lot about how LLMs can be used to generate all procedural content. Unfortunatelly, there are certain kinds of assets where the output quality is not very good in our opinion, for example humans. We experimented a lot with creating purpose-built parametric model generators to be reused in these scenarios, but the quality of those was really bad too. We think that this can be somewhat alleviated by using specific art styles, such as a vibrant low-poly style.

Accomplishments that we're proud of

  • SPATIO renders most scenes in 10-11 draw calls, resulting in high FPS.
    • All static geometry is rendered with a single draw call
    • Lighting shaders have been optimised
    • ASTC texture compression is used
  • Zero jitter, zero dynamic allocations -> predictable, smooth performance.
  • Secure, with special attention on AI generated code running in the client.
  • Frictionless binary WebSocket protocol handling.
  • Working C++ + Vulkan renderer.
  • "Hallucination-based API design", which helped us quickly map out engine interfaces.

What we learned

  • We learned a lot about tile-based GPUs, and the characteristics of current gen VR hardware.
  • We also learned a lot about how to approach large-scale code changes without breaking everything. We constantly had to change, and fix fundamental code smells before we started building more features on top. Sometimes this meant rewriting hundreds of files, that were just created, and tested to work correctly.

What's next for SPATIO

  • Right now, payment and billing is disabled, due to legal reasons. If anyone is interested in using the app, some business method needs to be established ...
  • Extending the engine: there are still a few blind spots, and very common scenarios, that should be explicitly supported by the engine, to make the generation of rooms using these features faster, and more reliable.
  • Working more on the quality of generated assets, possibly incorporating other models, such as Meshy.

Built With

Share this project:

Updates

Submission history