Sign in to follow this  
hyperscientist

What is the benefit of using 'resolution' property?

Recommended Posts

Hello, I'm in the process of setting up renderer so it covers whole range of devices and naturally I looked into 'resolution' property of the Renderer. Initially it worked well, but as my code evolved I started to realize it doesn't really help or simplify anything. Today most high end mobiles have ~1440p screens and lets say my device has a devicePixelRatio is 3. What difference does it make to my wellbeing as a developer if my screen has a virtual height of 1440px or 480px? Especially that there is a drawback: with roundPixels set to true (for performance reasons) it lowers the resolution of objects positioning which doesn't really make sense if we want to utilize high resolution screens (and we do since we set resolution to >1). What am I missing? Is this a legacy feature? Just trying to understand, so I would be grateful if you could share your thoughts!

Share this post


Link to post
Share on other sites

Nothing, just a handy variable: stage does not depend on resolution. CSS pixels (480p), width/height is stored in "renderer.screen.width" , real pixels  (1440p), stored in "renderer.view.width". You have also check "PIXI.settings.RESOLUTION" and "PIXI.settings.FILTER_RESOLUTION" because some features use global settings. "renderer.resize" also takes care of CSS resize if you use "autoResize:true" setting (look in source of SystemRenderer for resize method).

Other renderer engines have this variable too.

Share this post


Link to post
Share on other sites

Imagine you create a game at 1920x1080, which runs fine on most devices, but you have some older ones you want to support that aren't performing up to scratch and never will. Ok, well, set the resolution to 0.5, which can also trigger the loader to use @0.5 textures you have provided, and very quickly you have something that can run on lower performing devices. And then you're game gets picked up and you're going to a show to put your game on a big screen. Set the resolution to 2, which can also trigger the loader to use @2 assets provided, and you now have a 4k native resolution game with minimum fuss.

It's also possible, with a small amount of hackery, to change this resolution property dynamically on the renderer. A lot of video games do that these these days ... they have a target resolution, but will lower it if performance starts to suffer to get the fps back up. And once the fps comes up and is stable, it'll raise the resolution back to it's target again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.