WebGL vs Canvas

0 favourites
  • 12 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • Just wanted to ask... Apart from shader effects and extra framerate performance, are there any additional advantages to going with WebGL over regular canvas rendering for desktop builds? Memory management is different if I understand right, but what are the implications beyond slower startup times? Does it mean content-heavy games will choke on PC's with little memory for instance?

    I'm asking because I'm getting more steady performance out of non-WebGL rendering. No herky jerky situation going on as far as I can tell so I'm thinking I might as well just roll with canvas... Right?

  • Yes, the memory management means that you'll better be able to manage VRAM usage.

    In the ideal world, there should be no reason at all to ever go with canvas if you aren't forced to.

    What herky jerkiness are you seeing? I thought the whole Chrome jank issue was supposed to be fixed, at least at 60fps.

  • It's no big deal. Just a sense of slightly uneven screen updating from time to time that I don't get with webgl turned off. I don't even know if it's down to drivers or the dual-gpu solution in my laptop or just needing a fresh Windows re-install (I keep putting it off ).

    But if it's some kind of driver/hardware/OS issue and canvas turns out to be less vulnerable to that kind of thing then I'd gladly sacrifice the extra speed for predictable performance across PC's. Unless there are other limitations to it that is.

  • My old-ish laptop with a 512mb graphics card absolutely hated webgl in chrome. Canvas was and still is always butter smooth.... I'm going to do some big image testing tonight to see if I'm mistaken about that on my new machine.

    The label on the webgl tin says it's great. But that's just a selling point and might not reflect reality for everyone.

  • including a game-performance check seems not a bad idea, deciding canvas/webgl, but who wants to bother for fast simple gameplay.. is it actually possible to swith renderer in runtime ?

    maybe problems with webgl will surface more, with other engines using it more, and hopefully improve the situation, but i read sqiddster , there seems not much awareness about it being a big problem on other devsites?

    "funny" thing about the jerkiness, i have two screens, refreshrate was 75hz on one of them, not sure why...

    has bad jerking, move to the other screen 60hz, butter smooth.. put it on the checklist

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • "is it actually possible to swith renderer in runtime ? "

    No, and it might be due ti the fact that without webGL, every single asset of your game is loaded at every given time, while with webGL only necessary parts are. So If a switch could be done, I would think it would force a complete reload which is not something you want to do mid game (in an option menu maybe, but canvas2d being faster than webgl does not mean fast enough in many cases, still would be nice for user experience to have that option in a graphic setting menu, although with every asset being loaded, the crash risk is real for PC with not enough memory, and even without that, the potential is that it may just load images from the disk, which may be a concern).

    All in all, canvas2d is a fallback, nothing else, if there is an issue with webGL, then we either fixing it or working around is a better choice short, mid, and long term wise. Unless the issue is C2 specific, in that case fixing it would do the trick.

  • I noticed this too. All stutter in chrome would disappear when I'd switch WebGL off. My new laptop runs WebGL very smoothly in node-webkit 10.5.

  • Every platform I've ever tested - which is a lot and includes obscure mobile platforms and the like - runs WebGL at least as fast as canvas2d, usually 2-5x faster, and in some cases up to 20x faster (yes, twenty times faster per sprite drawn). WebGL also supports layout-by-layout texture memory management to guarantee maximum memory usage, supports shader effects and has more advanced rendering capabilities that the engine uses in some places for even further optimisation (e.g. the rendering of particle effects is different in WebGL mode). canvas2d exists solely as a fallback for old browsers or blacklisted drivers where WebGL won't run (still ~10% of devices according to webglstats.com). In the long term future, it is likely that the canvas2d renderer will eventually be dropped in favour of WebGL rendering, because it's clearly superior and will simplify the engine code and plugin development if you only need to code for one renderer.

    If you think canvas2d is faster then please share some measurements, since I have made a lot of measurements and canvas2d is never faster, unless there's a weird bug that does something like use a software-rendered WebGL but GPU-accelerated canvas2d (which should not happen on any modern browsers because the C2 engine now specifically declines any software-rendered WebGL and falls back to canvas2d). Still there may be room for improvement in WebGL mode and I can always optimise it for a given measurable .capx.

  • Ashley could it be possible that, behind the scenes, some webGL specifics operations could be software calculated on some platforms (not asking if it happens, but if browser vendors could work around specific bugs with that, which could explain the slow while not being blacklisted)?

  • IIRC there is only one performance caveat with WebGL: large constantly changing text objects. WebGL can't render text so it uses an intermediate 2D canvas and copies that to a WebGL texture. Sprite fonts and unchanging text objects are not affected though. There's also the opportunity for third party plugins to do something incredibly slow in WebGL mode only, but that's not an official part of C2. So as long as none of that happens it should always be faster. Like I say, if you don't believe me or on the chance I missed something, I need to see .capx examples.

  • Hey ASHLEY. Thanks for the detailed rundown. I'm not disputing WebGL's speed over Canvas2D. Oh no no I only felt that Canvas2D looked more consistent in it's screen updates and wanted to double-check with others. And to find out other disadvantages to Canvas2D over WebGL since I do like the idea of something that'll run straight away on any old PC without driver updates or other faffing about. Even if it's slower overall.

  • I think around chromium 38, disabling webGL would give my game a HUGE performance boost in chrome on my low powered PC tablet.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)