[Bf-blender-cvs] [6b91fb7] master: Cycles: Optimize derivatives calculation by using pre-calculated dx/dy
Sergey Sharybin
noreply at git.blender.org
Sat Mar 12 11:15:54 CET 2016
Commit: 6b91fb706d60033af9d2a1b09015d99ffc7e3bbc
Author: Sergey Sharybin
Date: Fri Mar 11 21:41:16 2016 +0500
Branches: master
https://developer.blender.org/rB6b91fb706d60033af9d2a1b09015d99ffc7e3bbc
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.
===================================================================
M intern/cycles/kernel/kernel_camera.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index db2f45c..31a578e 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 */
More information about the Bf-blender-cvs
mailing list