Jump to content

Disable antialias for WebGL, but keep smooth scaling?


olemoritz
 Share

Recommended Posts

I've noticed that disabling antialias for WebGL makes a significant difference in performance on a Retina MacBook (30-40 fps vs. 60), and I think that on a high-resolution screen, antialiasing/multisampling shouldn't really make much of a difference visually.

However, I'm not sure what the correct way to disable it is in Phaser. Setting game.antialias to false does work, but it has the side effect of also disabling smooth scaling for everything, which is great for pixel art, but not always what I want.

I can easily edit phaser.js to modify the _contextOptions, maybe add a "msaa" attribute to game or something like that, but I would obviously prefer not to fork because I'd then have to re-apply this hack for every new version... So, my question is: Is there some "official" way to disable antialiasing for the WebGL context, but still keep smooth scaling for sprites? I've tried setting this.stage.smoothed to true in various state lifecycle methods, but this doesn't seem to have any effect.

Link to comment
Share on other sites

Well, I have tested it, and there is no visible difference, nor would I expect there to be one.

The antialias option I'm talking about is what you get from

<canvasElement>.getContext('webgl').getContextAttributes().antialias

As far as I know, this option basically has the effect of rendering the framebuffer at a higher resolution and then downsampling it, which is obviously pretty expensive. It's not even supported on iOS (not sure about Android), and the effect of this should rarely be visible when rendering in 2D. From my understanding, WebGL doesn't really deal with text rendering at all. Text is basically rendered into an image/texture (usually with antialiasing) before being rendered by WebGL.

The problem is basically that Phaser conflates two different options into one.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...