diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-21 22:37:09 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-21 22:41:42 +0300 |
commit | dda355442dc7ba4f83f65cb792be3f27be8c9fee (patch) | |
tree | 4348e9dfa77c29ff2b682e00cf3342dd39684188 /intern/cycles/util | |
parent | 12ccac657f173ca74716e67cc80830c1142f8b22 (diff) |
Cycles: Support tube projection for images
This way Cycles finally becomes feature-full on image projections
compared to Blender Internal and Gooseberry Project Team could
finally finish the movie.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_math.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 177a72bc1c9..623849ea7c7 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -1450,6 +1450,20 @@ ccl_device bool ray_quad_intersect( } /* projections */ +ccl_device void map_to_tube(float *r_u, float *r_v, + const float x, const float y, const float z) +{ + float len; + *r_v = (z + 1.0f) * 0.5f; + len = sqrtf(x * x + y * y); + if (len > 0.0f) { + *r_u = (1.0f - (atan2f(x / len, y / len) / (float)M_PI)) * 0.5f; + } + else { + *r_v = *r_u = 0.0f; /* To avoid un-initialized variables. */ + } +} + ccl_device bool map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z) { |