2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 02:50:24 +01:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/camera.h"
|
|
|
|
|
#include "render/scene.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "blender/blender_sync.h"
|
|
|
|
|
#include "blender/blender_util.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_logging.h"
|
2014-12-18 14:40:14 +05:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
/* Blender Camera Intermediate: we first convert both the offline and 3d view
|
|
|
|
|
* render camera to this, and from there convert to our native camera format. */
|
|
|
|
|
|
|
|
|
|
struct BlenderCamera {
|
|
|
|
|
float nearclip;
|
|
|
|
|
float farclip;
|
|
|
|
|
|
2012-02-28 16:44:54 +00:00
|
|
|
CameraType type;
|
2011-04-27 11:58:34 +00:00
|
|
|
float ortho_scale;
|
|
|
|
|
|
|
|
|
|
float lens;
|
2012-04-30 12:49:26 +00:00
|
|
|
float shuttertime;
|
2015-06-29 17:40:13 +02:00
|
|
|
Camera::MotionPosition motion_position;
|
2016-05-08 00:28:21 +02:00
|
|
|
array<float> shutter_curve;
|
2011-09-16 13:14:02 +00:00
|
|
|
|
2015-11-20 14:42:34 +05:00
|
|
|
Camera::RollingShutterType rolling_shutter_type;
|
|
|
|
|
float rolling_shutter_duration;
|
|
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
float aperturesize;
|
|
|
|
|
uint apertureblades;
|
|
|
|
|
float aperturerotation;
|
2011-04-27 11:58:34 +00:00
|
|
|
float focaldistance;
|
|
|
|
|
|
|
|
|
|
float2 shift;
|
|
|
|
|
float2 offset;
|
|
|
|
|
float zoom;
|
|
|
|
|
|
|
|
|
|
float2 pixelaspect;
|
|
|
|
|
|
2014-08-27 10:51:50 +02:00
|
|
|
float aperture_ratio;
|
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
PanoramaType panorama_type;
|
|
|
|
|
float fisheye_fov;
|
|
|
|
|
float fisheye_lens;
|
2015-01-14 23:14:45 +05:00
|
|
|
float latitude_min;
|
|
|
|
|
float latitude_max;
|
|
|
|
|
float longitude_min;
|
|
|
|
|
float longitude_max;
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bool use_spherical_stereo;
|
|
|
|
|
float interocular_distance;
|
|
|
|
|
float convergence_distance;
|
2016-05-17 14:12:29 +02:00
|
|
|
bool use_pole_merge;
|
|
|
|
|
float pole_merge_angle_from;
|
|
|
|
|
float pole_merge_angle_to;
|
2012-05-04 16:20:51 +00:00
|
|
|
|
2011-11-05 11:11:06 +00:00
|
|
|
enum { AUTO, HORIZONTAL, VERTICAL } sensor_fit;
|
|
|
|
|
float sensor_width;
|
|
|
|
|
float sensor_height;
|
|
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
int full_width;
|
|
|
|
|
int full_height;
|
|
|
|
|
|
2012-11-10 22:31:29 +00:00
|
|
|
BoundBox2D border;
|
|
|
|
|
BoundBox2D pano_viewplane;
|
2015-01-27 21:36:14 +05:00
|
|
|
BoundBox2D viewport_camera_border;
|
2012-06-06 23:27:43 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Transform matrix;
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_init(BlenderCamera *bcam,
|
|
|
|
|
BL::RenderSettings& b_render)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
memset(bcam, 0, sizeof(BlenderCamera));
|
|
|
|
|
|
2012-02-28 16:44:54 +00:00
|
|
|
bcam->type = CAMERA_PERSPECTIVE;
|
2011-04-27 11:58:34 +00:00
|
|
|
bcam->zoom = 1.0f;
|
|
|
|
|
bcam->pixelaspect = make_float2(1.0f, 1.0f);
|
2011-11-05 11:11:06 +00:00
|
|
|
bcam->sensor_width = 32.0f;
|
|
|
|
|
bcam->sensor_height = 18.0f;
|
|
|
|
|
bcam->sensor_fit = BlenderCamera::AUTO;
|
2012-04-30 12:49:26 +00:00
|
|
|
bcam->shuttertime = 1.0f;
|
2015-06-29 17:40:13 +02:00
|
|
|
bcam->motion_position = Camera::MOTION_POSITION_CENTER;
|
2015-11-20 14:42:34 +05:00
|
|
|
bcam->rolling_shutter_type = Camera::ROLLING_SHUTTER_NONE;
|
|
|
|
|
bcam->rolling_shutter_duration = 0.1f;
|
2012-11-10 22:31:29 +00:00
|
|
|
bcam->border.right = 1.0f;
|
|
|
|
|
bcam->border.top = 1.0f;
|
|
|
|
|
bcam->pano_viewplane.right = 1.0f;
|
|
|
|
|
bcam->pano_viewplane.top = 1.0f;
|
2015-01-27 21:36:14 +05:00
|
|
|
bcam->viewport_camera_border.right = 1.0f;
|
|
|
|
|
bcam->viewport_camera_border.top = 1.0f;
|
2012-11-23 02:10:13 +00:00
|
|
|
|
|
|
|
|
/* render resolution */
|
2013-05-16 21:53:21 +00:00
|
|
|
bcam->full_width = render_resolution_x(b_render);
|
|
|
|
|
bcam->full_height = render_resolution_y(b_render);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static float blender_camera_focal_distance(BL::RenderEngine& b_engine,
|
|
|
|
|
BL::Object& b_ob,
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
BL::Camera& b_camera,
|
|
|
|
|
BlenderCamera *bcam)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
BL::Object b_dof_object = b_camera.dof_object();
|
|
|
|
|
|
|
|
|
|
if(!b_dof_object)
|
|
|
|
|
return b_camera.dof_distance();
|
|
|
|
|
|
2011-12-29 23:34:25 +00:00
|
|
|
/* for dof object, return distance along camera Z direction */
|
2015-04-06 10:40:12 -03:00
|
|
|
BL::Array<float, 16> b_ob_matrix;
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
b_engine.camera_model_matrix(b_ob, bcam->use_spherical_stereo, b_ob_matrix);
|
|
|
|
|
Transform obmat = transform_clear_scale(get_transform(b_ob_matrix));
|
2011-04-27 11:58:34 +00:00
|
|
|
Transform dofmat = get_transform(b_dof_object.matrix_world());
|
2015-09-07 13:29:52 +10:00
|
|
|
float3 view_dir = normalize(transform_get_column(&obmat, 2));
|
|
|
|
|
float3 dof_dir = transform_get_column(&obmat, 3) - transform_get_column(&dofmat, 3);
|
|
|
|
|
return fabsf(dot(view_dir, dof_dir));
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_from_object(BlenderCamera *bcam,
|
|
|
|
|
BL::RenderEngine& b_engine,
|
|
|
|
|
BL::Object& b_ob,
|
|
|
|
|
bool skip_panorama = false)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
BL::ID b_ob_data = b_ob.data();
|
|
|
|
|
|
|
|
|
|
if(b_ob_data.is_a(&RNA_Camera)) {
|
|
|
|
|
BL::Camera b_camera(b_ob_data);
|
|
|
|
|
PointerRNA ccamera = RNA_pointer_get(&b_camera.ptr, "cycles");
|
|
|
|
|
|
|
|
|
|
bcam->nearclip = b_camera.clip_start();
|
|
|
|
|
bcam->farclip = b_camera.clip_end();
|
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
switch(b_camera.type())
|
|
|
|
|
{
|
|
|
|
|
case BL::Camera::type_ORTHO:
|
|
|
|
|
bcam->type = CAMERA_ORTHOGRAPHIC;
|
|
|
|
|
break;
|
|
|
|
|
case BL::Camera::type_PANO:
|
2012-10-01 17:09:12 +00:00
|
|
|
if(!skip_panorama)
|
|
|
|
|
bcam->type = CAMERA_PANORAMA;
|
|
|
|
|
else
|
|
|
|
|
bcam->type = CAMERA_PERSPECTIVE;
|
2012-05-04 16:20:51 +00:00
|
|
|
break;
|
|
|
|
|
case BL::Camera::type_PERSP:
|
|
|
|
|
default:
|
|
|
|
|
bcam->type = CAMERA_PERSPECTIVE;
|
|
|
|
|
break;
|
2016-02-10 03:25:53 +05:00
|
|
|
}
|
2012-05-04 16:20:51 +00:00
|
|
|
|
2016-02-10 15:09:45 +01:00
|
|
|
bcam->panorama_type = (PanoramaType)get_enum(ccamera,
|
|
|
|
|
"panorama_type",
|
|
|
|
|
PANORAMA_NUM_TYPES,
|
|
|
|
|
PANORAMA_EQUIRECTANGULAR);
|
2012-05-04 16:20:51 +00:00
|
|
|
|
|
|
|
|
bcam->fisheye_fov = RNA_float_get(&ccamera, "fisheye_fov");
|
|
|
|
|
bcam->fisheye_lens = RNA_float_get(&ccamera, "fisheye_lens");
|
2015-01-14 23:14:45 +05:00
|
|
|
bcam->latitude_min = RNA_float_get(&ccamera, "latitude_min");
|
|
|
|
|
bcam->latitude_max = RNA_float_get(&ccamera, "latitude_max");
|
|
|
|
|
bcam->longitude_min = RNA_float_get(&ccamera, "longitude_min");
|
|
|
|
|
bcam->longitude_max = RNA_float_get(&ccamera, "longitude_max");
|
2012-05-04 16:20:51 +00:00
|
|
|
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bcam->interocular_distance = b_camera.stereo().interocular_distance();
|
2016-03-11 21:58:47 +05:00
|
|
|
if(b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {
|
|
|
|
|
bcam->convergence_distance = FLT_MAX;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bcam->convergence_distance = b_camera.stereo().convergence_distance();
|
|
|
|
|
}
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bcam->use_spherical_stereo = b_engine.use_spherical_stereo(b_ob);
|
|
|
|
|
|
2016-05-17 14:12:29 +02:00
|
|
|
bcam->use_pole_merge = b_camera.stereo().use_pole_merge();
|
|
|
|
|
bcam->pole_merge_angle_from = b_camera.stereo().pole_merge_angle_from();
|
|
|
|
|
bcam->pole_merge_angle_to = b_camera.stereo().pole_merge_angle_to();
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
bcam->ortho_scale = b_camera.ortho_scale();
|
|
|
|
|
|
|
|
|
|
bcam->lens = b_camera.lens();
|
2012-03-07 13:01:30 +00:00
|
|
|
|
|
|
|
|
/* allow f/stop number to change aperture_size but still
|
2012-06-09 17:22:52 +00:00
|
|
|
* give manual control over aperture radius */
|
2016-02-10 03:25:53 +05:00
|
|
|
int aperture_type = get_enum(ccamera, "aperture_type");
|
2012-03-07 13:01:30 +00:00
|
|
|
|
|
|
|
|
if(aperture_type == 1) {
|
|
|
|
|
float fstop = RNA_float_get(&ccamera, "aperture_fstop");
|
2013-03-21 02:38:11 +00:00
|
|
|
fstop = max(fstop, 1e-5f);
|
|
|
|
|
|
|
|
|
|
if(bcam->type == CAMERA_ORTHOGRAPHIC)
|
|
|
|
|
bcam->aperturesize = 1.0f/(2.0f*fstop);
|
|
|
|
|
else
|
|
|
|
|
bcam->aperturesize = (bcam->lens*1e-3f)/(2.0f*fstop);
|
2012-03-07 13:01:30 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
bcam->aperturesize = RNA_float_get(&ccamera, "aperture_size");
|
|
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
bcam->apertureblades = RNA_int_get(&ccamera, "aperture_blades");
|
|
|
|
|
bcam->aperturerotation = RNA_float_get(&ccamera, "aperture_rotation");
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bcam->focaldistance = blender_camera_focal_distance(b_engine, b_ob, b_camera, bcam);
|
2014-08-27 10:51:50 +02:00
|
|
|
bcam->aperture_ratio = RNA_float_get(&ccamera, "aperture_ratio");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bcam->shift.x = b_engine.camera_shift_x(b_ob, bcam->use_spherical_stereo);
|
2011-04-27 11:58:34 +00:00
|
|
|
bcam->shift.y = b_camera.shift_y();
|
2011-11-05 11:11:06 +00:00
|
|
|
|
|
|
|
|
bcam->sensor_width = b_camera.sensor_width();
|
|
|
|
|
bcam->sensor_height = b_camera.sensor_height();
|
|
|
|
|
|
|
|
|
|
if(b_camera.sensor_fit() == BL::Camera::sensor_fit_AUTO)
|
|
|
|
|
bcam->sensor_fit = BlenderCamera::AUTO;
|
|
|
|
|
else if(b_camera.sensor_fit() == BL::Camera::sensor_fit_HORIZONTAL)
|
|
|
|
|
bcam->sensor_fit = BlenderCamera::HORIZONTAL;
|
|
|
|
|
else
|
|
|
|
|
bcam->sensor_fit = BlenderCamera::VERTICAL;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* from lamp not implemented yet */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-22 20:04:46 +02:00
|
|
|
static Transform blender_camera_matrix(const Transform& tfm,
|
|
|
|
|
const CameraType type,
|
|
|
|
|
const PanoramaType panorama_type)
|
2012-04-30 12:49:26 +00:00
|
|
|
{
|
|
|
|
|
Transform result;
|
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
if(type == CAMERA_PANORAMA) {
|
2015-06-22 20:04:46 +02:00
|
|
|
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);
|
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* note the blender camera points along the negative z-axis */
|
|
|
|
|
result = tfm * transform_scale(1.0f, 1.0f, -1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return transform_clear_scale(result);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-21 15:36:35 +02:00
|
|
|
static void blender_camera_viewplane(BlenderCamera *bcam,
|
|
|
|
|
int width, int height,
|
|
|
|
|
BoundBox2D *viewplane,
|
|
|
|
|
float *aspectratio,
|
|
|
|
|
float *sensor_size)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
/* dimensions */
|
2014-05-03 07:22:14 +10:00
|
|
|
float xratio = (float)width*bcam->pixelaspect.x;
|
|
|
|
|
float yratio = (float)height*bcam->pixelaspect.y;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* compute x/y aspect and ratio */
|
2012-06-06 23:27:43 +00:00
|
|
|
float xaspect, yaspect;
|
2011-11-05 11:11:06 +00:00
|
|
|
bool horizontal_fit;
|
2012-05-04 16:20:51 +00:00
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
/* sensor fitting */
|
2011-11-05 11:11:06 +00:00
|
|
|
if(bcam->sensor_fit == BlenderCamera::AUTO) {
|
|
|
|
|
horizontal_fit = (xratio > yratio);
|
2015-07-21 15:36:35 +02:00
|
|
|
if(sensor_size != NULL) {
|
|
|
|
|
*sensor_size = bcam->sensor_width;
|
|
|
|
|
}
|
2011-11-05 11:11:06 +00:00
|
|
|
}
|
|
|
|
|
else if(bcam->sensor_fit == BlenderCamera::HORIZONTAL) {
|
|
|
|
|
horizontal_fit = true;
|
2015-07-21 15:36:35 +02:00
|
|
|
if(sensor_size != NULL) {
|
|
|
|
|
*sensor_size = bcam->sensor_width;
|
|
|
|
|
}
|
2011-11-05 11:11:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
horizontal_fit = false;
|
2015-07-21 15:36:35 +02:00
|
|
|
if(sensor_size != NULL) {
|
|
|
|
|
*sensor_size = bcam->sensor_height;
|
|
|
|
|
}
|
2011-11-05 11:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(horizontal_fit) {
|
2015-07-21 15:36:35 +02:00
|
|
|
if(aspectratio != NULL) {
|
|
|
|
|
*aspectratio = xratio/yratio;
|
|
|
|
|
}
|
2012-06-09 18:56:12 +00:00
|
|
|
xaspect = *aspectratio;
|
|
|
|
|
yaspect = 1.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-07-21 15:36:35 +02:00
|
|
|
if(aspectratio != NULL) {
|
|
|
|
|
*aspectratio = yratio/xratio;
|
|
|
|
|
}
|
2012-06-09 18:56:12 +00:00
|
|
|
xaspect = 1.0f;
|
|
|
|
|
yaspect = *aspectratio;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* modify aspect for orthographic scale */
|
2012-02-28 16:44:54 +00:00
|
|
|
if(bcam->type == CAMERA_ORTHOGRAPHIC) {
|
2012-06-06 23:27:43 +00:00
|
|
|
xaspect = xaspect*bcam->ortho_scale/(*aspectratio*2.0f);
|
|
|
|
|
yaspect = yaspect*bcam->ortho_scale/(*aspectratio*2.0f);
|
2015-07-21 15:36:35 +02:00
|
|
|
if(aspectratio != NULL) {
|
|
|
|
|
*aspectratio = bcam->ortho_scale/2.0f;
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
if(bcam->type == CAMERA_PANORAMA) {
|
2012-02-28 16:44:54 +00:00
|
|
|
/* set viewplane */
|
2015-07-21 15:36:35 +02:00
|
|
|
if(viewplane != NULL) {
|
|
|
|
|
*viewplane = bcam->pano_viewplane;
|
|
|
|
|
}
|
2012-02-28 16:44:54 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* set viewplane */
|
2015-07-21 15:36:35 +02:00
|
|
|
if(viewplane != NULL) {
|
|
|
|
|
viewplane->left = -xaspect;
|
|
|
|
|
viewplane->right = xaspect;
|
|
|
|
|
viewplane->bottom = -yaspect;
|
|
|
|
|
viewplane->top = yaspect;
|
|
|
|
|
|
|
|
|
|
/* zoom for 3d camera view */
|
|
|
|
|
*viewplane = (*viewplane) * bcam->zoom;
|
|
|
|
|
|
|
|
|
|
/* modify viewplane with camera shift and 3d camera view offset */
|
|
|
|
|
float dx = 2.0f*(*aspectratio*bcam->shift.x + bcam->offset.x*xaspect*2.0f);
|
|
|
|
|
float dy = 2.0f*(*aspectratio*bcam->shift.y + bcam->offset.y*yaspect*2.0f);
|
|
|
|
|
|
|
|
|
|
viewplane->left += dx;
|
|
|
|
|
viewplane->right += dx;
|
|
|
|
|
viewplane->bottom += dy;
|
|
|
|
|
viewplane->top += dy;
|
|
|
|
|
}
|
2012-02-28 16:44:54 +00:00
|
|
|
}
|
2012-06-06 23:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height, const char *viewname)
|
2012-06-06 23:27:43 +00:00
|
|
|
{
|
|
|
|
|
/* copy camera to compare later */
|
|
|
|
|
Camera prevcam = *cam;
|
|
|
|
|
float aspectratio, sensor_size;
|
|
|
|
|
|
|
|
|
|
/* viewplane */
|
|
|
|
|
blender_camera_viewplane(bcam, width, height,
|
2012-11-10 22:31:29 +00:00
|
|
|
&cam->viewplane, &aspectratio, &sensor_size);
|
2012-06-06 23:27:43 +00:00
|
|
|
|
2016-04-11 22:49:09 +02:00
|
|
|
cam->width = bcam->full_width;
|
|
|
|
|
cam->height = bcam->full_height;
|
|
|
|
|
|
|
|
|
|
cam->full_width = width;
|
|
|
|
|
cam->full_height = height;
|
|
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
/* panorama sensor */
|
2015-03-28 00:15:15 +05:00
|
|
|
if(bcam->type == CAMERA_PANORAMA && bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID) {
|
2014-05-03 07:22:14 +10:00
|
|
|
float fit_xratio = (float)bcam->full_width*bcam->pixelaspect.x;
|
|
|
|
|
float fit_yratio = (float)bcam->full_height*bcam->pixelaspect.y;
|
2012-11-23 02:10:13 +00:00
|
|
|
bool horizontal_fit;
|
|
|
|
|
float sensor_size;
|
2012-11-21 01:07:30 +00:00
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
if(bcam->sensor_fit == BlenderCamera::AUTO) {
|
|
|
|
|
horizontal_fit = (fit_xratio > fit_yratio);
|
|
|
|
|
sensor_size = bcam->sensor_width;
|
|
|
|
|
}
|
|
|
|
|
else if(bcam->sensor_fit == BlenderCamera::HORIZONTAL) {
|
|
|
|
|
horizontal_fit = true;
|
|
|
|
|
sensor_size = bcam->sensor_width;
|
|
|
|
|
}
|
2012-11-23 17:39:41 +00:00
|
|
|
else { /* vertical */
|
2012-11-23 02:10:13 +00:00
|
|
|
horizontal_fit = false;
|
|
|
|
|
sensor_size = bcam->sensor_height;
|
|
|
|
|
}
|
2012-11-21 01:07:30 +00:00
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
if(horizontal_fit) {
|
|
|
|
|
cam->sensorwidth = sensor_size;
|
|
|
|
|
cam->sensorheight = sensor_size * fit_yratio / fit_xratio;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cam->sensorwidth = sensor_size * fit_xratio / fit_yratio;
|
|
|
|
|
cam->sensorheight = sensor_size;
|
|
|
|
|
}
|
2012-11-21 01:07:30 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* clipping distances */
|
|
|
|
|
cam->nearclip = bcam->nearclip;
|
|
|
|
|
cam->farclip = bcam->farclip;
|
|
|
|
|
|
2012-02-28 16:44:54 +00:00
|
|
|
/* type */
|
|
|
|
|
cam->type = bcam->type;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-05-04 16:20:51 +00:00
|
|
|
/* panorama */
|
|
|
|
|
cam->panorama_type = bcam->panorama_type;
|
|
|
|
|
cam->fisheye_fov = bcam->fisheye_fov;
|
|
|
|
|
cam->fisheye_lens = bcam->fisheye_lens;
|
2015-01-14 23:14:45 +05:00
|
|
|
cam->latitude_min = bcam->latitude_min;
|
|
|
|
|
cam->latitude_max = bcam->latitude_max;
|
|
|
|
|
|
|
|
|
|
cam->longitude_min = bcam->longitude_min;
|
|
|
|
|
cam->longitude_max = bcam->longitude_max;
|
2012-05-04 16:20:51 +00:00
|
|
|
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
/* panorama stereo */
|
|
|
|
|
cam->interocular_distance = bcam->interocular_distance;
|
|
|
|
|
cam->convergence_distance = bcam->convergence_distance;
|
|
|
|
|
cam->use_spherical_stereo = bcam->use_spherical_stereo;
|
|
|
|
|
|
|
|
|
|
if(cam->use_spherical_stereo) {
|
|
|
|
|
if(strcmp(viewname, "left") == 0)
|
|
|
|
|
cam->stereo_eye = Camera::STEREO_LEFT;
|
|
|
|
|
else if(strcmp(viewname, "right") == 0)
|
|
|
|
|
cam->stereo_eye = Camera::STEREO_RIGHT;
|
|
|
|
|
else
|
|
|
|
|
cam->stereo_eye = Camera::STEREO_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 14:12:29 +02:00
|
|
|
cam->use_pole_merge = bcam->use_pole_merge;
|
|
|
|
|
cam->pole_merge_angle_from = bcam->pole_merge_angle_from;
|
|
|
|
|
cam->pole_merge_angle_to = bcam->pole_merge_angle_to;
|
|
|
|
|
|
2014-08-27 10:51:50 +02:00
|
|
|
/* anamorphic lens bokeh */
|
|
|
|
|
cam->aperture_ratio = bcam->aperture_ratio;
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* perspective */
|
2012-06-09 17:45:22 +00:00
|
|
|
cam->fov = 2.0f * atanf((0.5f * sensor_size) / bcam->lens / aspectratio);
|
2011-04-27 11:58:34 +00:00
|
|
|
cam->focaldistance = bcam->focaldistance;
|
2011-09-16 13:14:02 +00:00
|
|
|
cam->aperturesize = bcam->aperturesize;
|
|
|
|
|
cam->blades = bcam->apertureblades;
|
|
|
|
|
cam->bladesrotation = bcam->aperturerotation;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-02-28 16:44:54 +00:00
|
|
|
/* transform */
|
2015-06-22 20:04:46 +02:00
|
|
|
cam->matrix = blender_camera_matrix(bcam->matrix,
|
|
|
|
|
bcam->type,
|
|
|
|
|
bcam->panorama_type);
|
2012-04-30 12:49:26 +00:00
|
|
|
cam->motion.pre = cam->matrix;
|
|
|
|
|
cam->motion.post = cam->matrix;
|
|
|
|
|
cam->use_motion = false;
|
2015-07-21 15:36:35 +02:00
|
|
|
cam->use_perspective_motion = false;
|
2012-04-30 12:49:26 +00:00
|
|
|
cam->shuttertime = bcam->shuttertime;
|
2015-07-21 15:36:35 +02:00
|
|
|
cam->fov_pre = cam->fov;
|
|
|
|
|
cam->fov_post = cam->fov;
|
2015-06-29 17:40:13 +02:00
|
|
|
cam->motion_position = bcam->motion_position;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-11-20 14:42:34 +05:00
|
|
|
cam->rolling_shutter_type = bcam->rolling_shutter_type;
|
|
|
|
|
cam->rolling_shutter_duration = bcam->rolling_shutter_duration;
|
|
|
|
|
|
2016-05-08 00:28:21 +02:00
|
|
|
cam->shutter_curve = bcam->shutter_curve;
|
2015-10-27 19:00:51 +05:00
|
|
|
|
2012-06-06 23:27:43 +00:00
|
|
|
/* border */
|
2012-11-10 22:31:29 +00:00
|
|
|
cam->border = bcam->border;
|
2015-01-27 21:36:14 +05:00
|
|
|
cam->viewport_camera_border = bcam->viewport_camera_border;
|
2012-06-06 23:27:43 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* set update flag */
|
|
|
|
|
if(cam->modified(prevcam))
|
|
|
|
|
cam->tag_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sync Render Camera */
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_camera(BL::RenderSettings& b_render,
|
|
|
|
|
BL::Object& b_override,
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
int width, int height,
|
|
|
|
|
const char *viewname)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
BlenderCamera bcam;
|
2015-03-27 15:47:55 +05:00
|
|
|
blender_camera_init(&bcam, b_render);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* pixel aspect */
|
2013-03-14 07:38:37 +00:00
|
|
|
bcam.pixelaspect.x = b_render.pixel_aspect_x();
|
|
|
|
|
bcam.pixelaspect.y = b_render.pixel_aspect_y();
|
|
|
|
|
bcam.shuttertime = b_render.motion_blur_shutter();
|
2016-01-30 14:18:29 +01:00
|
|
|
|
|
|
|
|
BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
|
|
|
|
|
curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-06-29 17:40:13 +02:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2016-02-10 15:09:45 +01:00
|
|
|
bcam.motion_position =
|
|
|
|
|
(Camera::MotionPosition)get_enum(cscene,
|
|
|
|
|
"motion_blur_position",
|
|
|
|
|
Camera::MOTION_NUM_POSITIONS,
|
|
|
|
|
Camera::MOTION_POSITION_CENTER);
|
|
|
|
|
bcam.rolling_shutter_type =
|
|
|
|
|
(Camera::RollingShutterType)get_enum(cscene,
|
|
|
|
|
"rolling_shutter_type",
|
|
|
|
|
Camera::ROLLING_SHUTTER_NUM_TYPES,
|
|
|
|
|
Camera::ROLLING_SHUTTER_NONE);
|
2015-11-20 14:42:34 +05:00
|
|
|
bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");
|
|
|
|
|
|
2012-06-06 23:27:43 +00:00
|
|
|
/* border */
|
2013-03-14 07:38:37 +00:00
|
|
|
if(b_render.use_border()) {
|
|
|
|
|
bcam.border.left = b_render.border_min_x();
|
|
|
|
|
bcam.border.right = b_render.border_max_x();
|
|
|
|
|
bcam.border.bottom = b_render.border_min_y();
|
|
|
|
|
bcam.border.top = b_render.border_max_y();
|
2012-06-06 23:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* camera object */
|
|
|
|
|
BL::Object b_ob = b_scene.camera();
|
|
|
|
|
|
2012-04-13 17:42:03 +00:00
|
|
|
if(b_override)
|
|
|
|
|
b_ob = b_override;
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(b_ob) {
|
2015-04-06 10:40:12 -03:00
|
|
|
BL::Array<float, 16> b_ob_matrix;
|
|
|
|
|
blender_camera_from_object(&bcam, b_engine, b_ob);
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix);
|
2015-04-06 10:40:12 -03:00
|
|
|
bcam.matrix = get_transform(b_ob_matrix);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sync */
|
|
|
|
|
Camera *cam = scene->camera;
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
blender_camera_sync(cam, &bcam, width, height, viewname);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_camera_motion(BL::RenderSettings& b_render,
|
|
|
|
|
BL::Object& b_ob,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
|
float motion_time)
|
2012-04-30 12:49:26 +00:00
|
|
|
{
|
2015-07-24 21:18:17 +02:00
|
|
|
if(!b_ob)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
Camera *cam = scene->camera;
|
2015-04-06 10:40:12 -03:00
|
|
|
BL::Array<float, 16> b_ob_matrix;
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
b_engine.camera_model_matrix(b_ob, cam->use_spherical_stereo, b_ob_matrix);
|
2015-04-06 10:40:12 -03:00
|
|
|
Transform tfm = get_transform(b_ob_matrix);
|
2015-06-22 20:04:46 +02:00
|
|
|
tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
|
2012-04-30 12:49:26 +00:00
|
|
|
|
|
|
|
|
if(tfm != cam->matrix) {
|
2014-12-18 14:40:14 +05:00
|
|
|
VLOG(1) << "Camera " << b_ob.name() << " motion detected.";
|
2014-03-29 13:03:46 +01:00
|
|
|
if(motion_time == -1.0f) {
|
2012-04-30 12:49:26 +00:00
|
|
|
cam->motion.pre = tfm;
|
2014-03-29 13:03:46 +01:00
|
|
|
cam->use_motion = true;
|
|
|
|
|
}
|
|
|
|
|
else if(motion_time == 1.0f) {
|
2012-04-30 12:49:26 +00:00
|
|
|
cam->motion.post = tfm;
|
2014-03-29 13:03:46 +01:00
|
|
|
cam->use_motion = true;
|
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
2015-07-21 15:36:35 +02:00
|
|
|
|
|
|
|
|
if(cam->type == CAMERA_PERSPECTIVE) {
|
|
|
|
|
BlenderCamera bcam;
|
|
|
|
|
float aspectratio, sensor_size;
|
|
|
|
|
blender_camera_init(&bcam, b_render);
|
2015-10-15 19:32:18 +05:00
|
|
|
|
2016-05-28 11:54:08 +02:00
|
|
|
/* TODO(sergey): Consider making it a part of blender_camera_init(). */
|
|
|
|
|
bcam.pixelaspect.x = b_render.pixel_aspect_x();
|
|
|
|
|
bcam.pixelaspect.y = b_render.pixel_aspect_y();
|
|
|
|
|
|
2015-07-21 15:36:35 +02:00
|
|
|
blender_camera_from_object(&bcam, b_engine, b_ob);
|
|
|
|
|
blender_camera_viewplane(&bcam,
|
|
|
|
|
width, height,
|
|
|
|
|
NULL,
|
|
|
|
|
&aspectratio,
|
|
|
|
|
&sensor_size);
|
|
|
|
|
/* TODO(sergey): De-duplicate calculation with camera sync. */
|
|
|
|
|
float fov = 2.0f * atanf((0.5f * sensor_size) / bcam.lens / aspectratio);
|
|
|
|
|
if(fov != cam->fov) {
|
|
|
|
|
VLOG(1) << "Camera " << b_ob.name() << " FOV change detected.";
|
|
|
|
|
if(motion_time == -1.0f) {
|
|
|
|
|
cam->fov_pre = fov;
|
|
|
|
|
cam->use_perspective_motion = true;
|
|
|
|
|
}
|
|
|
|
|
else if(motion_time == 1.0f) {
|
|
|
|
|
cam->fov_post = fov;
|
|
|
|
|
cam->use_perspective_motion = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Sync 3D View Camera */
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_view_subset(BL::RenderEngine& b_engine,
|
|
|
|
|
BL::RenderSettings& b_render,
|
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
|
BL::Object& b_ob,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height,
|
|
|
|
|
BoundBox2D *view_box,
|
|
|
|
|
BoundBox2D *cam_box);
|
|
|
|
|
|
|
|
|
|
static void blender_camera_from_view(BlenderCamera *bcam,
|
|
|
|
|
BL::RenderEngine& b_engine,
|
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height,
|
|
|
|
|
bool skip_panorama = false)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
/* 3d view parameters */
|
2012-06-06 23:27:43 +00:00
|
|
|
bcam->nearclip = b_v3d.clip_start();
|
|
|
|
|
bcam->farclip = b_v3d.clip_end();
|
|
|
|
|
bcam->lens = b_v3d.lens();
|
|
|
|
|
bcam->shuttertime = b_scene.render().motion_blur_shutter();
|
2016-01-30 14:18:29 +01:00
|
|
|
|
|
|
|
|
BL::CurveMapping b_shutter_curve(b_scene.render().motion_blur_shutter_curve());
|
|
|
|
|
curvemapping_to_array(b_shutter_curve, bcam->shutter_curve, RAMP_TABLE_SIZE);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) {
|
|
|
|
|
/* camera view */
|
2012-04-12 11:42:18 +00:00
|
|
|
BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
if(b_ob) {
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_from_object(bcam, b_engine, b_ob, skip_panorama);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-11-10 22:31:29 +00:00
|
|
|
if(!skip_panorama && bcam->type == CAMERA_PANORAMA) {
|
|
|
|
|
/* in panorama camera view, we map viewplane to camera border */
|
|
|
|
|
BoundBox2D view_box, cam_box;
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::RenderSettings b_render_settings(b_scene.render());
|
|
|
|
|
blender_camera_view_subset(b_engine,
|
|
|
|
|
b_render_settings,
|
|
|
|
|
b_scene,
|
|
|
|
|
b_ob,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_rv3d,
|
|
|
|
|
width, height,
|
|
|
|
|
&view_box,
|
|
|
|
|
&cam_box);
|
2012-11-10 22:31:29 +00:00
|
|
|
|
|
|
|
|
bcam->pano_viewplane = view_box.make_relative_to(cam_box);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* magic zoom formula */
|
|
|
|
|
bcam->zoom = (float)b_rv3d.view_camera_zoom();
|
|
|
|
|
bcam->zoom = (1.41421f + bcam->zoom/50.0f);
|
|
|
|
|
bcam->zoom *= bcam->zoom;
|
|
|
|
|
bcam->zoom = 2.0f/bcam->zoom;
|
|
|
|
|
|
|
|
|
|
/* offset */
|
|
|
|
|
bcam->offset = get_float2(b_rv3d.view_camera_offset());
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_ORTHO) {
|
|
|
|
|
/* orthographic view */
|
2012-06-09 17:45:22 +00:00
|
|
|
bcam->farclip *= 0.5f;
|
2012-06-06 23:27:43 +00:00
|
|
|
bcam->nearclip = -bcam->farclip;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-10-24 16:15:46 +00:00
|
|
|
float sensor_size;
|
|
|
|
|
if(bcam->sensor_fit == BlenderCamera::VERTICAL)
|
|
|
|
|
sensor_size = bcam->sensor_height;
|
|
|
|
|
else
|
|
|
|
|
sensor_size = bcam->sensor_width;
|
|
|
|
|
|
2012-06-06 23:27:43 +00:00
|
|
|
bcam->type = CAMERA_ORTHOGRAPHIC;
|
2012-10-24 16:15:46 +00:00
|
|
|
bcam->ortho_scale = b_rv3d.view_distance() * sensor_size / b_v3d.lens();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-06 23:27:43 +00:00
|
|
|
bcam->zoom *= 2.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* 3d view transform */
|
2012-06-06 23:27:43 +00:00
|
|
|
bcam->matrix = transform_inverse(get_transform(b_rv3d.view_matrix()));
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_view_subset(BL::RenderEngine& b_engine,
|
|
|
|
|
BL::RenderSettings& b_render,
|
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
|
BL::Object& b_ob,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height,
|
|
|
|
|
BoundBox2D *view_box,
|
|
|
|
|
BoundBox2D *cam_box)
|
2012-11-10 22:31:29 +00:00
|
|
|
{
|
|
|
|
|
BoundBox2D cam, view;
|
|
|
|
|
float view_aspect, cam_aspect, sensor_size;
|
|
|
|
|
|
|
|
|
|
/* get viewport viewplane */
|
|
|
|
|
BlenderCamera view_bcam;
|
2015-03-27 15:47:55 +05:00
|
|
|
blender_camera_init(&view_bcam, b_render);
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_from_view(&view_bcam, b_engine, b_scene, b_v3d, b_rv3d, width, height, true);
|
2012-11-10 22:31:29 +00:00
|
|
|
|
|
|
|
|
blender_camera_viewplane(&view_bcam, width, height,
|
|
|
|
|
&view, &view_aspect, &sensor_size);
|
|
|
|
|
|
|
|
|
|
/* get camera viewplane */
|
|
|
|
|
BlenderCamera cam_bcam;
|
2015-03-27 15:47:55 +05:00
|
|
|
blender_camera_init(&cam_bcam, b_render);
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_from_object(&cam_bcam, b_engine, b_ob, true);
|
2012-11-10 22:31:29 +00:00
|
|
|
|
2012-11-23 02:10:13 +00:00
|
|
|
blender_camera_viewplane(&cam_bcam, cam_bcam.full_width, cam_bcam.full_height,
|
2012-11-10 22:31:29 +00:00
|
|
|
&cam, &cam_aspect, &sensor_size);
|
|
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
|
*view_box = view * (1.0f/view_aspect);
|
|
|
|
|
*cam_box = cam * (1.0f/cam_aspect);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_border_subset(BL::RenderEngine& b_engine,
|
|
|
|
|
BL::RenderSettings& b_render,
|
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
BL::Object& b_ob,
|
2015-01-27 21:36:14 +05:00
|
|
|
int width, int height,
|
|
|
|
|
const BoundBox2D &border,
|
|
|
|
|
BoundBox2D *result)
|
|
|
|
|
{
|
|
|
|
|
/* Determine camera viewport subset. */
|
|
|
|
|
BoundBox2D view_box, cam_box;
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_view_subset(b_engine, b_render, b_scene, b_ob, b_v3d, b_rv3d, width, height,
|
2015-01-27 21:36:14 +05:00
|
|
|
&view_box, &cam_box);
|
|
|
|
|
|
|
|
|
|
/* Determine viewport subset matching given border. */
|
|
|
|
|
cam_box = cam_box.make_relative_to(view_box);
|
|
|
|
|
*result = cam_box.subset(border);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
static void blender_camera_border(BlenderCamera *bcam,
|
|
|
|
|
BL::RenderEngine& b_engine,
|
|
|
|
|
BL::RenderSettings& b_render,
|
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height)
|
2012-06-06 23:27:43 +00:00
|
|
|
{
|
2012-10-16 11:57:46 +00:00
|
|
|
bool is_camera_view;
|
2012-06-06 23:27:43 +00:00
|
|
|
|
|
|
|
|
/* camera view? */
|
2012-10-16 11:57:46 +00:00
|
|
|
is_camera_view = b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA;
|
|
|
|
|
|
|
|
|
|
if(!is_camera_view) {
|
|
|
|
|
/* for non-camera view check whether render border is enabled for viewport
|
|
|
|
|
* and if so use border from 3d viewport
|
|
|
|
|
* assume viewport has got correctly clamped border already
|
|
|
|
|
*/
|
|
|
|
|
if(b_v3d.use_render_border()) {
|
2012-11-10 22:31:29 +00:00
|
|
|
bcam->border.left = b_v3d.render_border_min_x();
|
|
|
|
|
bcam->border.right = b_v3d.render_border_max_x();
|
|
|
|
|
bcam->border.bottom = b_v3d.render_border_min_y();
|
|
|
|
|
bcam->border.top = b_v3d.render_border_max_y();
|
2012-10-16 11:57:46 +00:00
|
|
|
}
|
2012-06-06 23:27:43 +00:00
|
|
|
return;
|
2015-01-27 21:36:14 +05:00
|
|
|
}
|
2012-06-06 23:27:43 +00:00
|
|
|
|
|
|
|
|
BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera();
|
|
|
|
|
|
|
|
|
|
if(!b_ob)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-01-27 21:36:14 +05:00
|
|
|
/* Determine camera border inside the viewport. */
|
|
|
|
|
BoundBox2D full_border;
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_border_subset(b_engine,
|
|
|
|
|
b_render,
|
2015-01-27 21:36:14 +05:00
|
|
|
b_scene,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_rv3d,
|
|
|
|
|
b_ob,
|
|
|
|
|
width, height,
|
|
|
|
|
full_border,
|
|
|
|
|
&bcam->viewport_camera_border);
|
|
|
|
|
|
|
|
|
|
if(!b_render.use_border()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-14 07:38:37 +00:00
|
|
|
bcam->border.left = b_render.border_min_x();
|
|
|
|
|
bcam->border.right = b_render.border_max_x();
|
|
|
|
|
bcam->border.bottom = b_render.border_min_y();
|
|
|
|
|
bcam->border.top = b_render.border_max_y();
|
2012-06-06 23:27:43 +00:00
|
|
|
|
2015-01-27 21:36:14 +05:00
|
|
|
/* Determine viewport subset matching camera border. */
|
2015-04-06 10:40:12 -03:00
|
|
|
blender_camera_border_subset(b_engine,
|
|
|
|
|
b_render,
|
2015-01-27 21:36:14 +05:00
|
|
|
b_scene,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_rv3d,
|
|
|
|
|
b_ob,
|
|
|
|
|
width, height,
|
|
|
|
|
bcam->border,
|
|
|
|
|
&bcam->border);
|
2016-02-01 10:02:24 +01:00
|
|
|
bcam->border = bcam->border.clamp();
|
2012-06-06 23:27:43 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_view(BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height)
|
2012-06-06 23:27:43 +00:00
|
|
|
{
|
|
|
|
|
BlenderCamera bcam;
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::RenderSettings b_render_settings(b_scene.render());
|
|
|
|
|
blender_camera_init(&bcam, b_render_settings);
|
|
|
|
|
blender_camera_from_view(&bcam,
|
|
|
|
|
b_engine,
|
|
|
|
|
b_scene,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_rv3d,
|
|
|
|
|
width, height);
|
|
|
|
|
blender_camera_border(&bcam,
|
|
|
|
|
b_engine,
|
|
|
|
|
b_render_settings,
|
|
|
|
|
b_scene,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_rv3d,
|
|
|
|
|
width, height);
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
blender_camera_sync(scene->camera, &bcam, width, height, "");
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BufferParams BlenderSync::get_buffer_params(BL::RenderSettings& b_render,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
Camera *cam,
|
|
|
|
|
int width, int height)
|
2011-12-20 12:25:37 +00:00
|
|
|
{
|
|
|
|
|
BufferParams params;
|
2012-10-16 11:57:46 +00:00
|
|
|
bool use_border = false;
|
2011-12-20 12:25:37 +00:00
|
|
|
|
|
|
|
|
params.full_width = width;
|
|
|
|
|
params.full_height = height;
|
|
|
|
|
|
2012-10-16 11:57:46 +00:00
|
|
|
if(b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA)
|
|
|
|
|
use_border = b_v3d.use_render_border();
|
|
|
|
|
else
|
2013-03-14 07:38:37 +00:00
|
|
|
use_border = b_render.use_border();
|
2012-10-16 11:57:46 +00:00
|
|
|
|
|
|
|
|
if(use_border) {
|
2012-06-06 23:27:43 +00:00
|
|
|
/* border render */
|
2015-03-05 15:07:21 +11:00
|
|
|
/* the viewport may offset the border outside the view */
|
|
|
|
|
BoundBox2D border = cam->border.clamp();
|
|
|
|
|
params.full_x = (int)(border.left * (float)width);
|
|
|
|
|
params.full_y = (int)(border.bottom * (float)height);
|
|
|
|
|
params.width = (int)(border.right * (float)width) - params.full_x;
|
|
|
|
|
params.height = (int)(border.top * (float)height) - params.full_y;
|
2012-06-13 11:25:36 +00:00
|
|
|
|
|
|
|
|
/* survive in case border goes out of view or becomes too small */
|
|
|
|
|
params.width = max(params.width, 1);
|
|
|
|
|
params.height = max(params.height, 1);
|
2011-12-20 12:25:37 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
params.width = width;
|
|
|
|
|
params.height = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return params;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|