diff options
Diffstat (limited to 'intern/cycles/blender/blender_shader.cpp')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 8baa53fc2ec..f35565d8330 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -28,6 +28,7 @@ #include "util_debug.h" #include "util_string.h" +#include "util_task.h" CCL_NAMESPACE_BEGIN @@ -1164,6 +1165,8 @@ void BlenderSync::sync_materials(bool update_all) /* material loop */ BL::BlendData::materials_iterator b_mat; + TaskPool pool; + for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) { Shader *shader; @@ -1199,9 +1202,22 @@ void BlenderSync::sync_materials(bool update_all) shader->displacement_method = (experimental) ? get_displacement_method(cmat) : DISPLACE_BUMP; shader->set_graph(graph); + + /* By simplifying the shader graph as soon as possible, some redundant shader nodes + * might be removed which prevents loading unneccessary attributes later. + * + * However, since graph simplification also accounts for e.g. mix weight, this would + * cause frequent expensive resyncs in interactive sessions, so for those sessions + * optimization is only performed right before compiling. */ + if(!preview) { + pool.push(function_bind(&ShaderGraph::simplify, shader->graph, scene)); + } + shader->tag_update(scene); } } + + pool.wait_work(); } /* Sync World */ |