Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2017-09-05 19:11:13 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-09-06 14:51:45 +0300
commitdd8016f7081fb502b969b3c1f7512e00466879eb (patch)
tree9b9b4ea5afba8e8da82cdb4224319f13e34e14bd /intern
parent56ff14ea6318ea7800c991a239fe8b8de6527d08 (diff)
Fix T52652: Cycles image box mapping has flipped textures.
This breaks backwards compatibility some in that 3 sides will be mapped differently now, but difficult to avoid and can be considered a bugfix.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/svm/svm_image.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 7be03dcd65a..6d6e92e73f6 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -211,6 +211,8 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
object_inverse_normal_transform(kg, sd, &N);
/* project from direction vector to barycentric coordinates in triangles */
+ float3 signed_N = N;
+
N.x = fabsf(N.x);
N.y = fabsf(N.y);
N.z = fabsf(N.z);
@@ -280,12 +282,19 @@ ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float
float4 f = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
uint use_alpha = stack_valid(alpha_offset);
- if(weight.x > 0.0f)
- f += weight.x*svm_image_texture(kg, id, co.y, co.z, srgb, use_alpha);
- if(weight.y > 0.0f)
- f += weight.y*svm_image_texture(kg, id, co.x, co.z, srgb, use_alpha);
- if(weight.z > 0.0f)
- f += weight.z*svm_image_texture(kg, id, co.y, co.x, srgb, use_alpha);
+ /* Map so that no textures are flipped, rotation is somewhat arbitrary. */
+ if(weight.x > 0.0f) {
+ float2 uv = make_float2((signed_N.x < 0.0f)? 1.0f - co.y: co.y, co.z);
+ f += weight.x*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
+ if(weight.y > 0.0f) {
+ float2 uv = make_float2((signed_N.y > 0.0f)? 1.0f - co.x: co.x, co.z);
+ f += weight.y*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
+ if(weight.z > 0.0f) {
+ float2 uv = make_float2((signed_N.z > 0.0f)? 1.0f - co.y: co.y, co.x);
+ f += weight.z*svm_image_texture(kg, id, uv.x, uv.y, srgb, use_alpha);
+ }
if(stack_valid(out_offset))
stack_store_float3(stack, out_offset, make_float3(f.x, f.y, f.z));