diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-21 16:36:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-21 18:40:03 +0300 |
commit | dc3563ff4801907ec8cd21a1589f0cb56d021a8f (patch) | |
tree | 88743d23f009deb1d3a3cc379ba1d67f5116a91e /intern/cycles/kernel | |
parent | 1df42798d46d031c7666a75b47faa0d20fc965ef (diff) |
Cycles: Implement camera zoom motion blur
Works totally similar to camera motion blur and majority of the changes are
related on just passing extra arguments to sync() functions.
Couple of things still to look into:
- Motion pass will not include motion caused by the zoom.
- Only perspective cameras are supported currently.
- Motion is being interpolated on projected coordinates, which might give
different results from constructing projection matrix from interpolated
field of view.
This could be good enough for us, but we need to consider improving this
at some point.
Reviewers: juicyfruit, dingto
Reviewed By: dingto
Differential Revision: https://developer.blender.org/D1383
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 25 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 8 |
2 files changed, 30 insertions, 3 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 3ce5134181a..67651f96544 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -43,7 +43,30 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo { /* create ray form raster position */ Transform rastertocamera = kernel_data.cam.rastertocamera; - float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); + float3 raster = make_float3(raster_x, raster_y, 0.0f); + float3 Pcamera = transform_perspective(&rastertocamera, raster); + +#ifdef __CAMERA_MOTION__ + if(kernel_data.cam.have_perspective_motion) { + /* TODO(sergey): Currently we interpolate projected coordinate which + * gives nice looking result and which is simple, but is in fact a bit + * different comparing to constructing projective matrix from an + * interpolated field of view. + */ + if(ray->time < 0.5f) { + Transform rastertocamera_pre = kernel_data.cam.perspective_motion.pre; + float3 Pcamera_pre = + transform_perspective(&rastertocamera_pre, raster); + Pcamera = interp(Pcamera_pre, Pcamera, ray->time * 2.0f); + } + else { + Transform rastertocamera_post = kernel_data.cam.perspective_motion.post; + float3 Pcamera_post = + transform_perspective(&rastertocamera_post, raster); + Pcamera = interp(Pcamera, Pcamera_post, (ray->time - 0.5f) * 2.0f); + } + } +#endif ray->P = make_float3(0.0f, 0.0f, 0.0f); ray->D = Pcamera; diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 46e5d6b2a31..ba8cba1dc83 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -778,7 +778,7 @@ typedef struct KernelCamera { /* motion blur */ float shuttertime; - int have_motion; + int have_motion, have_perspective_motion; /* clipping */ float nearclip; @@ -796,7 +796,6 @@ typedef struct KernelCamera { float inv_aperture_ratio; int is_inside_volume; - int pad2; /* more matrices */ Transform screentoworld; @@ -810,6 +809,11 @@ typedef struct KernelCamera { Transform worldtocamera; MotionTransform motion; + + /* Denotes changes in the projective matrix, namely in rastertocamera. + * Used for camera zoom motion blur, + */ + PerspectiveMotionTransform perspective_motion; } KernelCamera; typedef struct KernelFilm { |