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-08 02:16:09 +0400
committerMartijn Berger <martijn.berger@gmail.com>2014-03-08 02:16:33 +0400
commitdd2dca2f7e77e7521d13b78e875ffa58a90846f2 (patch)
tree26c0d371fbca7eb25e9060aabc5ef6fe56939cf2 /intern/cycles/kernel/svm
parentef51b690090967f5576b88a528a79c5defb1ddd4 (diff)
Add support for multiple interpolation modes on cycles image textures
All textures are sampled bi-linear currently with the exception of OSL there texture sampling is fixed and set to smart bi-cubic. This patch adds user control to this setting. Added: - bits to DNA / RNA in the form of an enum for supporting multiple interpolations types - changes to the image texture node drawing code ( add enum) - to ImageManager (this needs to know to allocate second texture when interpolation type is different) - to node compiler (pass on interpolation type) - to device tex_alloc this also needs to get the concept of multiple interpolation types - implementation for doing non interpolated lookup for cuda and cpu - implementation where we pass this along to osl ( this makes OSL also do linear untill I add smartcubic to the interface / DNA/ RNA) Reviewers: brecht, dingto Reviewed By: brecht CC: dingto, venomgfx Differential Revision: https://developer.blender.org/D317
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm_image.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index bc76ea1e662..750af97150e 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -60,7 +60,8 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
uint width = info.x;
uint height = info.y;
uint offset = info.z;
- uint periodic = info.w;
+ uint periodic = (info.w & 0x1);
+ uint interpolation = info.w >> 1;
int ix, iy, nix, niy;
float tx = svm_image_texture_frac(x*width, &ix);
@@ -81,10 +82,16 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
niy = svm_image_texture_wrap_clamp(iy+1, height);
}
- float4 r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + iy*width);
- r += (1.0f - ty)*tx*svm_image_texture_read(kg, offset + nix + iy*width);
- r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width);
- r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width);
+ float4 r;
+ if (interpolation == INTERPOLATION_CLOSEST){
+ r = svm_image_texture_read(kg, offset + ix + iy*width);
+ }
+ else { /* We default to linear interpolation if it is not closest */
+ r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + iy*width);
+ r += (1.0f - ty)*tx*svm_image_texture_read(kg, offset + nix + iy*width);
+ r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width);
+ r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width);
+ }
if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
float invw = 1.0f/r.w;