Blender  V3.3
scene/camera.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #include "scene/camera.h"
5 #include "scene/mesh.h"
6 #include "scene/object.h"
7 #include "scene/scene.h"
8 #include "scene/stats.h"
9 #include "scene/tables.h"
10 
11 #include "device/device.h"
12 
13 #include "util/foreach.h"
14 #include "util/function.h"
15 #include "util/log.h"
16 #include "util/math_cdf.h"
17 #include "util/task.h"
18 #include "util/time.h"
19 #include "util/vector.h"
20 
21 /* needed for calculating differentials */
24 
25 #include "kernel/camera/camera.h"
26 
28 
29 static float shutter_curve_eval(float x, array<float> &shutter_curve)
30 {
31  if (shutter_curve.size() == 0) {
32  return 1.0f;
33  }
34 
35  x *= shutter_curve.size();
36  int index = (int)x;
37  float frac = x - index;
38  if (index < shutter_curve.size() - 1) {
39  return lerp(shutter_curve[index], shutter_curve[index + 1], frac);
40  }
41  else {
42  return shutter_curve[shutter_curve.size() - 1];
43  }
44 }
45 
47 {
48  NodeType *type = NodeType::add("camera", create);
49 
50  SOCKET_FLOAT(shuttertime, "Shutter Time", 1.0f);
51 
52  static NodeEnum motion_position_enum;
53  motion_position_enum.insert("start", MOTION_POSITION_START);
54  motion_position_enum.insert("center", MOTION_POSITION_CENTER);
55  motion_position_enum.insert("end", MOTION_POSITION_END);
56  SOCKET_ENUM(motion_position, "Motion Position", motion_position_enum, MOTION_POSITION_CENTER);
57 
58  static NodeEnum rolling_shutter_type_enum;
59  rolling_shutter_type_enum.insert("none", ROLLING_SHUTTER_NONE);
60  rolling_shutter_type_enum.insert("top", ROLLING_SHUTTER_TOP);
61  SOCKET_ENUM(rolling_shutter_type,
62  "Rolling Shutter Type",
63  rolling_shutter_type_enum,
64  ROLLING_SHUTTER_NONE);
65  SOCKET_FLOAT(rolling_shutter_duration, "Rolling Shutter Duration", 0.1f);
66 
67  SOCKET_FLOAT_ARRAY(shutter_curve, "Shutter Curve", array<float>());
68 
69  SOCKET_FLOAT(aperturesize, "Aperture Size", 0.0f);
70  SOCKET_FLOAT(focaldistance, "Focal Distance", 10.0f);
71  SOCKET_UINT(blades, "Blades", 0);
72  SOCKET_FLOAT(bladesrotation, "Blades Rotation", 0.0f);
73 
74  SOCKET_TRANSFORM(matrix, "Matrix", transform_identity());
75  SOCKET_TRANSFORM_ARRAY(motion, "Motion", array<Transform>());
76 
77  SOCKET_FLOAT(aperture_ratio, "Aperture Ratio", 1.0f);
78 
79  static NodeEnum type_enum;
80  type_enum.insert("perspective", CAMERA_PERSPECTIVE);
81  type_enum.insert("orthograph", CAMERA_ORTHOGRAPHIC);
82  type_enum.insert("panorama", CAMERA_PANORAMA);
83  SOCKET_ENUM(camera_type, "Type", type_enum, CAMERA_PERSPECTIVE);
84 
85  static NodeEnum panorama_type_enum;
86  panorama_type_enum.insert("equirectangular", PANORAMA_EQUIRECTANGULAR);
87  panorama_type_enum.insert("mirrorball", PANORAMA_MIRRORBALL);
88  panorama_type_enum.insert("fisheye_equidistant", PANORAMA_FISHEYE_EQUIDISTANT);
89  panorama_type_enum.insert("fisheye_equisolid", PANORAMA_FISHEYE_EQUISOLID);
90  panorama_type_enum.insert("fisheye_lens_polynomial", PANORAMA_FISHEYE_LENS_POLYNOMIAL);
91  SOCKET_ENUM(panorama_type, "Panorama Type", panorama_type_enum, PANORAMA_EQUIRECTANGULAR);
92 
93  SOCKET_FLOAT(fisheye_fov, "Fisheye FOV", M_PI_F);
94  SOCKET_FLOAT(fisheye_lens, "Fisheye Lens", 10.5f);
95  SOCKET_FLOAT(latitude_min, "Latitude Min", -M_PI_2_F);
96  SOCKET_FLOAT(latitude_max, "Latitude Max", M_PI_2_F);
97  SOCKET_FLOAT(longitude_min, "Longitude Min", -M_PI_F);
98  SOCKET_FLOAT(longitude_max, "Longitude Max", M_PI_F);
99  SOCKET_FLOAT(fov, "FOV", M_PI_4_F);
100  SOCKET_FLOAT(fov_pre, "FOV Pre", M_PI_4_F);
101  SOCKET_FLOAT(fov_post, "FOV Post", M_PI_4_F);
102 
103  SOCKET_FLOAT(fisheye_polynomial_k0, "Fisheye Polynomial K0", 0.0f);
104  SOCKET_FLOAT(fisheye_polynomial_k1, "Fisheye Polynomial K1", 0.0f);
105  SOCKET_FLOAT(fisheye_polynomial_k2, "Fisheye Polynomial K2", 0.0f);
106  SOCKET_FLOAT(fisheye_polynomial_k3, "Fisheye Polynomial K3", 0.0f);
107  SOCKET_FLOAT(fisheye_polynomial_k4, "Fisheye Polynomial K4", 0.0f);
108 
109  static NodeEnum stereo_eye_enum;
110  stereo_eye_enum.insert("none", STEREO_NONE);
111  stereo_eye_enum.insert("left", STEREO_LEFT);
112  stereo_eye_enum.insert("right", STEREO_RIGHT);
113  SOCKET_ENUM(stereo_eye, "Stereo Eye", stereo_eye_enum, STEREO_NONE);
114 
115  SOCKET_BOOLEAN(use_spherical_stereo, "Use Spherical Stereo", false);
116 
117  SOCKET_FLOAT(interocular_distance, "Interocular Distance", 0.065f);
118  SOCKET_FLOAT(convergence_distance, "Convergence Distance", 30.0f * 0.065f);
119 
120  SOCKET_BOOLEAN(use_pole_merge, "Use Pole Merge", false);
121  SOCKET_FLOAT(pole_merge_angle_from, "Pole Merge Angle From", 60.0f * M_PI_F / 180.0f);
122  SOCKET_FLOAT(pole_merge_angle_to, "Pole Merge Angle To", 75.0f * M_PI_F / 180.0f);
123 
124  SOCKET_FLOAT(sensorwidth, "Sensor Width", 0.036f);
125  SOCKET_FLOAT(sensorheight, "Sensor Height", 0.024f);
126 
127  SOCKET_FLOAT(nearclip, "Near Clip", 1e-5f);
128  SOCKET_FLOAT(farclip, "Far Clip", 1e5f);
129 
130  SOCKET_FLOAT(viewplane.left, "Viewplane Left", 0);
131  SOCKET_FLOAT(viewplane.right, "Viewplane Right", 0);
132  SOCKET_FLOAT(viewplane.bottom, "Viewplane Bottom", 0);
133  SOCKET_FLOAT(viewplane.top, "Viewplane Top", 0);
134 
135  SOCKET_FLOAT(border.left, "Border Left", 0);
136  SOCKET_FLOAT(border.right, "Border Right", 0);
137  SOCKET_FLOAT(border.bottom, "Border Bottom", 0);
138  SOCKET_FLOAT(border.top, "Border Top", 0);
139 
140  SOCKET_FLOAT(viewport_camera_border.left, "Viewport Border Left", 0);
141  SOCKET_FLOAT(viewport_camera_border.right, "Viewport Border Right", 0);
142  SOCKET_FLOAT(viewport_camera_border.bottom, "Viewport Border Bottom", 0);
143  SOCKET_FLOAT(viewport_camera_border.top, "Viewport Border Top", 0);
144 
145  SOCKET_FLOAT(offscreen_dicing_scale, "Offscreen Dicing Scale", 1.0f);
146 
147  SOCKET_INT(full_width, "Full Width", 1024);
148  SOCKET_INT(full_height, "Full Height", 512);
149 
150  SOCKET_BOOLEAN(use_perspective_motion, "Use Perspective Motion", false);
151 
152  return type;
153 }
154 
155 Camera::Camera() : Node(get_node_type())
156 {
158 
159  width = 1024;
160  height = 512;
161 
162  use_perspective_motion = false;
163 
164  shutter_curve.resize(RAMP_TABLE_SIZE);
165  for (int i = 0; i < shutter_curve.size(); ++i) {
166  shutter_curve[i] = 1.0f;
167  }
168 
170 
177 
179 
180  dx = zero_float3();
181  dy = zero_float3();
182 
183  need_device_update = true;
184  need_flags_update = true;
186 
187  memset((void *)&kernel_camera, 0, sizeof(kernel_camera));
188 }
189 
191 {
192 }
193 
195 {
196  if (camera_type == CAMERA_PANORAMA) {
197  viewplane.left = 0.0f;
198  viewplane.right = 1.0f;
199  viewplane.bottom = 0.0f;
200  viewplane.top = 1.0f;
201  }
202  else {
203  float aspect = (float)full_width / (float)full_height;
204  if (full_width >= full_height) {
205  viewplane.left = -aspect;
206  viewplane.right = aspect;
207  viewplane.bottom = -1.0f;
208  viewplane.top = 1.0f;
209  }
210  else {
211  viewplane.left = -1.0f;
212  viewplane.right = 1.0f;
213  viewplane.bottom = -1.0f / aspect;
214  viewplane.top = 1.0f / aspect;
215  }
216  }
217 }
218 
220 {
221  Scene::MotionType need_motion = scene->need_motion();
222 
223  if (previous_need_motion != need_motion) {
224  /* scene's motion model could have been changed since previous device
225  * camera update this could happen for example in case when one render
226  * layer has got motion pass and another not */
227  need_device_update = true;
228  }
229 
230  if (!is_modified())
231  return;
232 
233  scoped_callback_timer timer([scene](double time) {
234  if (scene->update_stats) {
235  scene->update_stats->camera.times.add_entry({"update", time});
236  }
237  });
238 
239  /* Full viewport to camera border in the viewport. */
240  Transform fulltoborder = transform_from_viewplane(viewport_camera_border);
241  Transform bordertofull = transform_inverse(fulltoborder);
242 
243  /* NDC to raster. */
244  Transform ndctoraster = transform_scale(width, height, 1.0f) * bordertofull;
245  Transform full_ndctoraster = transform_scale(full_width, full_height, 1.0f) * bordertofull;
246 
247  /* Raster to screen. */
248  Transform screentondc = fulltoborder * transform_from_viewplane(viewplane);
249 
250  Transform screentoraster = ndctoraster * screentondc;
251  Transform rastertoscreen = transform_inverse(screentoraster);
252  Transform full_screentoraster = full_ndctoraster * screentondc;
253  Transform full_rastertoscreen = transform_inverse(full_screentoraster);
254 
255  /* Screen to camera. */
256  ProjectionTransform cameratoscreen;
257  if (camera_type == CAMERA_PERSPECTIVE)
258  cameratoscreen = projection_perspective(fov, nearclip, farclip);
259  else if (camera_type == CAMERA_ORTHOGRAPHIC)
260  cameratoscreen = projection_orthographic(nearclip, farclip);
261  else
262  cameratoscreen = projection_identity();
263 
264  ProjectionTransform screentocamera = projection_inverse(cameratoscreen);
265 
266  rastertocamera = screentocamera * rastertoscreen;
267  full_rastertocamera = screentocamera * full_rastertoscreen;
268  cameratoraster = screentoraster * cameratoscreen;
269 
270  cameratoworld = matrix;
271  screentoworld = cameratoworld * screentocamera;
272  rastertoworld = cameratoworld * rastertocamera;
273  ndctoworld = rastertoworld * ndctoraster;
274 
275  /* note we recompose matrices instead of taking inverses of the above, this
276  * is needed to avoid inverting near degenerate matrices that happen due to
277  * precision issues with large scenes */
278  worldtocamera = transform_inverse(matrix);
279  worldtoscreen = cameratoscreen * worldtocamera;
280  worldtondc = screentondc * worldtoscreen;
281  worldtoraster = ndctoraster * worldtondc;
282 
283  /* differentials */
284  if (camera_type == CAMERA_ORTHOGRAPHIC) {
285  dx = transform_perspective_direction(&rastertocamera, make_float3(1, 0, 0));
286  dy = transform_perspective_direction(&rastertocamera, make_float3(0, 1, 0));
287  full_dx = transform_perspective_direction(&full_rastertocamera, make_float3(1, 0, 0));
288  full_dy = transform_perspective_direction(&full_rastertocamera, make_float3(0, 1, 0));
289  }
290  else if (camera_type == CAMERA_PERSPECTIVE) {
291  dx = transform_perspective(&rastertocamera, make_float3(1, 0, 0)) -
292  transform_perspective(&rastertocamera, make_float3(0, 0, 0));
293  dy = transform_perspective(&rastertocamera, make_float3(0, 1, 0)) -
294  transform_perspective(&rastertocamera, make_float3(0, 0, 0));
295  full_dx = transform_perspective(&full_rastertocamera, make_float3(1, 0, 0)) -
296  transform_perspective(&full_rastertocamera, make_float3(0, 0, 0));
297  full_dy = transform_perspective(&full_rastertocamera, make_float3(0, 1, 0)) -
298  transform_perspective(&full_rastertocamera, make_float3(0, 0, 0));
299  }
300  else {
301  dx = zero_float3();
302  dy = zero_float3();
303  }
304 
305  dx = transform_direction(&cameratoworld, dx);
306  dy = transform_direction(&cameratoworld, dy);
307  full_dx = transform_direction(&cameratoworld, full_dx);
308  full_dy = transform_direction(&cameratoworld, full_dy);
309 
310  if (camera_type == CAMERA_PERSPECTIVE) {
311  float3 v = transform_perspective(&full_rastertocamera,
312  make_float3(full_width, full_height, 1.0f));
313  frustum_right_normal = normalize(make_float3(v.z, 0.0f, -v.x));
314  frustum_top_normal = normalize(make_float3(0.0f, v.z, -v.y));
315 
316  v = transform_perspective(&full_rastertocamera, make_float3(0.0f, 0.0f, 1.0f));
317  frustum_left_normal = normalize(make_float3(-v.z, 0.0f, v.x));
318  frustum_bottom_normal = normalize(make_float3(0.0f, -v.z, v.y));
319  }
320 
321  /* Compute kernel camera data. */
322  KernelCamera *kcam = &kernel_camera;
323 
324  /* store matrices */
325  kcam->screentoworld = screentoworld;
326  kcam->rastertoworld = rastertoworld;
327  kcam->rastertocamera = rastertocamera;
328  kcam->cameratoworld = cameratoworld;
329  kcam->worldtocamera = worldtocamera;
330  kcam->worldtoscreen = worldtoscreen;
331  kcam->worldtoraster = worldtoraster;
332  kcam->worldtondc = worldtondc;
333  kcam->ndctoworld = ndctoworld;
334 
335  /* camera motion */
336  kcam->num_motion_steps = 0;
337  kcam->have_perspective_motion = 0;
338  kernel_camera_motion.clear();
339 
340  /* Test if any of the transforms are actually different. */
341  bool have_motion = false;
342  for (size_t i = 0; i < motion.size(); i++) {
343  have_motion = have_motion || motion[i] != matrix;
344  }
345 
346  if (need_motion == Scene::MOTION_PASS) {
347  /* TODO(sergey): Support perspective (zoom, fov) motion. */
348  if (camera_type == CAMERA_PANORAMA) {
349  if (have_motion) {
350  kcam->motion_pass_pre = transform_inverse(motion[0]);
351  kcam->motion_pass_post = transform_inverse(motion[motion.size() - 1]);
352  }
353  else {
354  kcam->motion_pass_pre = kcam->worldtocamera;
355  kcam->motion_pass_post = kcam->worldtocamera;
356  }
357  }
358  else {
359  if (have_motion) {
360  kcam->perspective_pre = cameratoraster * transform_inverse(motion[0]);
361  kcam->perspective_post = cameratoraster * transform_inverse(motion[motion.size() - 1]);
362  }
363  else {
364  kcam->perspective_pre = worldtoraster;
365  kcam->perspective_post = worldtoraster;
366  }
367  }
368  }
369  else if (need_motion == Scene::MOTION_BLUR) {
370  if (have_motion) {
371  kernel_camera_motion.resize(motion.size());
372  transform_motion_decompose(kernel_camera_motion.data(), motion.data(), motion.size());
373  kcam->num_motion_steps = motion.size();
374  }
375 
376  /* TODO(sergey): Support other types of camera. */
377  if (use_perspective_motion && camera_type == CAMERA_PERSPECTIVE) {
378  /* TODO(sergey): Move to an utility function and de-duplicate with
379  * calculation above.
380  */
381  ProjectionTransform screentocamera_pre = projection_inverse(
382  projection_perspective(fov_pre, nearclip, farclip));
383  ProjectionTransform screentocamera_post = projection_inverse(
384  projection_perspective(fov_post, nearclip, farclip));
385 
386  kcam->perspective_pre = screentocamera_pre * rastertoscreen;
387  kcam->perspective_post = screentocamera_post * rastertoscreen;
388  kcam->have_perspective_motion = 1;
389  }
390  }
391 
392  /* depth of field */
393  kcam->aperturesize = aperturesize;
394  kcam->focaldistance = focaldistance;
395  kcam->blades = (blades < 3) ? 0.0f : blades;
396  kcam->bladesrotation = bladesrotation;
397 
398  /* motion blur */
399  kcam->shuttertime = (need_motion == Scene::MOTION_BLUR) ? shuttertime : -1.0f;
400  kcam->motion_position = motion_position;
401 
402  /* type */
403  kcam->type = camera_type;
404 
405  /* anamorphic lens bokeh */
406  kcam->inv_aperture_ratio = 1.0f / aperture_ratio;
407 
408  /* panorama */
409  kcam->panorama_type = panorama_type;
410  kcam->fisheye_fov = fisheye_fov;
411  kcam->fisheye_lens = fisheye_lens;
412  kcam->equirectangular_range = make_float4(longitude_min - longitude_max,
413  -longitude_min,
414  latitude_min - latitude_max,
415  -latitude_min + M_PI_2_F);
416  kcam->fisheye_lens_polynomial_bias = fisheye_polynomial_k0;
418  fisheye_polynomial_k1, fisheye_polynomial_k2, fisheye_polynomial_k3, fisheye_polynomial_k4);
419 
420  switch (stereo_eye) {
421  case STEREO_LEFT:
422  kcam->interocular_offset = -interocular_distance * 0.5f;
423  break;
424  case STEREO_RIGHT:
425  kcam->interocular_offset = interocular_distance * 0.5f;
426  break;
427  case STEREO_NONE:
428  default:
429  kcam->interocular_offset = 0.0f;
430  break;
431  }
432 
433  kcam->convergence_distance = convergence_distance;
434  if (use_pole_merge) {
435  kcam->pole_merge_angle_from = pole_merge_angle_from;
436  kcam->pole_merge_angle_to = pole_merge_angle_to;
437  }
438  else {
439  kcam->pole_merge_angle_from = -1.0f;
440  kcam->pole_merge_angle_to = -1.0f;
441  }
442 
443  /* sensor size */
444  kcam->sensorwidth = sensorwidth;
445  kcam->sensorheight = sensorheight;
446 
447  /* render size */
448  kcam->width = width;
449  kcam->height = height;
450 
451  /* store differentials */
452  kcam->dx = float3_to_float4(dx);
453  kcam->dy = float3_to_float4(dy);
454 
455  /* clipping */
456  kcam->nearclip = nearclip;
457  kcam->cliplength = (farclip == FLT_MAX) ? FLT_MAX : farclip - nearclip;
458 
459  /* Camera in volume. */
460  kcam->is_inside_volume = 0;
461 
462  /* Rolling shutter effect */
463  kcam->rolling_shutter_type = rolling_shutter_type;
464  kcam->rolling_shutter_duration = rolling_shutter_duration;
465 
466  /* Set further update flags */
467  clear_modified();
468  need_device_update = true;
469  need_flags_update = true;
470  previous_need_motion = need_motion;
471 }
472 
473 void Camera::device_update(Device * /* device */, DeviceScene *dscene, Scene *scene)
474 {
475  update(scene);
476 
477  if (!need_device_update)
478  return;
479 
480  scoped_callback_timer timer([scene](double time) {
481  if (scene->update_stats) {
482  scene->update_stats->camera.times.add_entry({"device_update", time});
483  }
484  });
485 
486  scene->lookup_tables->remove_table(&shutter_table_offset);
487  if (kernel_camera.shuttertime != -1.0f) {
488  vector<float> shutter_table;
490  0.0f,
491  1.0f,
492  function_bind(shutter_curve_eval, _1, shutter_curve),
493  false,
494  shutter_table);
495  shutter_table_offset = scene->lookup_tables->add_table(dscene, shutter_table);
496  kernel_camera.shutter_table_offset = (int)shutter_table_offset;
497  }
498 
499  dscene->data.cam = kernel_camera;
500 
501  size_t num_motion_steps = kernel_camera_motion.size();
502  if (num_motion_steps) {
503  DecomposedTransform *camera_motion = dscene->camera_motion.alloc(num_motion_steps);
504  memcpy(camera_motion, kernel_camera_motion.data(), sizeof(*camera_motion) * num_motion_steps);
505  dscene->camera_motion.copy_to_device();
506  }
507  else {
508  dscene->camera_motion.free();
509  }
510 }
511 
513 {
515  return;
516  }
517 
518  KernelIntegrator *kintegrator = &dscene->data.integrator;
519  if (kintegrator->use_volumes) {
520  KernelCamera *kcam = &dscene->data.cam;
521  BoundBox viewplane_boundbox = viewplane_bounds_get();
522 
523  /* Parallel object update, with grain size to avoid too much threading overhead
524  * for individual objects. */
525  static const int OBJECTS_PER_TASK = 32;
526  parallel_for(blocked_range<size_t>(0, scene->objects.size(), OBJECTS_PER_TASK),
527  [&](const blocked_range<size_t> &r) {
528  for (size_t i = r.begin(); i != r.end(); i++) {
529  Object *object = scene->objects[i];
530  if (object->get_geometry()->has_volume &&
531  viewplane_boundbox.intersects(object->bounds)) {
532  /* TODO(sergey): Consider adding more grained check. */
533  VLOG_INFO << "Detected camera inside volume.";
534  kcam->is_inside_volume = 1;
535  parallel_for_cancel();
536  break;
537  }
538  }
539  });
540 
541  if (!kcam->is_inside_volume) {
542  VLOG_INFO << "Camera is outside of the volume.";
543  }
544  }
545 
546  need_device_update = false;
547  need_flags_update = false;
548 }
549 
550 void Camera::device_free(Device * /*device*/, DeviceScene *dscene, Scene *scene)
551 {
553  dscene->camera_motion.free();
554 }
555 
556 float3 Camera::transform_raster_to_world(float raster_x, float raster_y)
557 {
558  float3 D, P;
559  if (camera_type == CAMERA_PERSPECTIVE) {
560  D = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
561  float3 Pclip = normalize(D);
562  P = zero_float3();
563  /* TODO(sergey): Aperture support? */
566  /* TODO(sergey): Clipping is conditional in kernel, and hence it could
567  * be mistakes in here, currently leading to wrong camera-in-volume
568  * detection.
569  */
570  P += nearclip * D / Pclip.z;
571  }
572  else if (camera_type == CAMERA_ORTHOGRAPHIC) {
573  D = make_float3(0.0f, 0.0f, 1.0f);
574  /* TODO(sergey): Aperture support? */
575  P = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
578  }
579  else {
580  assert(!"unsupported camera type");
581  }
582  return P;
583 }
584 
586 {
587  /* TODO(sergey): This is all rather stupid, but is there a way to perform
588  * checks we need in a more clear and smart fashion? */
590 
591  if (camera_type == CAMERA_PANORAMA) {
592  if (use_spherical_stereo == false) {
593  bounds.grow(make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w), nearclip);
594  }
595  else {
596  float half_eye_distance = interocular_distance * 0.5f;
597 
598  bounds.grow(
599  make_float3(cameratoworld.x.w + half_eye_distance, cameratoworld.y.w, cameratoworld.z.w),
600  nearclip);
601 
602  bounds.grow(
603  make_float3(cameratoworld.z.w, cameratoworld.y.w + half_eye_distance, cameratoworld.z.w),
604  nearclip);
605 
606  bounds.grow(
607  make_float3(cameratoworld.x.w - half_eye_distance, cameratoworld.y.w, cameratoworld.z.w),
608  nearclip);
609 
610  bounds.grow(
611  make_float3(cameratoworld.x.w, cameratoworld.y.w - half_eye_distance, cameratoworld.z.w),
612  nearclip);
613  }
614  }
615  else {
616  bounds.grow(transform_raster_to_world(0.0f, 0.0f));
617  bounds.grow(transform_raster_to_world(0.0f, (float)height));
618  bounds.grow(transform_raster_to_world((float)width, (float)height));
619  bounds.grow(transform_raster_to_world((float)width, 0.0f));
620  if (camera_type == CAMERA_PERSPECTIVE) {
621  /* Center point has the most distance in local Z axis,
622  * use it to construct bounding box/
623  */
624  bounds.grow(transform_raster_to_world(0.5f * width, 0.5f * height));
625  }
626  }
627  return bounds;
628 }
629 
631 {
632  float res = 1.0f;
633 
634  if (camera_type == CAMERA_ORTHOGRAPHIC) {
635  res = min(len(full_dx), len(full_dy));
636 
637  if (offscreen_dicing_scale > 1.0f) {
640  make_float3(full_width, full_height, 0.0f));
642 
643  /* Create point clamped to frustum */
644  float3 c;
645  c.x = max(v2.x, min(v1.x, p.x));
646  c.y = max(v2.y, min(v1.y, p.y));
647  c.z = max(0.0f, p.z);
648 
649  /* Check right side */
650  float f_dist = len(p - c) / sqrtf((v1.x * v1.x + v1.y * v1.y) * 0.5f);
651  if (f_dist < 0.0f) {
652  /* Check left side */
653  f_dist = len(p - c) / sqrtf((v2.x * v2.x + v2.y * v2.y) * 0.5f);
654  }
655  if (f_dist > 0.0f) {
656  res += res * f_dist * (offscreen_dicing_scale - 1.0f);
657  }
658  }
659  }
660  else if (camera_type == CAMERA_PERSPECTIVE) {
661  /* Calculate as if point is directly ahead of the camera. */
662  float3 raster = make_float3(0.5f * full_width, 0.5f * full_height, 0.0f);
664 
665  /* dDdx */
666  float3 Ddiff = transform_direction(&cameratoworld, Pcamera);
668  float3 dDdx = normalize(Ddiff + dx) - normalize(Ddiff);
669 
670  /* dPdx */
671  float dist = len(transform_point(&worldtocamera, P));
672  float3 D = normalize(Ddiff);
673  res = len(dist * dDdx - dot(dist * dDdx, D) * D);
674 
675  /* Decent approx distance to frustum
676  * (doesn't handle corners correctly, but not that big of a deal) */
677  float f_dist = 0.0f;
678 
679  if (offscreen_dicing_scale > 1.0f) {
681 
682  /* Distance from the four planes */
683  float r = dot(p, frustum_right_normal);
684  float t = dot(p, frustum_top_normal);
685  float l = dot(p, frustum_left_normal);
686  float b = dot(p, frustum_bottom_normal);
687 
688  if (r <= 0.0f && l <= 0.0f && t <= 0.0f && b <= 0.0f) {
689  /* Point is inside frustum */
690  f_dist = 0.0f;
691  }
692  else if (r > 0.0f && l > 0.0f && t > 0.0f && b > 0.0f) {
693  /* Point is behind frustum */
694  f_dist = len(p);
695  }
696  else {
697  /* Point may be behind or off to the side, need to check */
702 
703  float dist[] = {r, l, t, b};
704  float3 along[] = {along_right, along_left, along_top, along_bottom};
705 
706  bool test_o = false;
707 
708  float *d = dist;
709  float3 *a = along;
710  for (int i = 0; i < 4; i++, d++, a++) {
711  /* Test if we should check this side at all */
712  if (*d > 0.0f) {
713  if (dot(p, *a) >= 0.0f) {
714  /* We are in front of the back edge of this side of the frustum */
715  f_dist = max(f_dist, *d);
716  }
717  else {
718  /* Possibly far enough behind the frustum to use distance to origin instead of edge
719  */
720  test_o = true;
721  }
722  }
723  }
724 
725  if (test_o) {
726  f_dist = (f_dist > 0) ? min(f_dist, len(p)) : len(p);
727  }
728  }
729 
730  if (f_dist > 0.0f) {
731  res += len(dDdx - dot(dDdx, D) * D) * f_dist * (offscreen_dicing_scale - 1.0f);
732  }
733  }
734  }
735  else if (camera_type == CAMERA_PANORAMA) {
737  float dist = len(D);
738 
739  Ray ray;
740  memset(&ray, 0, sizeof(ray));
741 
742  /* Distortion can become so great that the results become meaningless, there
743  * may be a better way to do this, but calculating differentials from the
744  * point directly ahead seems to produce good enough results. */
745 #if 0
747  float3 raster = transform_perspective(&full_cameratoraster, make_float3(dir.x, dir.y, 0.0f));
748 
749  ray.t = 1.0f;
751  &kernel_camera, kernel_camera_motion.data(), raster.x, raster.y, 0.0f, 0.0f, &ray);
752  if (ray.t == 0.0f) {
753  /* No differentials, just use from directly ahead. */
756  0.5f * full_width,
757  0.5f * full_height,
758  0.0f,
759  0.0f,
760  &ray);
761  }
762 #else
764 # ifdef __CAMERA_MOTION__
766 # endif
767  0.5f * full_width,
768  0.5f * full_height,
769  0.0f,
770  0.0f,
771  &ray);
772 #endif
773 
774  /* TODO: would it help to use more accurate differentials here? */
775  differential3 dP;
776  differential_transfer_compact(&dP, ray.dP, ray.D, ray.dD, ray.D, dist);
777 
778  return max(len(dP.dx), len(dP.dy));
779  }
780 
781  return res;
782 }
783 
784 bool Camera::use_motion() const
785 {
786  return motion.size() > 1;
787 }
788 
789 void Camera::set_screen_size(int width_, int height_)
790 {
791  if (width_ != width || height_ != height) {
792  width = width_;
793  height = height_;
794  tag_modified();
795  }
796 }
797 
798 float Camera::motion_time(int step) const
799 {
800  return (use_motion()) ? 2.0f * step / (motion.size() - 1) - 1.0f : 0.0f;
801 }
802 
803 int Camera::motion_step(float time) const
804 {
805  if (use_motion()) {
806  for (int step = 0; step < motion.size(); step++) {
807  if (time == motion_time(step)) {
808  return step;
809  }
810  }
811  }
812 
813  return -1;
814 }
815 
typedef float(TangentPoint)[2]
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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 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 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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition: btDbvt.cpp:299
float bottom
Definition: boundbox.h:195
float top
Definition: boundbox.h:196
float right
Definition: boundbox.h:194
float left
Definition: boundbox.h:193
device_vector< DecomposedTransform > camera_motion
Definition: scene.h:98
KernelData data
Definition: scene.h:130
size_t add_table(DeviceScene *dscene, vector< float > &data)
Definition: tables.cpp:60
void remove_table(size_t *offset)
Definition: tables.cpp:95
size_t size() const
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_device_inline float2 direction_to_panorama(ccl_constant KernelCamera *cam, float3 dir)
ccl_device_inline float3 transform_perspective(ccl_private const ProjectionTransform *t, const float3 a)
ccl_device_inline ProjectionTransform projection_perspective(float fov, float n, float f)
ccl_device_inline float3 transform_perspective_direction(ccl_private const ProjectionTransform *t, const float3 a)
ccl_device_inline ProjectionTransform projection_identity()
ProjectionTransform projection_inverse(const ProjectionTransform &a)
Definition: transform.cpp:93
ccl_device_inline ProjectionTransform projection_orthographic(float znear, float zfar)
double time
Scene scene
#define function_bind
ccl_device_forceinline void differential_transfer_compact(ccl_private differential3 *surface_dP, const float ray_dP, const float3, const float ray_dD, const float3 surface_Ng, const float ray_t)
Definition: differential.h:122
int len
Definition: draw_manager.c:108
IconTextureDrawCall border
ccl_device_inline Transform transform_identity()
ccl_device_inline Transform transform_inverse(const Transform tfm)
ccl_device_inline float3 transform_direction(ccl_private const Transform *t, const float3 a)
ccl_device_inline Transform transform_scale(float3 s)
CCL_NAMESPACE_END CCL_NAMESPACE_BEGIN ccl_device_inline float3 transform_point(ccl_private const Transform *t, const float3 a)
ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam, float raster_x, float raster_y, float lens_u, float lens_v, ccl_private Ray *ray)
#define __CAMERA_MOTION__
Definition: kernel/types.h:80
@ MOTION_POSITION_END
Definition: kernel/types.h:487
@ MOTION_POSITION_START
Definition: kernel/types.h:483
@ MOTION_POSITION_CENTER
Definition: kernel/types.h:485
#define SHUTTER_TABLE_SIZE
Definition: kernel/types.h:28
#define RAMP_TABLE_SIZE
Definition: kernel/types.h:27
@ PANORAMA_MIRRORBALL
Definition: kernel/types.h:474
@ PANORAMA_FISHEYE_EQUISOLID
Definition: kernel/types.h:473
@ PANORAMA_FISHEYE_EQUIDISTANT
Definition: kernel/types.h:472
@ PANORAMA_FISHEYE_LENS_POLYNOMIAL
Definition: kernel/types.h:475
@ PANORAMA_EQUIRECTANGULAR
Definition: kernel/types.h:471
@ CAMERA_PERSPECTIVE
Definition: kernel/types.h:466
@ CAMERA_PANORAMA
Definition: kernel/types.h:466
@ CAMERA_ORTHOGRAPHIC
Definition: kernel/types.h:466
#define VLOG_INFO
Definition: log.h:77
void util_cdf_inverted(const int resolution, const float from, const float to, Functor functor, const bool make_symmetric, vector< float > &inv_cdf)
Definition: math_cdf.h:44
ccl_device_inline float3 zero_float3()
Definition: math_float3.h:80
ccl_device_inline float len_squared(const float3 a)
Definition: math_float3.h:423
static float P(float k)
Definition: math_interp.c:25
#define make_float4(x, y, z, w)
Definition: metal/compat.h:205
#define sqrtf(x)
Definition: metal/compat.h:243
#define make_float3(x, y, z)
Definition: metal/compat.h:204
static float lerp(float t, float a, float b)
ccl_device_inline float frac(float x, int *ix)
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value)
Allocate a new IDProperty of type IDP_INT, set its name and value.
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
Definition: BLI_task.hh:51
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
#define SOCKET_FLOAT(name, ui_name, default_value,...)
Definition: node_type.h:191
#define SOCKET_INT(name, ui_name, default_value,...)
Definition: node_type.h:187
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value,...)
Definition: node_type.h:239
#define SOCKET_TRANSFORM(name, ui_name, default_value,...)
Definition: node_type.h:205
#define SOCKET_UINT(name, ui_name, default_value,...)
Definition: node_type.h:189
#define SOCKET_TRANSFORM_ARRAY(name, ui_name, default_value,...)
Definition: node_type.h:260
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
Definition: node_type.h:185
#define SOCKET_ENUM(name, ui_name, values, default_value,...)
Definition: node_type.h:207
NODE_DEFINE(Camera)
static CCL_NAMESPACE_BEGIN float shutter_curve_eval(float x, array< float > &shutter_curve)
@ TABLE_OFFSET_INVALID
Definition: scene/tables.h:17
#define min(a, b)
Definition: sort.c:35
@ empty
Definition: boundbox.h:35
bool need_device_update
Definition: scene/camera.h:172
ProjectionTransform worldtoraster
Definition: scene/camera.h:150
float3 frustum_right_normal
Definition: scene/camera.h:166
BoundBox2D viewplane
Definition: scene/camera.h:110
void set_screen_size(int width_, int height_)
int previous_need_motion
Definition: scene/camera.h:174
float3 full_dy
Definition: scene/camera.h:164
bool need_flags_update
Definition: scene/camera.h:173
float3 full_dx
Definition: scene/camera.h:163
ProjectionTransform rastertoworld
Definition: scene/camera.h:146
BoundBox viewplane_bounds_get()
Transform worldtocamera
Definition: scene/camera.h:153
float motion_time(int step) const
void update(Scene *scene)
ProjectionTransform rastertocamera
Definition: scene/camera.h:155
ProjectionTransform screentoworld
Definition: scene/camera.h:145
bool use_motion() const
size_t shutter_table_offset
Definition: scene/camera.h:54
void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene)
void device_free(Device *device, DeviceScene *dscene, Scene *scene)
ProjectionTransform ndctoworld
Definition: scene/camera.h:147
float3 dx
Definition: scene/camera.h:160
void device_update(Device *device, DeviceScene *dscene, Scene *scene)
float3 frustum_left_normal
Definition: scene/camera.h:168
float world_to_raster_size(float3 P)
Transform cameratoworld
Definition: scene/camera.h:148
int motion_step(float time) const
void compute_auto_viewplane()
float3 frustum_top_normal
Definition: scene/camera.h:167
ProjectionTransform full_rastertocamera
Definition: scene/camera.h:158
float3 frustum_bottom_normal
Definition: scene/camera.h:169
float3 dy
Definition: scene/camera.h:161
KernelCamera kernel_camera
Definition: scene/camera.h:177
array< DecomposedTransform > kernel_camera_motion
Definition: scene/camera.h:178
float focaldistance
ProjectionTransform ndctoworld
float pole_merge_angle_to
Definition: kernel/types.h:999
int have_perspective_motion
float sensorheight
ProjectionTransform rastertocamera
float pole_merge_angle_from
Definition: kernel/types.h:998
float aperturesize
ProjectionTransform worldtoraster
float fisheye_fov
Definition: kernel/types.h:989
float fisheye_lens_polynomial_bias
Definition: kernel/types.h:992
Transform motion_pass_post
Transform cameratoworld
float4 equirectangular_range
Definition: kernel/types.h:991
float interocular_offset
Definition: kernel/types.h:996
Transform worldtocamera
ProjectionTransform screentoworld
float inv_aperture_ratio
ProjectionTransform perspective_post
float rolling_shutter_duration
ProjectionTransform perspective_pre
ProjectionTransform worldtoscreen
Transform motion_pass_pre
int rolling_shutter_type
ProjectionTransform worldtondc
float fisheye_lens
Definition: kernel/types.h:990
float bladesrotation
float convergence_distance
Definition: kernel/types.h:997
ProjectionTransform rastertoworld
float4 fisheye_lens_polynomial_coefficients
Definition: kernel/types.h:993
KernelCamera cam
void insert(const char *x, int y)
Definition: node_enum.h:20
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=NULL)
void tag_modified()
Definition: graph/node.cpp:809
bool is_modified() const
Definition: graph/node.cpp:804
float dD
Definition: kernel/types.h:534
float dP
Definition: kernel/types.h:533
float3 D
Definition: kernel/types.h:525
MotionType need_motion() const
Definition: scene.cpp:387
LookupTables * lookup_tables
Definition: scene.h:207
vector< Object * > objects
Definition: scene.h:213
MotionType
Definition: scene.h:259
@ MOTION_PASS
Definition: scene.h:259
@ MOTION_BLUR
Definition: scene.h:259
SceneUpdateStats * update_stats
Definition: scene.h:249
float x
Definition: types_float2.h:15
float y
Definition: types_float2.h:15
float z
float y
float x
void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, size_t size)
Definition: transform.cpp:246
Transform transform_from_viewplane(BoundBox2D &viewplane)
Definition: transform.cpp:282
float max
#define M_PI_2_F
Definition: util/math.h:37
#define M_PI_4_F
Definition: util/math.h:40
ccl_device_inline float4 float3_to_float4(const float3 a)
Definition: util/math.h:505
#define M_PI_F
Definition: util/math.h:34
BLI_INLINE float D(const float *data, const int res[3], int x, int y, int z)
Definition: voxel.c:13