148 BL::Camera &b_camera,
151 BL::Object b_dof_object = b_camera.dof().focus_object();
154 return b_camera.dof().focus_distance();
159 string focus_subtarget = b_camera.dof().focus_subtarget();
160 if (b_dof_object.pose() && !focus_subtarget.empty()) {
161 BL::PoseBone b_bone = b_dof_object.pose().bones[focus_subtarget];
168 BL::Array<float, 16> b_ob_matrix;
173 return fabsf(
dot(view_dir, dof_dir));
179 case BL::Camera::panorama_type_EQUIRECTANGULAR:
181 case BL::Camera::panorama_type_EQUIANGULAR_CUBEMAP_FACE:
183 case BL::Camera::panorama_type_MIRRORBALL:
185 case BL::Camera::panorama_type_FISHEYE_EQUIDISTANT:
187 case BL::Camera::panorama_type_FISHEYE_EQUISOLID:
189 case BL::Camera::panorama_type_FISHEYE_LENS_POLYNOMIAL:
191 case BL::Camera::panorama_type_CENTRAL_CYLINDRICAL:
199 BL::RenderEngine &b_engine,
201 bool skip_panorama =
false)
203 BL::ID b_ob_data = b_ob.data();
205 if (b_ob_data.is_a(&RNA_Camera)) {
206 BL::Camera b_camera(b_ob_data);
208 bcam->
nearclip = b_camera.clip_start();
209 bcam->
farclip = b_camera.clip_end();
211 switch (b_camera.type()) {
212 case BL::Camera::type_ORTHO:
215 case BL::Camera::type_PANO:
216 if (!skip_panorama) {
223 case BL::Camera::type_PERSP:
250 if (b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {
264 bcam->
lens = b_camera.lens();
266 bcam->
passepartout_alpha = b_camera.show_passepartout() ? b_camera.passepartout_alpha() : 0.0f;
268 if (b_camera.dof().use_dof()) {
271 float fstop = b_camera.dof().aperture_fstop();
272 fstop =
max(fstop, 1e-5f);
296 bcam->
shift.
y = b_camera.shift_y();
301 if (b_camera.sensor_fit() == BL::Camera::sensor_fit_AUTO) {
304 else if (b_camera.sensor_fit() == BL::Camera::sensor_fit_HORIZONTAL) {
311 else if (b_ob_data.is_a(&RNA_Light)) {
313 BL::SpotLight b_light(b_ob_data);
314 float lens = 16.0f /
tanf(b_light.spot_size() * 0.5f);
335 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
343 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
366 float xaspect, yaspect;
371 horizontal_fit = (xratio > yratio);
372 if (sensor_size !=
NULL) {
377 horizontal_fit =
true;
378 if (sensor_size !=
NULL) {
383 horizontal_fit =
false;
384 if (sensor_size !=
NULL) {
389 if (horizontal_fit) {
390 if (aspectratio !=
NULL) {
391 *aspectratio = xratio / yratio;
393 xaspect = *aspectratio;
397 if (aspectratio !=
NULL) {
398 *aspectratio = yratio / xratio;
401 yaspect = *aspectratio;
406 xaspect = xaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
407 yaspect = yaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
408 if (aspectratio !=
NULL) {
415 if (viewplane !=
NULL) {
422 const float dx = bcam->
shift.
x * shift_factor;
423 const float dy = bcam->
shift.
y * shift_factor;
425 viewplane->
left += dx;
426 viewplane->
right += dx;
428 viewplane->
top += dy;
433 if (viewplane !=
NULL) {
434 viewplane->
left = -xaspect;
435 viewplane->
right = xaspect;
436 viewplane->
bottom = -yaspect;
437 viewplane->
top = yaspect;
440 *viewplane = (*viewplane) * bcam->
zoom;
443 const float dx = 2.0f * (*aspectratio * bcam->
shift.
x + bcam->
offset.
x * xaspect * 2.0f);
444 const float dy = 2.0f * (*aspectratio * bcam->
shift.
y + bcam->
offset.
y * yaspect * 2.0f);
446 viewplane->
left += dx;
447 viewplane->
right += dx;
449 viewplane->
top += dy;
458 const char *viewname,
461 float aspectratio, sensor_size;
467 cam->set_viewplane_left(viewplane.
left);
468 cam->set_viewplane_right(viewplane.
right);
469 cam->set_viewplane_top(viewplane.
top);
470 cam->set_viewplane_bottom(viewplane.
bottom);
472 cam->set_full_width(width);
473 cam->set_full_height(height);
485 horizontal_fit = (fit_xratio > fit_yratio);
489 horizontal_fit =
true;
493 horizontal_fit =
false;
497 if (horizontal_fit) {
498 cam->set_sensorwidth(sensor_size);
499 cam->set_sensorheight(sensor_size * fit_yratio / fit_xratio);
502 cam->set_sensorwidth(sensor_size * fit_xratio / fit_yratio);
503 cam->set_sensorheight(sensor_size);
509 cam->set_farclip(bcam->
farclip);
512 cam->set_camera_type(bcam->
type);
542 if (cam->get_use_spherical_stereo()) {
543 if (strcmp(viewname,
"left") == 0) {
546 else if (strcmp(viewname,
"right") == 0) {
562 cam->set_fov(2.0f *
atanf((0.5f * sensor_size) / bcam->
lens / aspectratio));
573 cam->set_motion(motion);
574 cam->set_use_perspective_motion(
false);
577 cam->set_fov_pre(cam->get_fov());
578 cam->set_fov_post(cam->get_fov());
604 const BL::RenderSettings::motion_blur_position_enum type)
607 case BL::RenderSettings::motion_blur_position_START:
609 case BL::RenderSettings::motion_blur_position_CENTER:
611 case BL::RenderSettings::motion_blur_position_END:
619 BL::Object &b_override,
622 const char *viewname)
632 b_render.motion_blur_position());
634 BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve());
640 "rolling_shutter_type",
646 if (b_render.use_border()) {
650 bcam.
border.
top = b_render.border_max_y();
654 BL::Object b_ob = b_scene.camera();
661 BL::Array<float, 16> b_ob_matrix;
665 scene->bake_manager->set_use_camera(b_render.bake().view_from() ==
666 BL::BakeSettings::view_from_ACTIVE_CAMERA);
669 scene->bake_manager->set_use_camera(
false);
673 Camera *cam = scene->camera;
679 BL::Array<float, 16> b_ob_matrix;
687 *scene->dicing_camera = *cam;
691void BlenderSync::sync_camera_motion(
692 BL::RenderSettings &b_render, BL::Object &b_ob,
int width,
int height,
float motion_time)
698 Camera *cam = scene->camera;
699 BL::Array<float, 16> b_ob_matrix;
700 b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix);
704 if (motion_time == 0.0f) {
706 cam->set_matrix(tfm);
711 if (motion_step >= 0) {
713 motion[motion_step] = tfm;
714 cam->set_motion(motion);
719 float aspectratio, sensor_size;
729 float fov = 2.0f *
atanf((0.5f * sensor_size) / bcam.
lens / aspectratio);
730 if (fov != cam->get_fov()) {
731 VLOG_WORK <<
"Camera " << b_ob.name() <<
" FOV change detected.";
732 if (motion_time == 0.0f) {
735 else if (motion_time == -1.0f) {
736 cam->set_fov_pre(fov);
737 cam->set_use_perspective_motion(
true);
739 else if (motion_time == 1.0f) {
740 cam->set_fov_post(fov);
741 cam->set_use_perspective_motion(
true);
750 BL::RenderSettings &b_render,
753 BL::SpaceView3D &b_v3d,
754 BL::RegionView3D &b_rv3d,
762 BL::RenderEngine &b_engine,
764 BL::SpaceView3D &b_v3d,
765 BL::RegionView3D &b_rv3d,
768 bool skip_panorama =
false)
771 bcam->
nearclip = b_v3d.clip_start();
772 bcam->
farclip = b_v3d.clip_end();
773 bcam->
lens = b_v3d.lens();
774 bcam->
shuttertime = b_scene.render().motion_blur_shutter();
776 BL::CurveMapping b_shutter_curve(b_scene.render().motion_blur_shutter_curve());
779 if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) {
781 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
791 BL::RenderSettings b_render_settings(b_scene.render());
809 bcam->
zoom = (
float)b_rv3d.view_camera_zoom();
810 bcam->
zoom = (1.41421f + bcam->
zoom / 50.0f);
819 else if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_ORTHO) {
833 bcam->
ortho_scale = b_rv3d.view_distance() * sensor_size / b_v3d.lens();
847 BL::RenderSettings &b_render,
850 BL::SpaceView3D &b_v3d,
851 BL::RegionView3D &b_rv3d,
859 float cam_aspect, sensor_size;
881 *view_box = view * (1.0f / *view_aspect);
882 *cam_box = cam * (1.0f / cam_aspect);
886 BL::RenderSettings &b_render,
888 BL::SpaceView3D &b_v3d,
889 BL::RegionView3D &b_rv3d,
913 *result = cam_box.
subset(border);
917 BL::RenderEngine &b_engine,
918 BL::RenderSettings &b_render,
920 BL::SpaceView3D &b_v3d,
921 BL::RegionView3D &b_rv3d,
928 is_camera_view = b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA;
930 if (!is_camera_view) {
935 if (b_v3d.use_render_border()) {
936 bcam->
border.
left = b_v3d.render_border_min_x();
939 bcam->
border.
top = b_v3d.render_border_max_y();
944 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
963 if (b_render.use_border()) {
967 bcam->
border.
top = b_render.border_max_y();
970 bcam->
border = full_border;
991 BL::RegionView3D &b_rv3d,
996 BL::RenderSettings b_render_settings(b_scene.render());
1004 BL::Object b_ob = BL::Object(
RNA_pointer_get(&cscene,
"dicing_camera"));
1006 BL::Array<float, 16> b_ob_matrix;
1014 *scene->dicing_camera = *scene->camera;
1019 BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d,
Camera *cam,
int width,
int height)
1022 bool use_border =
false;
1024 params.full_width = width;
1025 params.full_height = height;
1027 if (b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA) {
1028 use_border = b_v3d.use_render_border();
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)
static float blender_camera_focal_distance(BL::RenderEngine &b_engine, BL::Object &b_ob, BL::Camera &b_camera, BlenderCamera *bcam)
static MotionPosition blender_motion_blur_position_type_to_cycles(const BL::RenderSettings::motion_blur_position_enum type)
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, int width, int height, const BoundBox2D &border, BoundBox2D *result)
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)
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, float *view_aspect)
static PanoramaType blender_panorama_type_to_cycles(const BL::Camera::panorama_type_enum type)
static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine &b_engine, BL::Object &b_ob, bool skip_panorama=false)
static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height, BoundBox2D *viewplane, float *aspectratio, float *sensor_size)
static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int height, const char *viewname, PointerRNA *cscene)
static Transform blender_camera_matrix(const Transform &tfm, const CameraType type, const PanoramaType panorama_type)
static void blender_camera_init(BlenderCamera *bcam, BL::RenderSettings &b_render)
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
void sync_camera(BL::RenderSettings &b_render, BL::Object &b_override, int width, int height, const char *viewname)
static BufferParams get_buffer_params(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height)
void sync_view(BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, int width, int height)
BoundBox2D clamp(float mn=0.0f, float mx=1.0f)
BoundBox2D make_relative_to(const BoundBox2D &other) const
BoundBox2D subset(const BoundBox2D &other) const
T * resize(size_t newsize)
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
static uint object_motion_steps(BL::Object &b_parent, BL::Object &b_ob, const int max_steps=INT_MAX)
static int render_resolution_x(BL::RenderSettings &b_render)
static void curvemapping_to_array(BL::CurveMapping &cumap, array< float > &data, int size)
static int render_resolution_y(BL::RenderSettings &b_render)
static int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
static float2 get_float2(const BL::Array< float, 2 > &array)
static Transform get_transform(const BL::Array< float, 16 > &array)
#define CCL_NAMESPACE_END
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
@ PANORAMA_FISHEYE_EQUISOLID
@ PANORAMA_CENTRAL_CYLINDRICAL
@ PANORAMA_EQUIANGULAR_CUBEMAP_FACE
@ PANORAMA_FISHEYE_EQUIDISTANT
@ PANORAMA_FISHEYE_LENS_POLYNOMIAL
@ PANORAMA_EQUIRECTANGULAR
ccl_device_inline float2 one_float2()
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
float central_cylindrical_radius
float rolling_shutter_duration
float central_cylindrical_range_u_min
MotionPosition motion_position
bool use_spherical_stereo
float fisheye_polynomial_k2
float fisheye_polynomial_k1
array< float > shutter_curve
float fisheye_polynomial_k0
float offscreen_dicing_scale
float central_cylindrical_range_v_min
enum BlenderCamera::@1412 sensor_fit
float fisheye_polynomial_k4
BoundBox2D pano_viewplane
Camera::RollingShutterType rolling_shutter_type
float convergence_distance
float central_cylindrical_range_v_max
float pole_merge_angle_from
float fisheye_polynomial_k3
PanoramaType panorama_type
float central_cylindrical_range_u_max
float pole_merge_angle_to
float interocular_distance
BoundBox2D viewport_camera_border
@ ROLLING_SHUTTER_NUM_TYPES
int motion_step(float time) const