diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-11 19:41:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-12 13:01:20 +0300 |
commit | 6b91fb706d60033af9d2a1b09015d99ffc7e3bbc (patch) | |
tree | c4cf39a5a300d78279ad9bc44f097d8609ce9fc0 /intern/cycles/kernel/kernel_camera.h | |
parent | a8c87bad22e618fab19521b4e2d162d19946db98 (diff) |
Cycles: Optimize derivatives calculation by using pre-calculated dx/dy
We've got pixel-wide world-space derivatives which we can use in the
perspective camera sampling. This allows to get rid of two calls to
transform_direction() function.
In theory we can save two transform_perspective() calls if we'll also
save pre-calculated camera-space dx/dy.
Diffstat (limited to 'intern/cycles/kernel/kernel_camera.h')
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index db2f45ce096..31a578e0b44 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -114,18 +114,20 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo /* ray differential */ ray->dP = differential3_zero(); - tD = transform_direction(&cameratoworld, Pcamera); - float3 Pdiff = spherical_stereo_position(kg, tD, Pcamera); - float3 Ddiff = spherical_stereo_direction(kg, tD, Pcamera, Pdiff); + float3 tD_diff = transform_direction(&cameratoworld, Pcamera); + float3 Pdiff = spherical_stereo_position(kg, tD_diff, Pcamera); + float3 Ddiff = spherical_stereo_direction(kg, tD_diff, Pcamera, Pdiff); - tP = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); - tD = transform_direction(&cameratoworld, tP); + tP = transform_perspective(&rastertocamera, + make_float3(raster_x + 1.0f, raster_y, 0.0f)); + tD = tD_diff + float4_to_float3(kernel_data.cam.dx); Pcamera = spherical_stereo_position(kg, tD, tP); ray->dD.dx = spherical_stereo_direction(kg, tD, tP, Pcamera) - Ddiff; ray->dP.dx = Pcamera - Pdiff; - tP = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); - tD = transform_direction(&cameratoworld, tP); + tP = transform_perspective(&rastertocamera, + make_float3(raster_x, raster_y + 1.0f, 0.0f)); + tD = tD_diff + float4_to_float3(kernel_data.cam.dy); Pcamera = spherical_stereo_position(kg, tD, tP); ray->dD.dy = spherical_stereo_direction(kg, tD, tP, Pcamera) - Ddiff; /* dP.dy is zero, since the omnidirectional panorama only shift the eyes horizontally */ |