Jump to content

Question about resolution


Recommended Posts

Hi, I have the following questions about renderer's resolution property:

1. It seems obvious, but I want to be sure: Does increasing the resolution of the renderer reduce performance?

2. In case the above is true, may I implement a switch in my game so that users on low end devices can reduce resolution, increasing performance? If so, is there any problem with changing the renderer's resolution at runtime?


Thanks in advance.

Link to comment
Share on other sites

1. yes, more pixels to draw

2. yes. for example you can read window.devicePixelRatio and set renderer's resolution accordingly, because there's a big probability that device with higher devicePixelRatio (and thus display resolution) needs more performant GPU.

not sure about changing renderer's resolution on the fly, but I think safest way would be to destroy and recreate renderer

Link to comment
Share on other sites

Also for 2. I wouldn't just link devicePixelRatio to the resolution part of PIXI. Otherwise you get mobile devices trying to render at 4k or over... which is just silly.  By all means, adjust resolution based on device, but I'd pick a few resolutions, and select which one to use based on inspecting the device

To change resolution of the renderer dynamically, you can use code like this

const oldResolution = renderer.resolution;

renderer.plugins.interaction.resolution = newResolution;

if ( renderer.gl ) ) {
  renderer.resolution = renderer.rootRenderTarget.resolution = newResolution;
} else {
  renderer.resolution = renderer.rootResolution = newResolution;

renderer.resize( renderer.width / oldResolution, renderer.height / oldResolution );


Link to comment
Share on other sites

of course you dont want mobile devices to be rendering at resolution 4. I meant something like this :

var resolution = Math.floor(window.devicePixelRatio ? window.devicePixelRatio : window.screen.deviceXDPI / window.screen.logicalXDPI) || 1;

if (resolution > 2 || device.isDesktop)
    resolution = 2;


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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