From 4a903395194aef1cfe97e4d50d73320a72280cf3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 28 Feb 2012 16:44:54 +0000 Subject: Cycles: support for camera rendering an environment map with equirectangular environment map, by enabling the Panorama option in the camera. http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Camera#Panorama The focal length or sensor settings are not used, the UI can be tweaked still to communicate this, also panorama should probably become a proper camera type like perspective or ortho. --- intern/cycles/kernel/kernel_montecarlo.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'intern/cycles/kernel/kernel_montecarlo.h') diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 9776baf65e4..66bd0ee9998 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -185,7 +185,7 @@ __device float2 regular_polygon_sample(float corners, float rotation, float u, f return make_float2(cr*p.x - sr*p.y, sr*p.x + cr*p.y); } -/* Spherical coordinates <-> Cartesion direction */ +/* Spherical coordinates <-> Cartesian direction */ __device float2 direction_to_spherical(float3 dir) { @@ -203,11 +203,11 @@ __device float3 spherical_to_direction(float theta, float phi) cosf(theta)); } -/* Equirectangular */ +/* Equirectangular coordinates <-> Cartesian direction */ __device float2 direction_to_equirectangular(float3 dir) { - float u = (atan2f(dir.y, dir.x) + M_PI_F)/(2.0f*M_PI_F); + 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; return make_float2(u, v); @@ -215,9 +215,8 @@ __device float2 direction_to_equirectangular(float3 dir) __device float3 equirectangular_to_direction(float u, float v) { - /* XXX check correctness? */ - float theta = M_PI_F*v; - float phi = 2.0f*M_PI_F*u; + float phi = M_PI_F*(1.0f - 2.0f*u); + float theta = M_PI_F*(1.0f - v); return make_float3( sin(theta)*cos(phi), -- cgit v1.2.3