Fix T45034: MirrorBall rendering on wrong camera axis
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 22 Jun 2015 18:04:46 +0000 (20:04 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 22 Jun 2015 18:09:52 +0000 (20:09 +0200)
This was a mistake in the original code from D1079.

With the current way how direction ot mirror ball works camera should look
into negative Y direction. Corrected it in the camera matrix synchronization,
so no extra calculations are needed at the render time.

That's a bit annoying, but we'd better port it to the release branch, or
otherwise we'll end up with files created with wrong camera mapping after
2.75 release.

intern/cycles/blender/blender_camera.cpp

index 3d23b5ecea8ee36a09d74099b1adc817f0fd8e62..90b42ea4ec22c66185f47ad935fd56af6ce189e7 100644 (file)
@@ -207,19 +207,34 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine b_e
        }
 }
 
-static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
+static Transform blender_camera_matrix(const Transform& tfm,
+                                       const CameraType type,
+                                       const PanoramaType panorama_type)
 {
        Transform result;
 
        if(type == CAMERA_PANORAMA) {
-               /* make it so environment camera needs to be pointed in the direction
-                * of the positive x-axis to match an environment texture, this way
-                * it is looking at the center of the texture */
-               result = tfm *
-                       make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
-                                       0.0f,  0.0f, 1.0f, 0.0f,
-                                      -1.0f,  0.0f, 0.0f, 0.0f,
-                                       0.0f,  0.0f, 0.0f, 1.0f);
+               if(panorama_type == PANORAMA_MIRRORBALL) {
+                       /* Mirror ball camera is looking into the negative Y direction
+                        * which matches texture mirror ball mapping.
+                        */
+                       result = tfm *
+                               make_transform(1.0f, 0.0f, 0.0f, 0.0f,
+                                              0.0f, 0.0f, 1.0f, 0.0f,
+                                              0.0f, 1.0f, 0.0f, 0.0f,
+                                              0.0f, 0.0f, 0.0f, 1.0f);
+               }
+               else {
+                       /* Make it so environment camera needs to be pointed in the direction
+                        * of the positive x-axis to match an environment texture, this way
+                        * it is looking at the center of the texture
+                        */
+                       result = tfm *
+                               make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
+                                               0.0f,  0.0f, 1.0f, 0.0f,
+                                              -1.0f,  0.0f, 0.0f, 0.0f,
+                                               0.0f,  0.0f, 0.0f, 1.0f);
+               }
        }
        else {
                /* note the blender camera points along the negative z-axis */
@@ -365,7 +380,9 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
        cam->bladesrotation = bcam->aperturerotation;
 
        /* transform */
-       cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type);
+       cam->matrix = blender_camera_matrix(bcam->matrix,
+                                           bcam->type,
+                                           bcam->panorama_type);
        cam->motion.pre = cam->matrix;
        cam->motion.post = cam->matrix;
        cam->use_motion = false;
@@ -424,7 +441,7 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
        BL::Array<float, 16> b_ob_matrix;
        b_engine.camera_model_matrix(b_ob, b_ob_matrix);
        Transform tfm = get_transform(b_ob_matrix);
-       tfm = blender_camera_matrix(tfm, cam->type);
+       tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
 
        if(tfm != cam->matrix) {
                VLOG(1) << "Camera " << b_ob.name() << " motion detected.";