diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 18 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 22 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 1 |
4 files changed, 13 insertions, 33 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 215953d1f29..206058259af 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -656,7 +656,7 @@ static ShaderNode *add_node(Scene *scene, } else { image->filename = image_user_file_path( - b_image_user, b_image, b_scene.frame_current(), &image->is_tiled); + b_image_user, b_image, b_scene.frame_current(), true); image->builtin_data = NULL; } @@ -710,7 +710,8 @@ static ShaderNode *add_node(Scene *scene, env->builtin_data = b_image.ptr.data; } else { - env->filename = image_user_file_path(b_image_user, b_image, b_scene.frame_current(), NULL); + env->filename = image_user_file_path( + b_image_user, b_image, b_scene.frame_current(), false); env->builtin_data = NULL; } diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 2c3e279a8d8..bea30a20b8c 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -234,24 +234,18 @@ static inline int render_resolution_y(BL::RenderSettings &b_render) static inline string image_user_file_path(BL::ImageUser &iuser, BL::Image &ima, int cfra, - bool *is_tiled) + bool load_tiled) { - if (is_tiled != NULL) { - *is_tiled = false; - } - char filepath[1024]; iuser.tile(0); BKE_image_user_frame_calc(NULL, iuser.ptr.data, cfra); BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath); - if (ima.source() == BL::Image::source_TILED && is_tiled != NULL) { - char *udim_id = strstr(filepath, "1001"); - if (udim_id != NULL) { - memcpy(udim_id, "%04d", 4); - *is_tiled = true; - } + + string filepath_str = string(filepath); + if (load_tiled && ima.source() == BL::Image::source_TILED) { + string_replace(filepath_str, "1001", "<UDIM>"); } - return string(filepath); + return filepath_str; } static inline int image_user_frame_number(BL::ImageUser &iuser, int cfra) diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index d176f58e636..e4339b40744 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -235,8 +235,6 @@ NODE_DEFINE(ImageTextureNode) SOCKET_STRING(filename, "Filename", ustring()); SOCKET_STRING(colorspace, "Colorspace", u_colorspace_auto); - SOCKET_BOOLEAN(is_tiled, "Is Tiled", false); - static NodeEnum alpha_type_enum; alpha_type_enum.insert("auto", IMAGE_ALPHA_AUTO); alpha_type_enum.insert("unassociated", IMAGE_ALPHA_UNASSOCIATED); @@ -381,9 +379,7 @@ void ImageTextureNode::compile(SVMCompiler &compiler) bool have_metadata = false; foreach (int tile, tiles) { string tile_name = filename.string(); - if (is_tiled) { - tile_name = string_printf(tile_name.c_str(), tile); - } + string_replace(tile_name, "<UDIM>", string_printf("%04d", tile)); ImageMetaData metadata; int slot = image_manager->add_image(tile_name, @@ -505,9 +501,7 @@ void ImageTextureNode::compile(OSLCompiler &compiler) ImageMetaData metadata; if (builtin_data == NULL) { string tile_name = filename.string(); - if (is_tiled) { - tile_name = string_printf(tile_name.c_str(), 1001); - } + string_replace(tile_name, "<UDIM>", "1001"); image_manager->get_image_metadata(tile_name, NULL, colorspace, metadata); slots.push_back(-1); } @@ -529,17 +523,8 @@ void ImageTextureNode::compile(OSLCompiler &compiler) } if (slots[0] == -1) { - ustring texture_name = filename; - if (is_tiled) { - size_t udim_pos = filename.rfind("%04d"); - if (udim_pos != string::npos) { - string texture_name_str = filename.string(); - texture_name_str.replace(udim_pos, 4, "<UDIM>"); - texture_name = ustring(texture_name_str); - } - } compiler.parameter_texture( - "filename", texture_name, compress_as_srgb ? u_colorspace_raw : known_colorspace); + "filename", filename, compress_as_srgb ? u_colorspace_raw : known_colorspace); } else { compiler.parameter_texture("filename", slots[0]); @@ -548,6 +533,7 @@ void ImageTextureNode::compile(OSLCompiler &compiler) const bool unassociate_alpha = !(ColorSpaceManager::colorspace_is_data(colorspace) || alpha_type == IMAGE_ALPHA_CHANNEL_PACKED || alpha_type == IMAGE_ALPHA_IGNORE); + const bool is_tiled = (filename.find("<UDIM>") != string::npos); compiler.parameter(this, "projection"); compiler.parameter(this, "projection_blend"); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 5b23ef6929e..a8fe7644957 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -114,7 +114,6 @@ class ImageTextureNode : public ImageSlotTextureNode { bool animated; float3 vector; ccl::vector<int> tiles; - bool is_tiled; /* Runtime. */ bool is_float; |