[iOS 13 beta] change in SCNCamera setProjectionTransform:?

Hello,

I noticed a new rendering issue in my SceneKit application that appeared with the iOS 13 beta (iOS 12 and below are still fine).

My application supports Portrait and Landscape Right; I obtain a projection matrix from ARKit (which is always consistent with Landscape Right). All I had to do was rotating this matrix by -pi/2 along Z to get my projection right.


In iOS 13, although the landscape right version of my app is fine (no changes), the portrait mode renders my scene with the proportions warped (e.g. if an object correctly takes 90% of my screen in landscape mode, it will also take 90% of my screen in portrait mode, stretched vertically and shrunk horizontally)


SCNMatrix4 matrix = SCNMatrix4FromGLKMatrix4(projection);
if (portrait) {
     matrix = SCNMatrix4Rotate(matrix, -M_PI_2, 0, 0, 1);
}
[_cameraNode.camera setProjectionTransform:matrix];


In other words it looks like my projection matrix rotates successfully (as in the content appears upright as expected) but the scene camera's aspect ratio is now all whack. I cannot find any docs on changes from iOS 12 to 13 that document that behavior.


(I know my input projection matrix is OK, values were the same in iOS 12 & below, and the problem doesn't occur in a Unity app using the same data source)


Thanks!

Replies

Ha! found it

/* Rotate 'm' by 'angle' radians about the vector '(x, y, z)' and return the result:
 * m' = rotation(angle, x, y, z) * m.
 Note: on iOS 10.12 or before, the matrix are combined in the wrong order: m' = m * rotation(angle, x, y, z) */
SCN_EXPORT SCNMatrix4 SCNMatrix4Rotate(SCNMatrix4 m, float angle, float x, float y, float z) API_AVAILABLE(macos(10.10));


therefore the correct code above should be


SCNMatrix4 matrix = SCNMatrix4FromGLKMatrix4(projection);  
if (portrait) {  
     matrix = SCNMatrix4Mult(matrix, SCNMatrix4MakeRotation(-M_PI_2, 0, 0, 1));
}  
[_cameraNode.camera setProjectionTransform:matrix];