diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-17 15:25:29 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-17 15:25:29 +0400 |
commit | 3f3fec37e5ae030f6daac055c75b4a54bf68d873 (patch) | |
tree | cb190a018c3fd65d1accb1b0c82a2508a5a6ee20 /intern/cycles | |
parent | 9678b0da4e8ba00114162a8ec1b10bd34cd68257 (diff) |
Fix cycles panorama camera not working with depth of field, patch by
Daniel M. Basso, thanks!
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index e1b474d8537..7fa987197c9 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -134,7 +134,7 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa /* Panorama Camera */ -__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray) +__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); @@ -151,6 +151,26 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y); + /* modify ray for depth of field */ + float aperturesize = kernel_data.cam.aperturesize; + + if(aperturesize > 0.0f) { + /* sample point on aperture */ + float2 lensuv = camera_sample_aperture(kg, lens_u, lens_v)*aperturesize; + + /* compute point on plane of focus */ + float3 D = normalize(ray->D); + float3 Pfocus = D * kernel_data.cam.focaldistance; + + /* calculate orthonormal coordinates perpendicular to D */ + float3 U, V; + make_orthonormals(D, &U, &V); + + /* update ray for effect of lens */ + ray->P = U * lensuv.x + V * lensuv.y; + ray->D = normalize(Pfocus - ray->P); + } + /* indicates ray should not receive any light, outside of the lens */ if(len_squared(ray->D) == 0.0f) { ray->t = 0.0f; @@ -206,7 +226,7 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo else if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) camera_sample_orthographic(kg, raster_x, raster_y, ray); else - camera_sample_panorama(kg, raster_x, raster_y, ray); + camera_sample_panorama(kg, raster_x, raster_y, lens_u, lens_v, ray); } CCL_NAMESPACE_END |