diff options
author | Martijn Berger <martijn.berger@gmail.com> | 2014-03-08 02:16:09 +0400 |
---|---|---|
committer | Martijn Berger <martijn.berger@gmail.com> | 2014-03-08 02:16:33 +0400 |
commit | dd2dca2f7e77e7521d13b78e875ffa58a90846f2 (patch) | |
tree | 26c0d371fbca7eb25e9060aabc5ef6fe56939cf2 /intern/cycles/render/nodes.cpp | |
parent | ef51b690090967f5576b88a528a79c5defb1ddd4 (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/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index af6fca29ab0..e2ee3a949fd 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -193,6 +193,7 @@ ImageTextureNode::ImageTextureNode() builtin_data = NULL; color_space = ustring("Color"); projection = ustring("Flat"); + interpolation = INTERPOLATION_LINEAR; projection_blend = 0.0f; animated = false; @@ -204,7 +205,7 @@ ImageTextureNode::ImageTextureNode() ImageTextureNode::~ImageTextureNode() { if(image_manager) - image_manager->remove_image(filename, builtin_data); + image_manager->remove_image(filename, builtin_data, interpolation); } ShaderNode *ImageTextureNode::clone() const @@ -241,7 +242,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; if(is_float == -1) { bool is_float_bool; - slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); + slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation); is_float = (int)is_float_bool; } @@ -315,6 +316,24 @@ void ImageTextureNode::compile(OSLCompiler& compiler) compiler.parameter("projection_blend", projection_blend); compiler.parameter("is_float", is_float); compiler.parameter("use_alpha", !alpha_out->links.empty()); + + switch (interpolation){ + case INTERPOLATION_LINEAR: + compiler.parameter("interpolation", "linear"); + break; + case INTERPOLATION_CLOSEST: + compiler.parameter("interpolation", "closest"); + break; + case INTERPOLATION_CUBIC: + compiler.parameter("interpolation", "cubic"); + break; + case INTERPOLATION_SMART: + compiler.parameter("interpolation", "smart"); + break; + default: + compiler.parameter("interpolation", "linear"); + break; + } compiler.add(this, "node_image_texture"); } @@ -354,7 +373,7 @@ EnvironmentTextureNode::EnvironmentTextureNode() EnvironmentTextureNode::~EnvironmentTextureNode() { if(image_manager) - image_manager->remove_image(filename, builtin_data); + image_manager->remove_image(filename, builtin_data, INTERPOLATION_LINEAR); } ShaderNode *EnvironmentTextureNode::clone() const @@ -389,7 +408,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; if(slot == -1) { bool is_float_bool; - slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); + slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR); is_float = (int)is_float_bool; } |