From dc3563ff4801907ec8cd21a1589f0cb56d021a8f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 21 Jul 2015 15:36:35 +0200 Subject: 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 --- intern/cycles/kernel/kernel_camera.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'intern/cycles/kernel/kernel_camera.h') 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; -- cgit v1.2.3