diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-21 17:00:51 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-21 17:00:51 +0400 |
commit | 90cdf34f560b0527b4211ebd5f941e4265bac8d0 (patch) | |
tree | c4eaddceb299f3d9e6825eeb82f40c7198995f30 /intern/cycles | |
parent | fde8b0f7bc4c837075b7f7d7e51028e53a7a80fe (diff) |
Fix #32796: cycles did not support image auto refresh option.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 35 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 6 | ||||
-rw-r--r-- | intern/cycles/render/image.cpp | 22 | ||||
-rw-r--r-- | intern/cycles/render/image.h | 6 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 2 |
6 files changed, 58 insertions, 19 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 63cf719d010..da06f1d0a38 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -500,8 +500,10 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen BL::Image b_image(b_image_node.image()); ImageTextureNode *image = new ImageTextureNode(); /* todo: handle generated/builtin images */ - if(b_image && b_image.source() != BL::Image::source_MOVIE) + if(b_image && b_image.source() != BL::Image::source_MOVIE) { image->filename = image_user_file_path(b_image_node.image_user(), b_image, b_scene.frame_current()); + image->animated = b_image_node.image_user().use_auto_refresh(); + } image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()]; image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()]; image->projection_blend = b_image_node.projection_blend(); @@ -513,8 +515,10 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen BL::ShaderNodeTexEnvironment b_env_node(b_node); BL::Image b_image(b_env_node.image()); EnvironmentTextureNode *env = new EnvironmentTextureNode(); - if(b_image && b_image.source() != BL::Image::source_MOVIE) + if(b_image && b_image.source() != BL::Image::source_MOVIE) { env->filename = image_user_file_path(b_env_node.image_user(), b_image, b_scene.frame_current()); + env->animated = b_env_node.image_user().use_auto_refresh(); + } env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()]; env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()]; get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping()); @@ -821,7 +825,7 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha /* Sync Materials */ -void BlenderSync::sync_materials() +void BlenderSync::sync_materials(bool update_all) { shader_map.set_default(scene->shaders[scene->default_surface]); @@ -832,7 +836,7 @@ void BlenderSync::sync_materials() Shader *shader; /* test if we need to sync */ - if(shader_map.sync(&shader, *b_mat)) { + if(shader_map.sync(&shader, *b_mat) || update_all) { ShaderGraph *graph = new ShaderGraph(); shader->name = b_mat->name().c_str(); @@ -868,14 +872,14 @@ void BlenderSync::sync_materials() /* Sync World */ -void BlenderSync::sync_world() +void BlenderSync::sync_world(bool update_all) { Background *background = scene->background; Background prevbackground = *background; BL::World b_world = b_scene.world(); - if(world_recalc || b_world.ptr.data != world_map) { + if(world_recalc || update_all || b_world.ptr.data != world_map) { Shader *shader = scene->shaders[scene->default_background]; ShaderGraph *graph = new ShaderGraph(); @@ -922,7 +926,7 @@ void BlenderSync::sync_world() /* Sync Lamps */ -void BlenderSync::sync_lamps() +void BlenderSync::sync_lamps(bool update_all) { shader_map.set_default(scene->shaders[scene->default_light]); @@ -933,7 +937,7 @@ void BlenderSync::sync_lamps() Shader *shader; /* test if we need to sync */ - if(shader_map.sync(&shader, *b_lamp)) { + if(shader_map.sync(&shader, *b_lamp) || update_all) { ShaderGraph *graph = new ShaderGraph(); /* create nodes */ @@ -972,11 +976,20 @@ void BlenderSync::sync_lamps() void BlenderSync::sync_shaders() { + /* for auto refresh images */ + bool auto_refresh_update = false; + + if(preview) { + ImageManager *image_manager = scene->image_manager; + int frame = b_scene.frame_current(); + auto_refresh_update = image_manager->set_animation_frame_update(frame); + } + shader_map.pre_sync(); - sync_world(); - sync_lamps(); - sync_materials(); + sync_world(auto_refresh_update); + sync_lamps(auto_refresh_update); + sync_materials(auto_refresh_update); /* false = don't delete unused shaders, not supported */ shader_map.post_sync(false); diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 71781bc5459..d3d21fbdf72 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -68,14 +68,14 @@ public: private: /* sync */ - void sync_lamps(); - void sync_materials(); + void sync_lamps(bool update_all); + void sync_materials(bool update_all); void sync_objects(BL::SpaceView3D b_v3d, int motion = 0); void sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override); void sync_film(); void sync_integrator(); void sync_view(); - void sync_world(); + void sync_world(bool update_all); void sync_render_layers(BL::SpaceView3D b_v3d, const char *layer); void sync_shaders(); diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 93c9e761f28..230a12f9ff2 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -36,6 +36,7 @@ ImageManager::ImageManager() need_update = true; pack_images = false; osl_texture_system = NULL; + animation_frame = 0; tex_num_images = TEX_NUM_IMAGES; tex_num_float_images = TEX_NUM_FLOAT_IMAGES; @@ -67,6 +68,23 @@ void ImageManager::set_extended_image_limits(void) tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START; } +bool ImageManager::set_animation_frame_update(int frame) +{ + if(frame != animation_frame) { + animation_frame = frame; + + for(size_t slot = 0; slot < images.size(); slot++) + if(images[slot] && images[slot]->animated) + return true; + + for(size_t slot = 0; slot < float_images.size(); slot++) + if(float_images[slot] && float_images[slot]->animated) + return true; + } + + return false; +} + bool ImageManager::is_float_image(const string& filename) { ImageInput *in = ImageInput::create(filename); @@ -95,7 +113,7 @@ bool ImageManager::is_float_image(const string& filename) return is_float; } -int ImageManager::add_image(const string& filename, bool& is_float) +int ImageManager::add_image(const string& filename, bool animated, bool& is_float) { Image *img; size_t slot; @@ -133,6 +151,7 @@ int ImageManager::add_image(const string& filename, bool& is_float) img = new Image(); img->filename = filename; img->need_load = true; + img->animated = animated; img->users = 1; float_images[slot] = img; @@ -166,6 +185,7 @@ int ImageManager::add_image(const string& filename, bool& is_float) img = new Image(); img->filename = filename; img->need_load = true; + img->animated = animated; img->users = 1; images[slot] = img; diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 584448647d6..4d177174971 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -51,7 +51,7 @@ public: ImageManager(); ~ImageManager(); - int add_image(const string& filename, bool& is_float); + int add_image(const string& filename, bool animated, bool& is_float); void remove_image(const string& filename); bool is_float_image(const string& filename); @@ -60,8 +60,8 @@ public: void set_osl_texture_system(void *texture_system); void set_pack_images(bool pack_images_); - void set_extended_image_limits(void); + bool set_animation_frame_update(int frame); bool need_update; @@ -70,11 +70,13 @@ private: int tex_num_float_images; int tex_image_byte_start; thread_mutex device_mutex; + int animation_frame; struct Image { string filename; bool need_load; + bool animated; int users; }; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index b297e6ea38c..48a8565ed98 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -145,6 +145,7 @@ ImageTextureNode::ImageTextureNode() color_space = ustring("Color"); projection = ustring("Flat");; projection_blend = 0.0f; + animated = false; add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV); add_output("Color", SHADER_SOCKET_COLOR); @@ -175,7 +176,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, is_float_bool); + slot = image_manager->add_image(filename, animated, is_float_bool); is_float = (int)is_float_bool; } @@ -272,6 +273,7 @@ EnvironmentTextureNode::EnvironmentTextureNode() filename = ""; color_space = ustring("Color"); projection = ustring("Equirectangular"); + animated = false; add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION); add_output("Color", SHADER_SOCKET_COLOR); @@ -302,7 +304,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; if(slot == -1) { bool is_float_bool; - slot = image_manager->add_image(filename, is_float_bool); + slot = image_manager->add_image(filename, animated, is_float_bool); is_float = (int)is_float_bool; } diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index d8f88cde259..3e89c2286ad 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -73,6 +73,7 @@ public: ustring color_space; ustring projection; float projection_blend; + bool animated; static ShaderEnum color_space_enum; static ShaderEnum projection_enum; @@ -90,6 +91,7 @@ public: string filename; ustring color_space; ustring projection; + bool animated; static ShaderEnum color_space_enum; static ShaderEnum projection_enum; |