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:
authorMartijn Berger <martijn.berger@gmail.com>2014-03-13 23:08:10 +0400
committerMartijn Berger <martijn.berger@gmail.com>2014-03-13 23:08:33 +0400
commita8039d99f8a38ec9acb8bc048d38259bab574c53 (patch)
treeef19a0022f3b0ad865d4d520baa27f0ea03746aa /intern/cycles/kernel/kernel_compat_cpu.h
parent4080673ea7dd7ae62dccae65c4bb7f7a3c80255f (diff)
Fix cycles texture interpolation mode closest constant offset on some devices
Diffstat (limited to 'intern/cycles/kernel/kernel_compat_cpu.h')
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index 55f4484ba1f..850ef0abed1 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -99,28 +99,38 @@ template<typename T> struct texture_image {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
int ix, iy, nix, niy;
- float tx = frac(x*width - 0.5f, &ix);
- float ty = frac(y*height - 0.5f, &iy);
-
- if(periodic) {
- ix = wrap_periodic(ix, width);
- iy = wrap_periodic(iy, height);
-
- nix = wrap_periodic(ix+1, width);
- niy = wrap_periodic(iy+1, height);
- }
- else {
- ix = wrap_clamp(ix, width);
- iy = wrap_clamp(iy, height);
-
- nix = wrap_clamp(ix+1, width);
- niy = wrap_clamp(iy+1, height);
- }
-
if(interpolation == INTERPOLATION_CLOSEST) {
+ frac(x*width, &ix);
+ frac(y*height, &iy);
+ if(periodic) {
+ ix = wrap_periodic(ix, width);
+ iy = wrap_periodic(iy, height);
+
+ }
+ else {
+ ix = wrap_clamp(ix, width);
+ iy = wrap_clamp(iy, height);
+ }
return read(data[ix + iy*width]);
}
else {
+ float tx = frac(x*width - 0.5f, &ix);
+ float ty = frac(y*height - 0.5f, &iy);
+
+ if(periodic) {
+ ix = wrap_periodic(ix, width);
+ iy = wrap_periodic(iy, height);
+
+ nix = wrap_periodic(ix+1, width);
+ niy = wrap_periodic(iy+1, height);
+ }
+ else {
+ ix = wrap_clamp(ix, width);
+ iy = wrap_clamp(iy, height);
+
+ nix = wrap_clamp(ix+1, width);
+ niy = wrap_clamp(iy+1, height);
+ }
float4 r = (1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width]);
r += (1.0f - ty)*tx*read(data[nix + iy*width]);
r += ty*(1.0f - tx)*read(data[ix + niy*width]);