Cycles: Expose image image extension mapping to the image manager
[blender.git] / intern / cycles / render / nodes.cpp
index 46d5b3c3684c547edf629d83ab8b24129431f3ba..1150c63a65ace804bb21c09e65880732c527712b 100644 (file)
@@ -198,6 +198,7 @@ ImageTextureNode::ImageTextureNode()
        color_space = ustring("Color");
        projection = ustring("Flat");
        interpolation = INTERPOLATION_LINEAR;
+       extension = EXTENSION_REPEAT;
        projection_blend = 0.0f;
        animated = false;
 
@@ -208,8 +209,12 @@ ImageTextureNode::ImageTextureNode()
 
 ImageTextureNode::~ImageTextureNode()
 {
-       if(image_manager)
-               image_manager->remove_image(filename, builtin_data, interpolation);
+       if(image_manager) {
+               image_manager->remove_image(filename,
+                                           builtin_data,
+                                           interpolation,
+                                           extension);
+       }
 }
 
 ShaderNode *ImageTextureNode::clone() const
@@ -246,9 +251,15 @@ 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, 0, is_float_bool, is_linear,
-                                               interpolation, use_alpha);
+               slot = image_manager->add_image(filename,
+                                               builtin_data,
+                                               animated,
+                                               0,
+                                               is_float_bool,
+                                               is_linear,
+                                               interpolation,
+                                               extension,
+                                               use_alpha);
                is_float = (int)is_float_bool;
        }
 
@@ -318,9 +329,15 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
                }
                else {
                        bool is_float_bool;
-                       slot = image_manager->add_image(filename, builtin_data,
-                                                       animated, 0, is_float_bool, is_linear,
-                                                       interpolation, use_alpha);
+                       slot = image_manager->add_image(filename,
+                                                       builtin_data,
+                                                       animated,
+                                                       0,
+                                                       is_float_bool,
+                                                       is_linear,
+                                                       interpolation,
+                                                       extension,
+                                                       use_alpha);
                        is_float = (int)is_float_bool;
                }
        }
@@ -361,6 +378,14 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
                        compiler.parameter("interpolation", "linear");
                        break;
        }
+
+       if (extension == EXTENSION_REPEAT) {
+               compiler.parameter("wrap", "periodic");
+       }
+       else {
+               compiler.parameter("wrap", "clamp");
+       }
+
        compiler.add(this, "node_image_texture");
 }
 
@@ -400,8 +425,12 @@ EnvironmentTextureNode::EnvironmentTextureNode()
 
 EnvironmentTextureNode::~EnvironmentTextureNode()
 {
-       if(image_manager)
-               image_manager->remove_image(filename, builtin_data, INTERPOLATION_LINEAR);
+       if(image_manager) {
+               image_manager->remove_image(filename,
+                                           builtin_data,
+                                           INTERPOLATION_LINEAR,
+                                           EXTENSION_REPEAT);
+       }
 }
 
 ShaderNode *EnvironmentTextureNode::clone() const
@@ -436,9 +465,15 @@ 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, 0, is_float_bool, is_linear,
-                                               INTERPOLATION_LINEAR, use_alpha);
+               slot = image_manager->add_image(filename,
+                                               builtin_data,
+                                               animated,
+                                               0,
+                                               is_float_bool,
+                                               is_linear,
+                                               INTERPOLATION_LINEAR,
+                                               EXTENSION_REPEAT,
+                                               use_alpha);
                is_float = (int)is_float_bool;
        }
 
@@ -499,9 +534,15 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
                }
                else {
                        bool is_float_bool;
-                       slot = image_manager->add_image(filename, builtin_data,
-                                                       animated, 0, is_float_bool, is_linear,
-                                                       INTERPOLATION_LINEAR, use_alpha);
+                       slot = image_manager->add_image(filename,
+                                                       builtin_data,
+                                                       animated,
+                                                       0,
+                                                       is_float_bool,
+                                                       is_linear,
+                                                       INTERPOLATION_LINEAR,
+                                                       EXTENSION_REPEAT,
+                                                       use_alpha);
                        is_float = (int)is_float_bool;
                }
        }
@@ -1330,8 +1371,12 @@ PointDensityTextureNode::PointDensityTextureNode()
 
 PointDensityTextureNode::~PointDensityTextureNode()
 {
-       if(image_manager)
-               image_manager->remove_image(filename, builtin_data, interpolation);
+       if(image_manager) {
+               image_manager->remove_image(filename,
+                                           builtin_data,
+                                           interpolation,
+                                           EXTENSION_CLIP);
+       }
 }
 
 ShaderNode *PointDensityTextureNode::clone() const
@@ -1374,6 +1419,7 @@ void PointDensityTextureNode::compile(SVMCompiler& compiler)
                                                        false, 0,
                                                        is_float, is_linear,
                                                        interpolation,
+                                                       EXTENSION_CLIP,
                                                        true);
                }
 
@@ -1421,6 +1467,7 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler)
                                                        false, 0,
                                                        is_float, is_linear,
                                                        interpolation,
+                                                       EXTENSION_CLIP,
                                                        true);
                }