Cycles: Expose image image extension mapping to the image manager

Currently only two mappings are supported by API, which is Repeat (old behavior)
and new Clip behavior. Internally this extension is being converted to periodic
flag which was already supported but wasn't exposed.

There's no support for OpenCL yet because of the way how we pack images into a
single texture.

Those settings are not exposed to UI or anywhere else and there should be no
functional changes so far.
This commit is contained in:
Sergey Sharybin
2015-07-21 21:58:19 +02:00
parent dc3563ff48
commit f2c54df625
12 changed files with 276 additions and 64 deletions

View 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);
}