[Bf-blender-cvs] [3002f66362c] cycles_texture_cache: Cycles: Fixed differentials for UDIM textures.

Stefan Werner noreply at git.blender.org
Tue May 11 14:19:16 CEST 2021


Commit: 3002f66362c5e20492eae2d3fe2e67614bacbf38
Author: Stefan Werner
Date:   Tue May 11 14:18:07 2021 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB3002f66362c5e20492eae2d3fe2e67614bacbf38

Cycles: Fixed differentials for UDIM textures.

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

M	intern/cycles/kernel/svm/svm_image.h

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

diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 78df4a9a69e..bef90209cb1 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -70,6 +70,40 @@ ccl_device void svm_node_tex_image(
     tex_co = make_float2(co.x, co.y);
   }
 
+  differential ds, dt;
+#ifdef __KERNEL_CPU__
+  if (stack_valid(dx_offset) && stack_valid(dy_offset)) {
+    float3 dx = stack_load_float3(stack, dx_offset);
+    float3 dy = stack_load_float3(stack, dy_offset);
+    float2 tex_co_dx, tex_co_dy;
+    if (projection == NODE_IMAGE_PROJ_SPHERE) {
+      dx = texco_remap_square(dx);
+      tex_co_dx = map_to_sphere(dx);
+      dy = texco_remap_square(dy);
+      tex_co_dy = map_to_sphere(dy);
+    }
+    else if (projection == NODE_IMAGE_PROJ_TUBE) {
+      dx = texco_remap_square(dx);
+      tex_co_dx = map_to_tube(dx);
+      dy = texco_remap_square(dy);
+      tex_co_dy = map_to_tube(dy);
+    }
+    else {
+      tex_co_dx = make_float2(dx.x, dx.y);
+      tex_co_dy = make_float2(dy.x, dy.y);
+    }
+    ds.dx = tex_co_dx.x - tex_co.x;
+    ds.dy = tex_co_dy.x - tex_co.x;
+    dt.dx = tex_co_dx.y - tex_co.y;
+    dt.dy = tex_co_dy.y - tex_co.y;
+  }
+  else
+#endif
+  {
+    ds = differential_zero();
+    dt = differential_zero();
+  }
+
   /* TODO(lukas): Consider moving tile information out of the SVM node.
    * TextureInfo seems a reasonable candidate. */
   int id = -1;
@@ -113,40 +147,6 @@ ccl_device void svm_node_tex_image(
     id = -num_nodes;
   }
 
-  differential ds, dt;
-#ifdef __KERNEL_CPU__
-  if (stack_valid(dx_offset) && stack_valid(dy_offset)) {
-    float3 dx = stack_load_float3(stack, dx_offset);
-    float3 dy = stack_load_float3(stack, dy_offset);
-    float2 tex_co_dx, tex_co_dy;
-    if (projection == NODE_IMAGE_PROJ_SPHERE) {
-      dx = texco_remap_square(dx);
-      tex_co_dx = map_to_sphere(dx);
-      dy = texco_remap_square(dy);
-      tex_co_dy = map_to_sphere(dy);
-    }
-    else if (projection == NODE_IMAGE_PROJ_TUBE) {
-      dx = texco_remap_square(dx);
-      tex_co_dx = map_to_tube(dx);
-      dy = texco_remap_square(dy);
-      tex_co_dy = map_to_tube(dy);
-    }
-    else {
-      tex_co_dx = make_float2(dx.x, dx.y);
-      tex_co_dy = make_float2(dy.x, dy.y);
-    }
-    ds.dx = tex_co_dx.x - tex_co.x;
-    ds.dy = tex_co_dy.x - tex_co.x;
-    dt.dx = tex_co_dx.y - tex_co.y;
-    dt.dy = tex_co_dy.y - tex_co.y;
-  }
-  else
-#endif
-  {
-    ds = differential_zero();
-    dt = differential_zero();
-  }
-
   float4 f = svm_image_texture(kg, id, tex_co.x, tex_co.y, ds, dt, flags, path_flag);
 
   if (stack_valid(out_offset))



More information about the Bf-blender-cvs mailing list