143 BL::Object b_dof_object = b_camera.dof().focus_object();
146 return b_camera.dof().focus_distance();
149 BL::Array<float, 16> b_ob_matrix;
155 return fabsf(
dot(view_dir, dof_dir));
161 bool skip_panorama =
false)
163 BL::ID b_ob_data = b_ob.data();
169 bcam->
nearclip = b_camera.clip_start();
170 bcam->
farclip = b_camera.clip_end();
172 switch (b_camera.type()) {
173 case BL::Camera::type_ORTHO:
176 case BL::Camera::type_PANO:
182 case BL::Camera::type_PERSP:
199 if (b_camera.stereo().convergence_mode() == BL::CameraStereoData::convergence_mode_PARALLEL) {
213 bcam->
lens = b_camera.lens();
215 if (b_camera.dof().use_dof()) {
218 float fstop = b_camera.dof().aperture_fstop();
219 fstop =
max(fstop, 1e-5f);
241 bcam->
shift.
y = b_camera.shift_y();
246 if (b_camera.sensor_fit() == BL::Camera::sensor_fit_AUTO)
248 else if (b_camera.sensor_fit() == BL::Camera::sensor_fit_HORIZONTAL)
255 BL::SpotLight b_light(b_ob_data);
256 float lens = 16.0f /
tanf(b_light.spot_size() * 0.5f);
277 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
285 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
308 float xaspect, yaspect;
313 horizontal_fit = (xratio > yratio);
314 if (sensor_size !=
NULL) {
319 horizontal_fit =
true;
320 if (sensor_size !=
NULL) {
325 horizontal_fit =
false;
326 if (sensor_size !=
NULL) {
331 if (horizontal_fit) {
332 if (aspectratio !=
NULL) {
333 *aspectratio = xratio / yratio;
335 xaspect = *aspectratio;
339 if (aspectratio !=
NULL) {
340 *aspectratio = yratio / xratio;
343 yaspect = *aspectratio;
348 xaspect = xaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
349 yaspect = yaspect * bcam->
ortho_scale / (*aspectratio * 2.0f);
350 if (aspectratio !=
NULL) {
357 if (viewplane !=
NULL) {
363 if (viewplane !=
NULL) {
364 viewplane->
left = -xaspect;
365 viewplane->
right = xaspect;
366 viewplane->
bottom = -yaspect;
367 viewplane->
top = yaspect;
370 *viewplane = (*viewplane) * bcam->
zoom;
373 float dx = 2.0f * (*aspectratio * bcam->
shift.
x + bcam->
offset.
x * xaspect * 2.0f);
374 float dy = 2.0f * (*aspectratio * bcam->
shift.
y + bcam->
offset.
y * yaspect * 2.0f);
376 viewplane->
left += dx;
377 viewplane->
right += dx;
379 viewplane->
top += dy;
388 const char *viewname,
391 float aspectratio, sensor_size;
397 cam->set_viewplane_left(viewplane.
left);
398 cam->set_viewplane_right(viewplane.
right);
399 cam->set_viewplane_top(viewplane.
top);
400 cam->set_viewplane_bottom(viewplane.
bottom);
402 cam->set_full_width(
width);
403 cam->set_full_height(
height);
413 horizontal_fit = (fit_xratio > fit_yratio);
417 horizontal_fit =
true;
421 horizontal_fit =
false;
425 if (horizontal_fit) {
426 cam->set_sensorwidth(sensor_size);
427 cam->set_sensorheight(sensor_size * fit_yratio / fit_xratio);
430 cam->set_sensorwidth(sensor_size * fit_xratio / fit_yratio);
431 cam->set_sensorheight(sensor_size);
437 cam->set_farclip(bcam->
farclip);
440 cam->set_camera_type(bcam->
type);
457 if (cam->get_use_spherical_stereo()) {
458 if (strcmp(viewname,
"left") == 0)
460 else if (strcmp(viewname,
"right") == 0)
474 cam->set_fov(2.0f *
atanf((0.5f * sensor_size) / bcam->
lens / aspectratio));
485 cam->set_motion(motion);
486 cam->set_use_perspective_motion(
false);
489 cam->set_fov_pre(cam->get_fov());
490 cam->set_fov_post(cam->get_fov());
519 const char *viewname)
534 "motion_blur_position",
539 "rolling_shutter_type",
545 if (b_render.use_border()) {
549 bcam.
border.
top = b_render.border_max_y();
559 BL::Array<float, 16> b_ob_matrix;
572 BL::Array<float, 16> b_ob_matrix;
584 void BlenderSync::sync_camera_motion(
591 BL::Array<float, 16> b_ob_matrix;
592 b_engine.camera_model_matrix(b_ob, cam->get_use_spherical_stereo(), b_ob_matrix);
596 if (motion_time == 0.0f) {
598 cam->set_matrix(tfm);
603 if (motion_step >= 0) {
605 motion[motion_step] = tfm;
606 cam->set_motion(motion);
611 float aspectratio, sensor_size;
621 float fov = 2.0f *
atanf((0.5f * sensor_size) / bcam.
lens / aspectratio);
622 if (fov != cam->get_fov()) {
623 VLOG(1) <<
"Camera " << b_ob.name() <<
" FOV change detected.";
624 if (motion_time == 0.0f) {
627 else if (motion_time == -1.0f) {
628 cam->set_fov_pre(fov);
629 cam->set_use_perspective_motion(
true);
631 else if (motion_time == 1.0f) {
632 cam->set_fov_post(fov);
633 cam->set_use_perspective_motion(
true);
642 BL::RenderSettings &b_render,
645 BL::SpaceView3D &b_v3d,
655 BL::SpaceView3D &b_v3d,
659 bool skip_panorama =
false)
662 bcam->
nearclip = b_v3d.clip_start();
663 bcam->
farclip = b_v3d.clip_end();
664 bcam->
lens = b_v3d.lens();
665 bcam->
shuttertime = b_scene.render().motion_blur_shutter();
667 BL::CurveMapping b_shutter_curve(b_scene.render().motion_blur_shutter_curve());
670 if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) {
672 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
681 BL::RenderSettings b_render_settings(b_scene.render());
697 bcam->
zoom = (
float)b_rv3d.view_camera_zoom();
698 bcam->
zoom = (1.41421f + bcam->
zoom / 50.0f);
707 else if (b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_ORTHO) {
719 bcam->
ortho_scale = b_rv3d.view_distance() * sensor_size / b_v3d.lens();
733 BL::RenderSettings &b_render,
736 BL::SpaceView3D &b_v3d,
744 float view_aspect, cam_aspect, sensor_size;
766 *view_box =
view * (1.0f / view_aspect);
767 *cam_box = cam * (1.0f / cam_aspect);
771 BL::RenderSettings &b_render,
773 BL::SpaceView3D &b_v3d,
784 b_engine, b_render, b_scene, b_ob, b_v3d, b_rv3d,
width,
height, &view_box, &cam_box);
793 BL::RenderSettings &b_render,
795 BL::SpaceView3D &b_v3d,
803 is_camera_view = b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA;
805 if (!is_camera_view) {
810 if (b_v3d.use_render_border()) {
811 bcam->
border.
left = b_v3d.render_border_min_x();
814 bcam->
border.
top = b_v3d.render_border_max_y();
819 BL::Object b_ob = (b_v3d.use_local_camera()) ? b_v3d.camera() : b_scene.camera();
837 if (!b_render.use_border()) {
844 bcam->
border.
top = b_render.border_max_y();
866 BL::RenderSettings b_render_settings(b_scene.render());
876 BL::Array<float, 16> b_ob_matrix;
889 BL::SpaceView3D &b_v3d,
894 const bool use_denoiser)
897 bool use_border =
false;
902 if (b_v3d && b_rv3d && b_rv3d.view_perspective() != BL::RegionView3D::view_perspective_CAMERA)
903 use_border = b_v3d.use_render_border();
905 use_border = b_render.use_border();
typedef float(TangentPoint)[2]
struct CurveMapping CurveMapping
struct RegionView3D RegionView3D
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
struct RenderEngine RenderEngine
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 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_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_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)
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)
PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, vector< Pass > &passes)
static BufferParams get_buffer_params(BL::RenderSettings &b_render, BL::SpaceView3D &b_v3d, BL::RegionView3D &b_rv3d, Camera *cam, int width, int height, const bool use_denoiser)
void sync_camera(BL::RenderSettings &b_render, BL::Object &b_override, int width, int height, const char *viewname)
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)
IconTextureDrawCall border
#define CCL_NAMESPACE_END
@ PANORAMA_FISHEYE_EQUISOLID
@ PANORAMA_EQUIRECTANGULAR
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
float rolling_shutter_duration
Camera::MotionPosition motion_position
enum BlenderCamera::@1186 sensor_fit
bool use_spherical_stereo
array< float > shutter_curve
float offscreen_dicing_scale
BoundBox2D pano_viewplane
Camera::RollingShutterType rolling_shutter_type
float convergence_distance
float pole_merge_angle_from
PanoramaType panorama_type
float pole_merge_angle_to
float interocular_distance
BoundBox2D viewport_camera_border
@ ROLLING_SHUTTER_NUM_TYPES
int motion_step(float time) const
ccl_device_inline float2 one_float2()
ccl_device_inline float2 normalize(const float2 &a)
ccl_device_inline float dot(const float2 &a, const float2 &b)