[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50694] trunk/blender/intern/cycles/kernel /kernel_camera.h: Fix cycles panorama camera not working with depth of field, patch by

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Sep 17 13:25:29 CEST 2012


Revision: 50694
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50694
Author:   blendix
Date:     2012-09-17 11:25:29 +0000 (Mon, 17 Sep 2012)
Log Message:
-----------
Fix cycles panorama camera not working with depth of field, patch by
Daniel M. Basso, thanks!

Modified Paths:
--------------
    trunk/blender/intern/cycles/kernel/kernel_camera.h

Modified: trunk/blender/intern/cycles/kernel/kernel_camera.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_camera.h	2012-09-17 11:25:10 UTC (rev 50693)
+++ trunk/blender/intern/cycles/kernel/kernel_camera.h	2012-09-17 11:25:29 UTC (rev 50694)
@@ -134,7 +134,7 @@
 
 /* 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 @@
 
 	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 @@
 	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




More information about the Bf-blender-cvs mailing list