@@ -52,7 +52,7 @@ using namespace IECoreCycles;
5252namespace
5353{
5454
55- ccl::Camera *convertCommon ( const IECoreScene::Camera *camera, const std::string &nodeName )
55+ ccl::Camera *convertCommon ( const IECoreScene::Camera *camera, const std::string &nodeName, int frame )
5656{
5757 assert ( camera->typeId () == IECoreScene::Camera::staticTypeId () );
5858 ccl::Camera *ccam = new ccl::Camera ();
@@ -66,7 +66,7 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
6666 ccam->fov = M_PI_2;
6767 if ( camera->getFStop () > 0 .0f )
6868 {
69- ccam->aperturesize = camera->getFocalLength () * camera->getFocalLengthWorldScale () / camera->getFStop ();
69+ ccam->aperturesize = 0 . 5f * camera->getFocalLength () * camera->getFocalLengthWorldScale () / camera->getFStop ();
7070 ccam->focaldistance = camera->getFocusDistance ();
7171 }
7272 }
@@ -87,23 +87,24 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
8787
8888 // Screen window/resolution TODO: full_ might be something to do with cropping?
8989 const Imath::Box2f &frustum = camera->frustum ();
90- const Imath::V2i &resolution = camera->getResolution ();
90+ const Imath::V2i &resolution = camera->renderResolution ();
9191 const float pixelAspectRatio = camera->getPixelAspectRatio ();
9292 ccam->width = resolution[0 ];
9393 ccam->height = resolution[1 ];
9494 ccam->full_width = resolution[0 ];
9595 ccam->full_height = resolution[1 ];
9696 ccam->viewplane .left = frustum.min .x ;
9797 ccam->viewplane .right = frustum.max .x ;
98- ccam->viewplane .bottom = frustum.min .y ;
99- ccam->viewplane .top = frustum.max .y ;
98+ // Invert the viewplane in Y so Gaffer's aperture offsets and overscan are applied in the correct direction
99+ ccam->viewplane .bottom = -frustum.max .y ;
100+ ccam->viewplane .top = -frustum.min .y ;
100101 ccam->aperture_ratio = pixelAspectRatio; // This is more for the bokeh, maybe it should be a separate parameter?
101102
102103 // Clipping planes
103104 const Imath::V2f &clippingPlanes = camera->getClippingPlanes ();
104105 ccam->nearclip = clippingPlanes.x ;
105106 ccam->farclip = clippingPlanes.y ;
106-
107+
107108 // Crop window
108109 if ( camera->hasCropWindow () )
109110 {
@@ -115,27 +116,23 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
115116 ccam->border .clamp ();
116117 }
117118
118- // Shutter TODO: Need to see if this is correct or not, cycles also has a shutter curve...
119+ // Shutter TODO: Cycles also has a shutter curve...
119120 const Imath::V2f &shutter = camera->getShutter ();
120- if ((shutter.x > 0.0 ) && (shutter.y > 0.0 ))
121+ ccam->shuttertime = abs ( shutter.y - shutter.x );
122+
123+ // Set the correct motion position.
124+ const Imath::V2f relativeShutter = shutter - Imath::V2f ( frame );
125+ if ( ( relativeShutter.x >= 0 .0f ) && ( relativeShutter.y > 0 .0f ) )
121126 {
122127 ccam->motion_position = ccl::Camera::MOTION_POSITION_START;
123- ccam->shuttertime = shutter.x + shutter.y ;
124- }
125- else if ((shutter.x < 0.0 ) && (shutter.y > 0.0 ))
126- {
127- ccam->motion_position = ccl::Camera::MOTION_POSITION_CENTER;
128- ccam->shuttertime = abs (shutter.x ) + shutter.y ;
129128 }
130- else if ((shutter .x < 0.0 ) && (shutter .y <= 0.0 ) )
129+ else if ( ( relativeShutter .x < 0 .0f ) && ( relativeShutter .y <= 0 .0f ) )
131130 {
132131 ccam->motion_position = ccl::Camera::MOTION_POSITION_END;
133- ccam->shuttertime = abs (shutter.x ) + abs (shutter.y );
134132 }
135133 else
136134 {
137135 ccam->motion_position = ccl::Camera::MOTION_POSITION_CENTER;
138- ccam->shuttertime = 1.0 ;
139136 }
140137
141138 return ccam;
@@ -155,9 +152,9 @@ namespace CameraAlgo
155152
156153{
157154
158- ccl::Camera *convert ( const IECoreScene::Camera *camera, const std::string &nodeName )
155+ ccl::Camera *convert ( const IECoreScene::Camera *camera, const std::string &nodeName, int frame )
159156{
160- return convertCommon ( camera, nodeName );
157+ return convertCommon ( camera, nodeName, frame );
161158}
162159
163160} // namespace CameraAlgo
0 commit comments