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