diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-05-07 20:51:55 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-05-07 20:51:55 +0400 |
commit | 9a731205e942da12c622dac9804ff308a6f1c4c6 (patch) | |
tree | 5e9380ea6de3e7e6222dac5525a2b3972376c75f /intern | |
parent | 4bbcb7714ecc212864a0b574136f17baa0191f01 (diff) |
direction to equisolid - final fix for [#31307] Cycles panoramic fisheye lens and vector pass problem
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/kernel_projection.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index 43535182d61..0ff905b7db8 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -74,7 +74,7 @@ __device float3 equirectangular_to_direction(float u, float v) cos(theta)); } -/* Fisheye <- Cartesian direction */ +/* Fisheye <-> Cartesian direction */ __device float2 direction_to_fisheye(float3 dir, float fov) { @@ -109,11 +109,14 @@ __device float3 fisheye_to_direction(float u, float v, float fov) ); } -__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 @@ __device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) 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); } } |