Fix #32796: cycles did not support image auto refresh option.
This commit is contained in:
@@ -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());
|
BL::Image b_image(b_image_node.image());
|
||||||
ImageTextureNode *image = new ImageTextureNode();
|
ImageTextureNode *image = new ImageTextureNode();
|
||||||
/* todo: handle generated/builtin images */
|
/* 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->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->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
|
||||||
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
|
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
|
||||||
image->projection_blend = b_image_node.projection_blend();
|
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::ShaderNodeTexEnvironment b_env_node(b_node);
|
||||||
BL::Image b_image(b_env_node.image());
|
BL::Image b_image(b_env_node.image());
|
||||||
EnvironmentTextureNode *env = new EnvironmentTextureNode();
|
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->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->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
|
||||||
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
|
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
|
||||||
get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
|
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 */
|
/* Sync Materials */
|
||||||
|
|
||||||
void BlenderSync::sync_materials()
|
void BlenderSync::sync_materials(bool update_all)
|
||||||
{
|
{
|
||||||
shader_map.set_default(scene->shaders[scene->default_surface]);
|
shader_map.set_default(scene->shaders[scene->default_surface]);
|
||||||
|
|
||||||
@@ -832,7 +836,7 @@ void BlenderSync::sync_materials()
|
|||||||
Shader *shader;
|
Shader *shader;
|
||||||
|
|
||||||
/* test if we need to sync */
|
/* 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();
|
ShaderGraph *graph = new ShaderGraph();
|
||||||
|
|
||||||
shader->name = b_mat->name().c_str();
|
shader->name = b_mat->name().c_str();
|
||||||
@@ -868,14 +872,14 @@ void BlenderSync::sync_materials()
|
|||||||
|
|
||||||
/* Sync World */
|
/* Sync World */
|
||||||
|
|
||||||
void BlenderSync::sync_world()
|
void BlenderSync::sync_world(bool update_all)
|
||||||
{
|
{
|
||||||
Background *background = scene->background;
|
Background *background = scene->background;
|
||||||
Background prevbackground = *background;
|
Background prevbackground = *background;
|
||||||
|
|
||||||
BL::World b_world = b_scene.world();
|
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];
|
Shader *shader = scene->shaders[scene->default_background];
|
||||||
ShaderGraph *graph = new ShaderGraph();
|
ShaderGraph *graph = new ShaderGraph();
|
||||||
|
|
||||||
@@ -922,7 +926,7 @@ void BlenderSync::sync_world()
|
|||||||
|
|
||||||
/* Sync Lamps */
|
/* Sync Lamps */
|
||||||
|
|
||||||
void BlenderSync::sync_lamps()
|
void BlenderSync::sync_lamps(bool update_all)
|
||||||
{
|
{
|
||||||
shader_map.set_default(scene->shaders[scene->default_light]);
|
shader_map.set_default(scene->shaders[scene->default_light]);
|
||||||
|
|
||||||
@@ -933,7 +937,7 @@ void BlenderSync::sync_lamps()
|
|||||||
Shader *shader;
|
Shader *shader;
|
||||||
|
|
||||||
/* test if we need to sync */
|
/* 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();
|
ShaderGraph *graph = new ShaderGraph();
|
||||||
|
|
||||||
/* create nodes */
|
/* create nodes */
|
||||||
@@ -972,11 +976,20 @@ void BlenderSync::sync_lamps()
|
|||||||
|
|
||||||
void BlenderSync::sync_shaders()
|
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();
|
shader_map.pre_sync();
|
||||||
|
|
||||||
sync_world();
|
sync_world(auto_refresh_update);
|
||||||
sync_lamps();
|
sync_lamps(auto_refresh_update);
|
||||||
sync_materials();
|
sync_materials(auto_refresh_update);
|
||||||
|
|
||||||
/* false = don't delete unused shaders, not supported */
|
/* false = don't delete unused shaders, not supported */
|
||||||
shader_map.post_sync(false);
|
shader_map.post_sync(false);
|
||||||
|
@@ -68,14 +68,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* sync */
|
/* sync */
|
||||||
void sync_lamps();
|
void sync_lamps(bool update_all);
|
||||||
void sync_materials();
|
void sync_materials(bool update_all);
|
||||||
void sync_objects(BL::SpaceView3D b_v3d, int motion = 0);
|
void sync_objects(BL::SpaceView3D b_v3d, int motion = 0);
|
||||||
void sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override);
|
void sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override);
|
||||||
void sync_film();
|
void sync_film();
|
||||||
void sync_integrator();
|
void sync_integrator();
|
||||||
void sync_view();
|
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_render_layers(BL::SpaceView3D b_v3d, const char *layer);
|
||||||
void sync_shaders();
|
void sync_shaders();
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ ImageManager::ImageManager()
|
|||||||
need_update = true;
|
need_update = true;
|
||||||
pack_images = false;
|
pack_images = false;
|
||||||
osl_texture_system = NULL;
|
osl_texture_system = NULL;
|
||||||
|
animation_frame = 0;
|
||||||
|
|
||||||
tex_num_images = TEX_NUM_IMAGES;
|
tex_num_images = TEX_NUM_IMAGES;
|
||||||
tex_num_float_images = TEX_NUM_FLOAT_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;
|
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)
|
bool ImageManager::is_float_image(const string& filename)
|
||||||
{
|
{
|
||||||
ImageInput *in = ImageInput::create(filename);
|
ImageInput *in = ImageInput::create(filename);
|
||||||
@@ -95,7 +113,7 @@ bool ImageManager::is_float_image(const string& filename)
|
|||||||
return is_float;
|
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;
|
Image *img;
|
||||||
size_t slot;
|
size_t slot;
|
||||||
@@ -133,6 +151,7 @@ int ImageManager::add_image(const string& filename, bool& is_float)
|
|||||||
img = new Image();
|
img = new Image();
|
||||||
img->filename = filename;
|
img->filename = filename;
|
||||||
img->need_load = true;
|
img->need_load = true;
|
||||||
|
img->animated = animated;
|
||||||
img->users = 1;
|
img->users = 1;
|
||||||
|
|
||||||
float_images[slot] = img;
|
float_images[slot] = img;
|
||||||
@@ -166,6 +185,7 @@ int ImageManager::add_image(const string& filename, bool& is_float)
|
|||||||
img = new Image();
|
img = new Image();
|
||||||
img->filename = filename;
|
img->filename = filename;
|
||||||
img->need_load = true;
|
img->need_load = true;
|
||||||
|
img->animated = animated;
|
||||||
img->users = 1;
|
img->users = 1;
|
||||||
|
|
||||||
images[slot] = img;
|
images[slot] = img;
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
ImageManager();
|
ImageManager();
|
||||||
~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);
|
void remove_image(const string& filename);
|
||||||
bool is_float_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_osl_texture_system(void *texture_system);
|
||||||
void set_pack_images(bool pack_images_);
|
void set_pack_images(bool pack_images_);
|
||||||
|
|
||||||
void set_extended_image_limits(void);
|
void set_extended_image_limits(void);
|
||||||
|
bool set_animation_frame_update(int frame);
|
||||||
|
|
||||||
bool need_update;
|
bool need_update;
|
||||||
|
|
||||||
@@ -70,11 +70,13 @@ private:
|
|||||||
int tex_num_float_images;
|
int tex_num_float_images;
|
||||||
int tex_image_byte_start;
|
int tex_image_byte_start;
|
||||||
thread_mutex device_mutex;
|
thread_mutex device_mutex;
|
||||||
|
int animation_frame;
|
||||||
|
|
||||||
struct Image {
|
struct Image {
|
||||||
string filename;
|
string filename;
|
||||||
|
|
||||||
bool need_load;
|
bool need_load;
|
||||||
|
bool animated;
|
||||||
int users;
|
int users;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -145,6 +145,7 @@ ImageTextureNode::ImageTextureNode()
|
|||||||
color_space = ustring("Color");
|
color_space = ustring("Color");
|
||||||
projection = ustring("Flat");;
|
projection = ustring("Flat");;
|
||||||
projection_blend = 0.0f;
|
projection_blend = 0.0f;
|
||||||
|
animated = false;
|
||||||
|
|
||||||
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV);
|
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV);
|
||||||
add_output("Color", SHADER_SOCKET_COLOR);
|
add_output("Color", SHADER_SOCKET_COLOR);
|
||||||
@@ -175,7 +176,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
|
|||||||
image_manager = compiler.image_manager;
|
image_manager = compiler.image_manager;
|
||||||
if(is_float == -1) {
|
if(is_float == -1) {
|
||||||
bool is_float_bool;
|
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;
|
is_float = (int)is_float_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +273,7 @@ EnvironmentTextureNode::EnvironmentTextureNode()
|
|||||||
filename = "";
|
filename = "";
|
||||||
color_space = ustring("Color");
|
color_space = ustring("Color");
|
||||||
projection = ustring("Equirectangular");
|
projection = ustring("Equirectangular");
|
||||||
|
animated = false;
|
||||||
|
|
||||||
add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION);
|
add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION);
|
||||||
add_output("Color", SHADER_SOCKET_COLOR);
|
add_output("Color", SHADER_SOCKET_COLOR);
|
||||||
@@ -302,7 +304,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
|
|||||||
image_manager = compiler.image_manager;
|
image_manager = compiler.image_manager;
|
||||||
if(slot == -1) {
|
if(slot == -1) {
|
||||||
bool is_float_bool;
|
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;
|
is_float = (int)is_float_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -73,6 +73,7 @@ public:
|
|||||||
ustring color_space;
|
ustring color_space;
|
||||||
ustring projection;
|
ustring projection;
|
||||||
float projection_blend;
|
float projection_blend;
|
||||||
|
bool animated;
|
||||||
|
|
||||||
static ShaderEnum color_space_enum;
|
static ShaderEnum color_space_enum;
|
||||||
static ShaderEnum projection_enum;
|
static ShaderEnum projection_enum;
|
||||||
@@ -90,6 +91,7 @@ public:
|
|||||||
string filename;
|
string filename;
|
||||||
ustring color_space;
|
ustring color_space;
|
||||||
ustring projection;
|
ustring projection;
|
||||||
|
bool animated;
|
||||||
|
|
||||||
static ShaderEnum color_space_enum;
|
static ShaderEnum color_space_enum;
|
||||||
static ShaderEnum projection_enum;
|
static ShaderEnum projection_enum;
|
||||||
|
Reference in New Issue
Block a user