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/kernel/svm/svm_image.h | |
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/kernel/svm/svm_image.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_image.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 44d15e185cb..e667fc2033d 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -354,6 +354,12 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, #endif +/* Remap coordnate from 0..1 box to -1..-1 */ +ccl_device_inline float3 texco_remap_square(float3 co) +{ + return (co - make_float3(0.5f, 0.5f, 0.5f)) * 2.0f; +} + ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint id = node.y; @@ -364,9 +370,13 @@ ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *sta float3 co = stack_load_float3(stack, co_offset); uint use_alpha = stack_valid(alpha_offset); if(node.w == NODE_IMAGE_PROJ_SPHERE) { - co = (co - make_float3(0.5f, 0.5f, 0.5f)) * 2.0f; + co = texco_remap_square(co); map_to_sphere(&co.x, &co.y, co.x, co.y, co.z); } + else if(node.w == NODE_IMAGE_PROJ_TUBE) { + co = texco_remap_square(co); + map_to_tube(&co.x, &co.y, co.x, co.y, co.z); + } float4 f = svm_image_texture(kg, id, co.x, co.y, srgb, use_alpha); if(stack_valid(out_offset)) |