[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46387] trunk/blender/intern/cycles/kernel /kernel_projection.h: direction to equisolid - final fix for [#31307] Cycles panoramic fisheye lens and vector pass problem
Dalai Felinto
dfelinto at gmail.com
Mon May 7 18:51:56 CEST 2012
Revision: 46387
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46387
Author: dfelinto
Date: 2012-05-07 16:51:55 +0000 (Mon, 07 May 2012)
Log Message:
-----------
direction to equisolid - final fix for [#31307] Cycles panoramic fisheye lens and vector pass problem
Modified Paths:
--------------
trunk/blender/intern/cycles/kernel/kernel_projection.h
Modified: trunk/blender/intern/cycles/kernel/kernel_projection.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_projection.h 2012-05-07 15:50:57 UTC (rev 46386)
+++ trunk/blender/intern/cycles/kernel/kernel_projection.h 2012-05-07 16:51:55 UTC (rev 46387)
@@ -74,7 +74,7 @@
cos(theta));
}
-/* Fisheye <- Cartesian direction */
+/* Fisheye <-> Cartesian direction */
__device float2 direction_to_fisheye(float3 dir, float fov)
{
@@ -109,12 +109,15 @@
);
}
-__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float fov, float width, float height)
+__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
{
- /* XXX not implemented yet */
- float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f;
- float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f;
+ float theta = acosf(dir.x);
+ float r = 2.0f * lens * sinf(theta * 0.25f);
+ float phi = atan2f(dir.z, dir.y);
+ float u = r * cosf(phi) / width + 0.5f;
+ float v = r * sinf(phi) / height + 0.5f;
+
return make_float2(u, v);
}
@@ -197,7 +200,7 @@
case PANORAMA_FISHEYE_EQUISOLID:
default:
return direction_to_fisheye_equisolid(dir, kernel_data.cam.fisheye_lens,
- kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight);
+ kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight);
}
}
More information about the Bf-blender-cvs
mailing list