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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-08-24 11:37:59 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-08-24 11:40:37 +0300
commitaac6ee6b870eb968d37c16039e6cdc579df17288 (patch)
tree140f0d6c6cb0532fef501adfd12915b8dce9556c
parent8cc8ce3d466126b68b2a73f0491c332526b01fe0 (diff)
Fix T45885: Cycles coordinate extension modes not working as expected
Fix T45769: Image Texture Node clipping bug Simple mistakes in the normalized/pixel-space coordinates handling. Render tests for this feature are coming.
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h72
1 files changed, 46 insertions, 26 deletions
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index d02670f630a..951de884494 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -144,7 +144,7 @@ template<typename T> struct texture_image {
iy = wrap_periodic(iy, height);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -168,7 +168,7 @@ template<typename T> struct texture_image {
niy = wrap_periodic(iy+1, height);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -176,8 +176,13 @@ template<typename T> struct texture_image {
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
- nix = wrap_clamp(ix+1, width);
- niy = wrap_clamp(iy+1, height);
+ if (x >= 0.0f && y >= 0.0f && x <= 1.0f && y <= 1.0f) {
+ nix = wrap_clamp(ix+1, width);
+ niy = wrap_clamp(iy+1, height);
+ }
+ else {
+ return read(data[ix + iy*width]);
+ }
break;
}
@@ -208,7 +213,7 @@ template<typename T> struct texture_image {
nniy = wrap_periodic(iy+2, height);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -216,14 +221,19 @@ template<typename T> struct texture_image {
ix = wrap_clamp(ix, width);
iy = wrap_clamp(iy, height);
- pix = wrap_clamp(ix-1, width);
- piy = wrap_clamp(iy-1, height);
+ if (x >= 0.0f && y >= 0.0f && x <= 1.0f && y <= 1.0f) {
+ pix = wrap_clamp(ix-1, width);
+ piy = wrap_clamp(iy-1, height);
- nix = wrap_clamp(ix+1, width);
- niy = wrap_clamp(iy+1, height);
+ nix = wrap_clamp(ix+1, width);
+ niy = wrap_clamp(iy+1, height);
- nnix = wrap_clamp(ix+2, width);
- nniy = wrap_clamp(iy+2, height);
+ nnix = wrap_clamp(ix+2, width);
+ nniy = wrap_clamp(iy+2, height);
+ }
+ else {
+ return read(data[ix + iy*width]);
+ }
break;
}
@@ -279,7 +289,7 @@ template<typename T> struct texture_image {
iz = wrap_periodic(iz, depth);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -308,7 +318,7 @@ template<typename T> struct texture_image {
niz = wrap_periodic(iz+1, depth);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -317,9 +327,14 @@ template<typename T> struct texture_image {
iy = wrap_clamp(iy, height);
iz = wrap_clamp(iz, depth);
- nix = wrap_clamp(ix+1, width);
- niy = wrap_clamp(iy+1, height);
- niz = wrap_clamp(iz+1, depth);
+ if (x >= 0.0f && y >= 0.0f && x <= 1.0f && y <= 1.0f) {
+ nix = wrap_clamp(ix+1, width);
+ niy = wrap_clamp(iy+1, height);
+ niz = wrap_clamp(iz+1, depth);
+ }
+ else {
+ return read(data[ix + iy*width + iz*width*height]);
+ }
break;
}
@@ -363,7 +378,7 @@ template<typename T> struct texture_image {
nniz = wrap_periodic(iz+2, depth);
break;
case EXTENSION_CLIP:
- if (x < 0.0f || y < 0.0f || x >= width || y >= height) {
+ if (x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
}
/* Fall through. */
@@ -372,17 +387,22 @@ template<typename T> struct texture_image {
iy = wrap_clamp(iy, height);
iz = wrap_clamp(iz, depth);
- pix = wrap_clamp(ix-1, width);
- piy = wrap_clamp(iy-1, height);
- piz = wrap_clamp(iz-1, depth);
+ if (x >= 0.0f && y >= 0.0f && x <= 1.0f && y <= 1.0f) {
+ pix = wrap_clamp(ix-1, width);
+ piy = wrap_clamp(iy-1, height);
+ piz = wrap_clamp(iz-1, depth);
- nix = wrap_clamp(ix+1, width);
- niy = wrap_clamp(iy+1, height);
- niz = wrap_clamp(iz+1, depth);
+ nix = wrap_clamp(ix+1, width);
+ niy = wrap_clamp(iy+1, height);
+ niz = wrap_clamp(iz+1, depth);
- nnix = wrap_clamp(ix+2, width);
- nniy = wrap_clamp(iy+2, height);
- nniz = wrap_clamp(iz+2, depth);
+ nnix = wrap_clamp(ix+2, width);
+ nniy = wrap_clamp(iy+2, height);
+ nniz = wrap_clamp(iz+2, depth);
+ }
+ else {
+ return read(data[ix + iy*width + iz*width*height]);
+ }
break;
}