644 points · by TrevorSundberg · 3y ago · 159 comments
We’re building off a previous engine that we worked on for DigiPen Institute of Technology called the Zero Engine with a similar component based design architecture to Unity. Our engine had a unique feature called Spaces: separate worlds/levels that you can instantiate and run at the same time, which became super useful for creating UI overlays using only game objects, running multiple simulations, etc. The lighting and rendering engine is scriptable, and the default deferred rendering implementation is based on the Unreal physically based rendering (PBR) approach. The physics engine was built from the ground up to handle both 2D and 3D physics together. The scripting language was also built in house to be a type safe language that binds to C++ objects and facilitates auto-complete (try it in editor!)
This particular fork by Raverie builds both the engine and editor to WebAssembly using only clang without Emscripten. We love Emscripten and in fact borrowed a tiny bit of exception code that we’d love to see up-streamed into LLVM, however we wanted to create a pure WASM binary without Emscripten bindings. We also love WASI too though we already had our own in memory virtual file system, hence we don’t use the WASI imports. All WASM imports and exports needed to run the engine are defined here: https://github.com/raverie-us/raverie-engine/blob/main/Code/...
The abstraction means that in the future, porting to other platforms that can support a WASM runtime should be trivial. It’s our dream to be able to export a build of your game to any platform, all from inside the browser. Our near term road-map includes getting the sound engine integrated with WebAudio, getting the script debugger working (currently freezes), porting our networking engine to WebRTC and WebSockets, and getting saving/loading from a database instead of browser local storage.
Our end goal is to use this engine to create an online Flash-like hub for games that people can share and remix, akin to Scratch or Tinkercad.
glad to see the spirit of Zero still going strong through Raverie, though!
I have an imperfect perspective of the students' attitudes, but it seems to me that they tend to agree with my point of view: at the beginning of the year, I said, "Raise your hand if you wish you'd be working on a custom engine this year," expecting to see a few dozen hands go up. Surprisingly, only about one and a half hands were raised! Working on a custom game engine is an amazing and unique experience, but it's not the end-all-be-all of game programming.
Then tried it on my aging Mate 20 Pro (not too new, not tooo old), and it just seemed to get stuck at "Downloading runtime". Got a funny feeling my flaky 4G wasn't actually to blame, inspected the tab from my laptop (chrome://inspect) via USB, and was greeted with
Uncaught (in promise) Error: Needs OES_texture_float_linear to function
at M (worker-3ec07b2e.js:1:3338)
at J (worker-3ec07b2e.js:1:3403)
It is what it is. It's a good philosophical question about whether it's worth coding up an error screen, since it's all just to tell people they can't play with the toy. Hehe.OES_texture_float OES_texture_float_linear
But on WebGL2, it only shows OES_texture_float_linear. I think OES_texture_float doesn't exist on WebGL2 I'm guessing.
I finally managed to highlight the starting sphere after several tries. At first I wasn't sure if it was loaded.
Of course, I'm only using a 1.8 GHz Celeron with onboard GPU and 8GB Ram in Firefox, so... not exactly high-end stuff.
Firefox Developer (119.0b1), Chrome (117.0.5938.92), Opera (102.0.4880.56), Edge (117.0.2045.43).
Turning off all other programs (without crashing Windows), ranking for trying to drag the selection square ~2 inches x 2 inches (on a 1920 x 1080 laptop with the above noted characteristics) without doing anything else. Did the drag back and forth TL-BR, BL-TR 5-6 times to get a feel for general timing (cannot claim I used a stopwatch):
Edge: ~1 sec response before square changes
Chrome: ~1.5 sec response before square changes
Opera: ~1.5 sec response before square changes
Firefox: ~2 sec response before square changes
From my super low-end perspective, Edge is surprisingly responsive (maybe optimized for Windows?)
Edit: From another perspective, looking at the Dev Tools (what I actually care about), Edge is pretty hilarious, it has 72 errors on its default landing page (including this is not a "TrustedScriptURL"). Opera only has 2 "Uncaught (in promise)" and both Google and Firefox have 0.
There's something comforting about the idea that Microsoft still does not trust Microsoft. ("Left hand meet right hand. Begone fool, we have no hands!") The more things change...
I know personally, anything 3d in Firefox is a slideshow, even with a 4090
It was laggy in Windows and under X11 on linux, but under Wayland I get 60-80fps and it's very usable.
Not sure what the cause is
EDIT: Under Chromium (compiled from AUR) the performance is roughly the same
This is, as far as I can tell, exactly what the Godot engine does[1]. That engine also has a browser (wasm) target.
I suppose it's not any kind of priority to the project. Tested it a bit and it does seem to work :), but it's slower than running it natively.
It makes composing and managing objects and compositions much easier than just with the tree view.
Like a Unity prefab, but much better
The only real need for JS would be to initialize the wasm module in the first place.
I don't think that's true. You still need JS glue code that would return these externrefs. A WebAssembly module loaded through ESM integration can't as far as the current proposals access Web-APIs on its own. As far as I understand there is also a number performance issues related to the wasm spec itself that limit possible optimizations, making wasm second class to JS in terms of performance of WebAPI access.
Is there any way to scale the UI for high dpi displays?
On a 2:1 display, the fonts look aliased, if I set the browser zoom to 50%, the UI looks crisp, but everything is a bit small to be useful.
The fix is setting canvas width to window.innerWidth * window.devicePixelRatio, and height to window.innerHeight * window.devicePixelRatio. Then use CSS to maximize the canvas on the screen.
Had to take into account the mouse coordinates too since they were not scaled.
Makes sense to switch the rest of the UI to react though, just for how many people know it.
Many of the students you taught are working on Minecraft now. I'm using so many fundamentals taught by you and my time at DigiPen when designing the Minecraft scripting API today.
Glad to see you're still rocking it.
I just did some profiling on Firefox and I feel like the profiling result doesn't quite make sense but it's saying that the majority of time is spent calling Performance.now() from the clock calls in C++. I'm wondering if that's because we're calling it too many times and maybe we should just call it once per frame.
Maybe not the most helpful comparison haha. Anyways, great work, this is very impressive
Gotta give this a shot on desktop later.
I'm not seeing documentation linked in the readme or within the github project. Are there how-tos and tutorials anywhere?
And with this concrete project I cannot compare, because on my mobile nothing loads, neither on ff or chrome.
[1] https://github.com/gfx-rs/wgpu/pull/3626#issuecomment-173417...
Tiny modules also sound awesome. I'll give the article a read, thanks for this!
On Android firefox on my poor old Nokia Android phone it's way too slow to try, on rotating the UI size hasn't caught up for a few seconds and everything stretches.
Edit: I got Failed to create WebGL context: WebGL creation failed: (Feature_Failure_EGL_Create) Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXAUSTED_DRIVERS) TypeError: a is null.
The Ubuntu is in qemu but should have 3D support, as others mentioned there should be some error surfacing, not just continuing to show the splash screen forever.
On Firefox on Ubuntu, I'm still waiting after a couple of minutes for it to start, so might try again later.
No experience with Zero, but when I did the workshop in 2008 we used the .NET-based engine. I forget the name of it and the backup I have is in a pile of unlabeled burnt CDs.
AMAZING.
Hackable games are such a great in-road for new developers, and for anyone who takes an interest in software because of gaming.
That being said, one of the biggest annoyances I had trying to switch to Godot from Unity is that their Scene view doesn't reflect the Game view at runtime (you can see the hierarchy, but there's no visuals, no gizmos, no debug raycasting or colliders)[1]. It seems this engine has the same missing feature?
[1]https://github.com/godotengine/godot-proposals/issues/7213
Thanks Trevor!
Error: Failed to allocate type at x.allocate (worker-3ec07b2e.js:1:3516) at ImportGlGenTexture (worker-3ec07b2e.js:1:7645) at RaverieEditor-60af6467.wasm:0x1d459ee at RaverieEditor-60af6467.wasm:0xedf9e7 at RaverieEditor-60af6467.wasm:0xedf56b at RaverieEditor-60af6467.wasm:0xdffefa at RaverieEditor-60af6467.wasm:0xf213e3
Reloading fixed it, maybe a race condition between setting up the app and it being ready to run.
Overall though it's a cool project. Personally I would prefer if it was a desktop app as well (with better integrations and less overhead – and certainly with hi-res support!). Congrats on the launch!
I have an old 3D modeler I want to modernize, is it possible to reuse the UI framework? is it imgui based? I don't seem to see a sign of it.
is it easy to be separated out? is the rendering backend swappable? (I hope to use webgpu)
edit: chrome btw
Good find though!
https://github.com/zeroengineteam/ZeroDocs/blob/master/getti...
You also don't need to parent objects to the camera for UI. Not sure how it used to be in the past.
Had to reboot.
Lame.
That makes me think this must be a challenge to host. What are the pain points to hosting it?