[Bf-blender-cvs] [bb194e6b842] blender-v2.93-release: Fix T103615: OSL image box mapping has flipped textures

Philipp Oeser noreply at git.blender.org
Fri Jan 13 10:21:52 CET 2023


Commit: bb194e6b842ca23e36fb007fe8a7a39cbf52d1cf
Author: Philipp Oeser
Date:   Wed Jan 4 10:33:40 2023 +0100
Branches: blender-v2.93-release
https://developer.blender.org/rBbb194e6b842ca23e36fb007fe8a7a39cbf52d1cf

Fix T103615: OSL 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.

Similar to rBdd8016f7081f.

Maniphest Tasks: T103615

Differential Revision: https://developer.blender.org/D16910

===================================================================

M	intern/cycles/kernel/shaders/node_image_texture.osl

===================================================================

diff --git a/intern/cycles/kernel/shaders/node_image_texture.osl b/intern/cycles/kernel/shaders/node_image_texture.osl
index 9e2ef84c872..9fb203de67c 100644
--- a/intern/cycles/kernel/shaders/node_image_texture.osl
+++ b/intern/cycles/kernel/shaders/node_image_texture.osl
@@ -135,6 +135,7 @@ shader node_image_texture(int use_mapping = 0,
     vector Nob = transform("world", "object", N);
 
     /* project from direction vector to barycentric coordinates in triangles */
+    vector signed_Nob = Nob;
     Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2]));
     Nob /= (Nob[0] + Nob[1] + Nob[2]);
 
@@ -197,9 +198,10 @@ shader node_image_texture(int use_mapping = 0,
     float tmp_alpha;
 
     if (weight[0] > 0.0) {
+      point UV = point((signed_Nob[0] < 0.0) ? 1.0 - p[1] : p[1], p[2], 0.0);
       Color += weight[0] * image_texture_lookup(filename,
-                                                p[1],
-                                                p[2],
+                                                UV[0],
+                                                UV[1],
                                                 tmp_alpha,
                                                 compress_as_srgb,
                                                 ignore_alpha,
@@ -211,9 +213,10 @@ shader node_image_texture(int use_mapping = 0,
       Alpha += weight[0] * tmp_alpha;
     }
     if (weight[1] > 0.0) {
+      point UV = point((signed_Nob[1] > 0.0) ? 1.0 - p[0] : p[0], p[2], 0.0);
       Color += weight[1] * image_texture_lookup(filename,
-                                                p[0],
-                                                p[2],
+                                                UV[0],
+                                                UV[1],
                                                 tmp_alpha,
                                                 compress_as_srgb,
                                                 ignore_alpha,
@@ -225,9 +228,10 @@ shader node_image_texture(int use_mapping = 0,
       Alpha += weight[1] * tmp_alpha;
     }
     if (weight[2] > 0.0) {
+      point UV = point((signed_Nob[2] > 0.0) ? 1.0 - p[1] : p[1], p[0], 0.0);
       Color += weight[2] * image_texture_lookup(filename,
-                                                p[1],
-                                                p[0],
+                                                UV[0],
+                                                UV[1],
                                                 tmp_alpha,
                                                 compress_as_srgb,
                                                 ignore_alpha,



More information about the Bf-blender-cvs mailing list