Coming soon - Get a detailed view of why an account is flagged as spam!
view details
3
How does the Unity WebGL export compare to native JavaScript and other JS libraries?
Post Flair (click to view more posts with a particular flair)
Post Body

Since Unity's WebGL export is effectively cross-compiling C# into JavaScript, which is a single-threaded language. The GPU work should be roughly the same efficiency as a native build as it uses your GPU to do the work, however the CPU side is different because it cross-compiles to asm.js, which can't utilize SIMD or multithreading.

As with all cross-compiling, there is the threat that Unity is slower than doing it in JavaScript from the start. If a library is built around WebGL, it would take all the WebGL caveats into account from the start, but Unity's export was created later. It's essentially forcing Unity to work on this platform, which I fear may not be as efficient.

What I wan't to know though isn't how a web build compares to a native build, but rather how Unity WebGL compares to Babylon.js (which also uses WebGL), threejs (which uses WebGL) and phaser (which does not use WebGL, but is 2D only /u/dvdarias corrected this. Uses WebGL whenever possible, otherwise defaults to Canvas).

If the same scalable MMO was created as a web game using all libraries, programmed by the same people, how would it compare performance wise? Would the difference be big enough to warrant avoiding certain libraries?

Also, strictly comparing Phaser to Unity's WebGL, if the game is 2D and we could use Phaser (which would skip the need for WebGL in general and let us just do native JavaScript), would that performance difference be big enough to warrant skipping the Unity engine? Or would the difference still be small enough that the time saved from using Unity is worth it?

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
47,706
Link Karma
3,451
Comment Karma
44,141
Profile updated: 6 days ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago