diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-19 10:52:48 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-19 10:52:48 +0300 |
commit | 3e534833e3a83ceecef35aa6c32764971e3b086e (patch) | |
tree | a3d56ccf3cc8205aa9b2a129ece3b361817ccd1f /intern/cycles/kernel/svm/svm_image.h | |
parent | 5004b582622144317948262793d5a4199ec90f13 (diff) |
Cycles: Make sphere and tube image mapping friendly with OpenCL
OpenCL doesn't let you to get address of vector components, which
is kinda annoying. On the other hand, maybe now compiler will have
more chances to optimize something out.
Diffstat (limited to 'intern/cycles/kernel/svm/svm_image.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_image.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index e667fc2033d..4de69479bd9 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -368,16 +368,20 @@ ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *sta decode_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &srgb); float3 co = stack_load_float3(stack, co_offset); + float2 tex_co; uint use_alpha = stack_valid(alpha_offset); if(node.w == NODE_IMAGE_PROJ_SPHERE) { co = texco_remap_square(co); - map_to_sphere(&co.x, &co.y, co.x, co.y, co.z); + tex_co = map_to_sphere(co); } 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); + tex_co = map_to_tube(co); } - float4 f = svm_image_texture(kg, id, co.x, co.y, srgb, use_alpha); + else { + tex_co = make_float2(co.x, co.y); + } + float4 f = svm_image_texture(kg, id, tex_co.x, tex_co.y, srgb, use_alpha); if(stack_valid(out_offset)) stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z)); |