29 ms·
WebGL noob question - why is this silky smooth on Safari on my MacbookPro but Mine 3D [0] (and to be fair basically any other Web GL) is noticably low fps? I u
by afro88 10y ago
WebGL noob question - why is this silky smooth on Safari on my MacbookPro but Mine 3D [0] (and to be fair basically any other Web GL) is noticably low fps?
I understand Chrome has better support, and I'm in the habit of launching Chrome to check out Web GL stuff. But I absent mindedly followed this link on Safari and was pleasantly surprised.
[0] http://egraether.com/mine3d/ http://egraether.com/mine3d/
- wodenokoto 10y agoBecause this is asm.js It is a sub-set of javascript that you can roughly think of as javascript-bytecode and this can be heavily optimised in the browser compared to full javascript. http://asmjs.org/faq.html http://asmjs.org/faq.html
- moron4hire 10y agoA few things: First, they aren't apples to apples comparisons. The render loops of these two games will look completely different from each other. OpenLaura is built with Emscripten, so it's actually a C or C++ program that is complied to ASM.js, a subset of JavaScript that some JavaScript interpreters can basically convert 1-to-1 to native code that runs directly on the C runtime rather than needing to be interpreted, specifically because it avoids the dynamic features of JavaScript that require interpreting. Mine3D is straight, object oriented JavaScript. And while I haven't had time to dig too deep into the code yet, I know from experience that it can be very difficult to avoid garbage collections in such a design. There are a lot of places in JS where you implicitly create objects, and there are a lot of idiomatic JS patterns that involve creating short-lived objects that get dumped on the floor very quickly. It's possible to make high-performance, object-oriented JavaScript, but it's very hard. So between the two (and again, this is just speculation), there could be upwards of an 8 to 10x improvement in "performance". That's difficult to put into meaningful terms, though, because again, the two games are built completely differently and do different things. One of the ways in which they are completely different is that Mine3D is using relatively large image files for its textures. Almost all of the variations in materials in Mine3D appear to be done through the textures. I don't want to go to the trouble of checking, but I would not be surprised if the textures used in the OpenLaura demo completely fit inside one of the letters inside one of the Mine3D textures. However, I doubt that is the source of the problems. It could actually go either way. The large textures could be impacting fill rate, or having all of the materials based on the same texture could be improving draw call batching. Much more likely is that Mine3D uses a lot of idle animation, transition effects, and DOM manipulation. A lot of modern graphic design (or rather, more modern than the original Tomb Raider games) emphasize having a lot of visual "breath" in a game. All of that sort of stuff runs on the CPU, where it will be hurt the most by not being tuned completely. And it's really hard to get DOM and WebGL working together smoothly. There are a variety of things you can do in DOM that will trigger disabling hardware-accelerated 2D compositing in the browser, and I am not aware of anywhere they are documented clearly and plainly, so trying to mix the two is fraught with peril. It's best to just not do it and implement your UI for your game 100% in WebGL.