googlevr / cardboard

Open source Cardboard SDK and samples
Other
1.48k stars 252 forks source link

[iPhone12] Screen Size Error #144

Closed UnityKR closed 3 years ago

UnityKR commented 3 years ago

iPhone12 Pro Max iPhone12

iOS 14.1 Cardboard XR SDK 130 Unity 2019.4.5f1

VR Rendering Scale Problem. How to fix it.

iPhone12 pro max

iPhone12 pro max Screen

iPhone12

iPhone12 Screen

jballoffet commented 3 years ago

Thanks for reporting this issue. A fix for this has just been submitted and it will be included in the next release. In case you cannot wait until v1.4.0 is out, you can apply the required changes by yourself. In order to do so, you just need to add the correct DPIs for 2020 iPhone models in this file, by applying the following patch:

diff --git a/sdk/screen_params/ios/screen_params.mm b/sdk/screen_params/ios/screen_params.mm
index 69ce5b9..90c1c12 100644
--- a/sdk/screen_params/ios/screen_params.mm
+++ b/sdk/screen_params/ios/screen_params.mm
@@ -47,6 +47,10 @@ NSString *const kGIPDeviceGenerationiPhone11 = @"iPhone 11";
 NSString *const kGIPDeviceGenerationiPhone11Pro = @"iPhone 11 Pro";
 NSString *const kGIPDeviceGenerationiPhone11ProMax = @"iPhone 11 Pro Max";
 NSString *const kGIPDeviceGenerationiPhoneSimulator = @"iPhone Simulator";
+NSString *const kGIPDeviceGenerationiPhone12Mini = @"iPhone 12 Mini";
+NSString *const kGIPDeviceGenerationiPhone12 = @"iPhone 12";
+NSString *const kGIPDeviceGenerationiPhone12Pro = @"iPhone 12 Pro";
+NSString *const kGIPDeviceGenerationiPhone12ProMax = @"iPhone 12 Pro Max";

 // DPI for iPhone (default) and iPhone+: http://dpi.lv/
 static CGFloat const kDefaultDpi = 326.0f;
@@ -54,6 +58,8 @@ static CGFloat const kIPhonePlusDpi = 401.0f;
 static CGFloat const kIPhoneOledDpi = 458.0f;
 static CGFloat const kIPhoneXrDpi = 324.0f;
 static CGFloat const kIPhoneXsMaxDpi = 456.0f;
+static CGFloat const kIPhone12MiniDpi = 476.0f;
+static CGFloat const kIPhone12Dpi = 460.0f;

 CGFloat getDpi() {
   // Gets model name.
@@ -103,6 +109,10 @@ CGFloat getDpi() {
     @"iPhone12,1" : kGIPDeviceGenerationiPhone11,
     @"iPhone12,3" : kGIPDeviceGenerationiPhone11Pro,
     @"iPhone12,5" : kGIPDeviceGenerationiPhone11ProMax,
+    @"iPhone13,1" : kGIPDeviceGenerationiPhone12Mini,
+    @"iPhone13,2" : kGIPDeviceGenerationiPhone12,
+    @"iPhone13,3" : kGIPDeviceGenerationiPhone12Pro,
+    @"iPhone13,4" : kGIPDeviceGenerationiPhone12ProMax,
   };
   NSString *model = models[modelName];
   if (!model) {
@@ -135,6 +145,10 @@ CGFloat getDpi() {
     kGIPDeviceGenerationiPhone11 : @(kDefaultDpi),
     kGIPDeviceGenerationiPhone11Pro : @(kIPhoneOledDpi),
     kGIPDeviceGenerationiPhone11ProMax : @(kIPhoneOledDpi),
+    kGIPDeviceGenerationiPhone12Mini : @(kIPhone12MiniDpi),
+    kGIPDeviceGenerationiPhone12 : @(kIPhone12Dpi),
+    kGIPDeviceGenerationiPhone12Pro : @(kIPhone12Dpi),
+    kGIPDeviceGenerationiPhone12ProMax : @(kIPhoneOledDpi),
   };

   NSNumber *dpi = dpis[model];
@@ -154,3 +168,4 @@ void getScreenSizeInMeters(int width_pixels, int height_pixels, float* out_width

 }  // namespace screen_params
 }  // namespace cardboard
+
Excubitor commented 3 years ago

What do you have to do if you are using the unity package? (How do you do this in the plugin?, I've tried doing it in xcode after unity export, but it didn't work)

UPDATE: I’ve managed to solve this for testing purposes by modifieing it in xcode after unity export, works while waiting for the next version of google vr.

chaosemer commented 3 years ago

This was fixed in v1.4.0.

AndrewSpalato-FGMNT commented 3 years ago

@Excubitor @jballoffet Do you know where to find the file "screen_params.mm" or "screen_params.h" in Xcode? I am using the Cardboard XR plugin for Unity.

AndrewSpalato-FGMNT commented 3 years ago

@chaosemer I tried v1.4.0 still getting this issue on iPhone 12

BRM15538 commented 7 months ago

Hello everyone! sorry for the ignorance about my question, but, how can i update from version 1.23 to the version 1.4? every time when i click on update button doesn't happen nothing (im using unity 2021.3.29f). Or where y can i put the file screen_params.mm of @jballoffet blessings for all!

image