Skip to content

Commit 7e1cdf9

Browse files
committed
Panorama support + a way to specify custom parameters to send down to Cycles eg. the sockets found here: https://github.com/boberfly/cycles/blob/74f4cbdee302eaacbdacf513bc76d7fe057bf220/src/render/camera.cpp#L59
Also added a few of the nice things found here: boberfly#33
1 parent 9c94600 commit 7e1cdf9

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

src/GafferCycles/IECoreCyclesPreview/CameraAlgo.cpp

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,14 @@ 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
}
7373
else if( projection == "orthographic" )
7474
{
7575
ccam->type = ccl::CAMERA_ORTHOGRAPHIC;
7676
}
77-
else if( projection == "panorama" )
78-
{
79-
ccam->type = ccl::CAMERA_PANORAMA;
80-
// TODO: Spec out panorama data
81-
}
8277
else
8378
{
8479
ccam->type = ccl::CAMERA_PERSPECTIVE;
@@ -87,16 +82,17 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
8782

8883
// Screen window/resolution TODO: full_ might be something to do with cropping?
8984
const Imath::Box2f &frustum = camera->frustum();
90-
const Imath::V2i &resolution = camera->getResolution();
85+
const Imath::V2i &resolution = camera->renderResolution();
9186
const float pixelAspectRatio = camera->getPixelAspectRatio();
9287
ccam->width = resolution[0];
9388
ccam->height = resolution[1];
9489
ccam->full_width = resolution[0];
9590
ccam->full_height = resolution[1];
9691
ccam->viewplane.left = frustum.min.x;
9792
ccam->viewplane.right = frustum.max.x;
98-
ccam->viewplane.bottom = frustum.min.y;
99-
ccam->viewplane.top = frustum.max.y;
93+
// Invert the viewplane in Y so Gaffer's aperture offsets and overscan are applied in the correct direction
94+
ccam->viewplane.bottom = -frustum.max.y;
95+
ccam->viewplane.top = -frustum.min.y;
10096
ccam->aperture_ratio = pixelAspectRatio; // This is more for the bokeh, maybe it should be a separate parameter?
10197

10298
// Clipping planes
@@ -138,6 +134,42 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
138134
ccam->shuttertime = 1.0;
139135
}
140136

137+
for( CompoundDataMap::const_iterator it = camera->parameters().begin(), eIt = camera->parameters().end(); it != eIt; ++it )
138+
{
139+
if( it->first == "panoramaType" )
140+
{
141+
if( const StringData *data = static_cast<const StringData *>( it->second.get() ) )
142+
{
143+
std::string panoType = data->readable();
144+
145+
if( panoType == "equirectangular" )
146+
{
147+
ccam->type = ccl::CAMERA_PANORAMA;
148+
ccam->panorama_type = ccl::PANORAMA_EQUIRECTANGULAR;
149+
}
150+
else if( panoType == "mirrorball" )
151+
{
152+
ccam->type = ccl::CAMERA_PANORAMA;
153+
ccam->panorama_type = ccl::PANORAMA_MIRRORBALL;
154+
}
155+
else if( panoType == "fisheyeEquidistant" )
156+
{
157+
ccam->type = ccl::CAMERA_PANORAMA;
158+
ccam->panorama_type = ccl::PANORAMA_FISHEYE_EQUIDISTANT;
159+
}
160+
else if( panoType == "fisheyeEquisolid" )
161+
{
162+
ccam->type = ccl::CAMERA_PANORAMA;
163+
ccam->panorama_type = ccl::PANORAMA_FISHEYE_EQUISOLID;
164+
}
165+
}
166+
}
167+
else
168+
{
169+
SocketAlgo::setSocket( ccam, it->first, it->second.get() );
170+
}
171+
}
172+
141173
return ccam;
142174
}
143175

0 commit comments

Comments
 (0)