Does BJS take into account window.devicePixelRatio?

I have strange behaviour with my android device. I think it’s because of its cheap gpu but anyway. I get bad antialiasing for textures on my blocky-style project (like minecraft textures, I use Constants.TEXTURE_NEAREST_SAMPLINGMODE). It has: 1920x1080 and window.devicePixelRatio=1.
On other phones all look good: iphone 6, iphone 11.
The only one solution for that Android phone that I’ve success it’s:
engine.setHardwareScalingLevel( 0.5 );
then it looks great on that Android. And no any difference on iphones. iPhones don’t need to set such option all looks good without it.

As I read it hear it’s not the best solution just for impoving visual quality :grinning:
iPhones have devicePixelRatio=3.0, Android has devicePixelRatio=1.0. My thought was is to check first does BJS use window.devicePixelRatio setting inside the engine?
Do you have any suggestions why do I face such behaviour?

Babylon can take devicePixelRation into account, if you want it to. You need to pass the option to the engine when you create it -

It defaults to false.


here is the code:
Babylon.js/webgpuEngine.ts at master · BabylonJS/Babylon.js (

The reason I show the code is that you said your device has a devicePixelRatio of 1.0, but you only get success with .setHardwareScalingLevel(0.5) - I don’t think that will happen with the adaptToDeviceRatio option… then again I haven’t had any coffee this morning! :smile:

1 Like