Unity, Mozilla team up to bring PEW! PEW! PEW! to browsers, too

Latest game dev tools feature built-in WebGL exporter

Unity-based game running in a browser via WebGL

GDC 2015 The latest version of the Unity cross-platform game development toolkit is helping to bring advanced 3D graphics and gaming to the web, albeit in baby steps.

Unity 5, released to coincide with the Game Developers Conference taking place in San Francisco this week, includes a preview version of an exporter for WebGL, an evolving standard for browser-based 3D graphics.

Unity worked with Mozilla to enable the feature, which is actually based on a combination of WebGL and asm.js, the Mozilla-developed subset of JavaScript that's touted as an "assembly language for the web."

"The result is native-like performance in desktop browsers without the need for plugins," Mozilla said in a blog post.

Mozilla has shown off native-like 3D games running in its Firefox browser before, but past demos were the result of lots of custom coding. With Unity's new export feature, game devs can repurpose the same lightweight graphics and code they use for their mobile games to run inside the browser.

The exporter takes advantage of a pair of cross-compilation tools, including Mozilla-developed Emscripten and Unity's own IL2CPP.

First, IL2CPP takes all of a game's scripts and converts them from .Net assemblies (Unity's internal code format) to C++ code. Emscripten then takes that output and cross-compiles the C++ code to asm.js.

Because asm.js is a stripped-down dialect of pure JavaScript, it can run in any modern browser. What's more, recent versions of Chrome and Firefox include asm.js-specific optimizations that can execute the cross-compiled code at near-native performance. Microsoft has said it plans to include asm.js optimizations in future versions of Internet Explorer, too, but IE11 offers only partial support for WebGL.


"Teleporter," a demo of Unity-based 3D graphics displayed via the forthcoming WebGL 2

Unity, Madfinger Games, and Dejobaan Games have released a trio of playable demo games that show off the results of the exporter, which you can see here, here, and here, respectively.

Forward to WebGL 2

While the demos run impressively well today, however, WebGL remains a work in progress. WebGL 2, the second generation of the tech, is still under development by the Khronos Group and was unveiled for the first time at GDC on Tuesday.

Where WebGL 1.0 was based on version 2.0 of OpenGL ES – the subset of OpenGL that's tailored to run on embedded systems – the second version of the spec is based on OpenGL ES 3.0 and includes a number of rendering improvements.

"For example, while WebGL 1 only required support for being able to render using 8 textures at a time, WebGL 2 raises this minimum limit to 32," Mozilla explained in a blog post. "WebGL 2 also includes requirements for higher precision in fragment shaders, adds support for features such as occlusion queries and geometry instancing, and introduces developer-controlled access to antialiasing, multiple render targets, and more."

For now, though, Unity 5 – including the preview WebGL exporter that outputs WebGL 1 code – is available for download globally as of Tuesday. The Professional version can be had for a subscription fee of $75 per month or $1,500 for a perpetual license, while the more limited Personal edition is available free of charge. ®


An earlier version of this story said Unity 5's WebGL export tool outputs WebGL 2, which isn't right. Although Mozilla is working with Unity on WebGL 2 support – which is what you see in the "Teleporter" demo video, above – Unity 5 currently outputs WebGL 1, and that's what the playable demos are based on.

"We have captioned the video to reiterate the point we made in the post, that Teleporter showcases WebGL 2. Developers can try out AAA for Awesome and Dead Trigger 2 as examples of what they can do with Unity and WebGL 1 right now," Martin Best, Mozilla's director of platform management, told El Reg.

Sponsored: Beyond the Data Frontier

More from The Register

Firefox Preview, a new browser for Android from Mozilla

Firefox Preview for Android: Mozilla has another go at a mobile browser

Firefox Focus frozen as Mozilla redirects Android effort ... despite small market share

Today in tortured tech analogies: Mozilla lets Firefox loose in the hen house, and by hen house, we mean the tracking cookie jar, er...

Remember when people didn't use browsers from the one of world's biggest adtech giants?
red fox. pic by Shutterstock

This Free software ain't free to make, pal, it's expensive: Mozilla to bankroll Firefox with paid-for premium extras

Browser will remain gratis, optional $$-per-month services to be offered later this year

Mozilla Firefox to begin slow rollout of DNS-over-HTTPS by default at the end of the month

To protect query privacy, browser maker will run everything through Cloudflare
Chrome vs. Firefox

Mozilla says Firefox won't defang ad blockers – unlike a certain ad-giant browser

Extensions still free to use uber-powerful webRequest API to filter crap out of webpages
Google, photo by lightpoet via Shutterstock

Mozilla returns crypto-signed website packaging spec to sender – yes, it's Google

Ad giant's site slurping tech complicates web security model, could give more power to search engines and social networks, Firefox maker warns
Well done, everyone

Finally. Thanks so much, nerds. Google, Apple, Mozilla end government* internet spying for good

* Terms and conditions apply. Offer not valid outside Kazakhstan. Your home may be repossessed if you do not keep up payments
Firefox logo

Awoogah! Awoogah! Firefox fans urged to update and patch zero-day hole exploited in the wild by miscreants

Just make sure you're running the latest version

Biting the hand that feeds IT © 1998–2019