diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-02-28 20:44:54 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-02-28 20:44:54 +0400 |
commit | 4a903395194aef1cfe97e4d50d73320a72280cf3 (patch) | |
tree | 056c15cc54f0d0446aef69c9b7f299023c01a69f /intern/cycles/kernel/kernel_montecarlo.h | |
parent | 0052cbed0dadafce44f818d3d2016254c3d914d0 (diff) |
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.
Diffstat (limited to 'intern/cycles/kernel/kernel_montecarlo.h')
-rw-r--r-- | intern/cycles/kernel/kernel_montecarlo.h | 11 |
1 files changed, 5 insertions, 6 deletions
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), |