BabylonReactNative icon indicating copy to clipboard operation
BabylonReactNative copied to clipboard

Pixel Scaling

Open CedricGuillemet opened this issue 3 years ago • 4 comments
trafficstars

Evaluate state and if we have to do something regarding DPI scaling in Babylon React Native. Related BN issue : https://github.com/BabylonJS/BabylonNative/issues/1016

CedricGuillemet avatar Apr 08 '22 17:04 CedricGuillemet

On Windows: size in OnSizeChanged is logical.

CedricGuillemet avatar Apr 13 '22 13:04 CedricGuillemet

on iOS: MTKView size is in logical coord but its value is multiplied by the content factor here: https://github.com/BabylonJS/BabylonReactNative/blob/7123f41839ac8d0850528ce3f2a26af56b13f74d/Modules/%40babylonjs/react-native-iosandroid/ios/BabylonNativeInterop.mm#L58

It means rendering is done in native resolution. I did a quick try at forcing the contentScaleFactor at 1.0 in EngineViewManager and it properly renders at logical resolution.

Changing contentScaleFactor from the doc:

In general, you should not need to modify the value in this property. However, if your application draws using OpenGL ES, you may want to change the scale factor to trade image quality for rendering performance.

https://developer.apple.com/documentation/uikit/uiview/1622657-contentscalefactor?language=objc

CedricGuillemet avatar Apr 13 '22 15:04 CedricGuillemet

on Android Native window is used to get native size. Rendering is done in native resolution. https://github.com/BabylonJS/BabylonReactNative/blob/7123f41839ac8d0850528ce3f2a26af56b13f74d/Modules/%40babylonjs/react-native-iosandroid/android/src/main/cpp/BabylonNativeInterop.cpp#L69

CedricGuillemet avatar Apr 13 '22 15:04 CedricGuillemet

Related issues in BN : https://github.com/BabylonJS/BabylonNative/issues/1016 https://github.com/BabylonJS/BabylonNative/issues/65

CedricGuillemet avatar Dec 02 '22 09:12 CedricGuillemet