Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-02-21 19:55:24 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-04-06 17:22:17 +0300
commitb5f58c1ad9b19f3fe7ee06a4ab5ec5498dfc0652 (patch)
tree54db8c7e24bdfa585e849ede412be4ac86c5702b /intern/cycles/blender/blender_shader.cpp
parent36f352a4e45202a6a45aa608ee083f30a4db2c81 (diff)
Cycles: Experiment with making previews more interactive
There were two major problems with the interactivity of material previews: - Beckmann tables were re-generated on every material tweak. This is because preview scene is not set to be persistent, so re-triggering the render leads to the full scene re-sync. - Images could take rather noticeable time to load with OIIO from the disk on every tweak. This patch addressed this two issues in the following way: - Beckmann tables are now static on CPU memory. They're couple of hundred kilobytes only, so wouldn't expect this to be an issue. And they're needed for almost every render anyway. This actually also makes blackbody table to be static, but it's even smaller than beckmann table. Not totally happy with this approach, but others seems to complicate things quite a bit with all this render engine life time and so.. - For preview rendering all images are considered to be built-in. This means instead of OIIO which re-loads images on every re-render they're coming from ImBuf cache which is fully manageable from blender side and unused images gets freed later. This would make it impossible to have mipmapping with OSL for now, but we'll be working on that later anyway and don't think mipmaps are really so crucial for the material preview. This seems to be a better alternative to making preview scene persistent, because of much optimal memory control from blender side. Reviewers: brecht, juicyfruit, campbellbarton, dingto Subscribers: eyecandy, venomgfx Differential Revision: https://developer.blender.org/D1132
Diffstat (limited to 'intern/cycles/blender/blender_shader.cpp')
-rw-r--r--intern/cycles/blender/blender_shader.cpp66
1 files changed, 53 insertions, 13 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index dda06616ac6..d3b01fbf1d4 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -179,7 +179,13 @@ static bool is_output_node(BL::Node b_node)
|| b_node.is_a(&RNA_ShaderNodeOutputLamp));
}
-static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, ShaderGraph *graph, BL::ShaderNodeTree b_ntree, BL::ShaderNode b_node)
+static ShaderNode *add_node(Scene *scene,
+ BL::RenderEngine b_engine,
+ BL::BlendData b_data,
+ BL::Scene b_scene,
+ ShaderGraph *graph,
+ BL::ShaderNodeTree b_ntree,
+ BL::ShaderNode b_node)
{
ShaderNode *node = NULL;
@@ -558,7 +564,8 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
*/
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
- b_image.source() == BL::Image::source_MOVIE;
+ b_image.source() == BL::Image::source_MOVIE ||
+ b_engine.is_preview();
if(is_builtin) {
/* for builtin images we're using image datablock name to find an image to
@@ -601,7 +608,8 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
if(b_image) {
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
- b_image.source() == BL::Image::source_MOVIE;
+ b_image.source() == BL::Image::source_MOVIE ||
+ b_engine.is_preview();
if(is_builtin) {
int scene_frame = b_scene.frame_current();
@@ -805,8 +813,14 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node,
return node->output(name.c_str());
}
-static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, ShaderGraph *graph, BL::ShaderNodeTree b_ntree,
- const ProxyMap &proxy_input_map, const ProxyMap &proxy_output_map)
+static void add_nodes(Scene *scene,
+ BL::RenderEngine b_engine,
+ BL::BlendData b_data,
+ BL::Scene b_scene,
+ ShaderGraph *graph,
+ BL::ShaderNodeTree b_ntree,
+ const ProxyMap &proxy_input_map,
+ const ProxyMap &proxy_output_map)
{
/* add nodes */
BL::ShaderNodeTree::nodes_iterator b_node;
@@ -883,8 +897,16 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
output_map[b_output->ptr.data] = proxy->outputs[0];
}
- if(b_group_ntree)
- add_nodes(scene, b_data, b_scene, graph, b_group_ntree, group_proxy_input_map, group_proxy_output_map);
+ if (b_group_ntree) {
+ add_nodes(scene,
+ b_engine,
+ b_data,
+ b_scene,
+ graph,
+ b_group_ntree,
+ group_proxy_input_map,
+ group_proxy_output_map);
+ }
}
else if(b_node->is_a(&RNA_NodeGroupInput)) {
/* map each socket to a proxy node */
@@ -923,7 +945,13 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
}
}
else {
- node = add_node(scene, b_data, b_scene, graph, b_ntree, BL::ShaderNode(*b_node));
+ node = add_node(scene,
+ b_engine,
+ b_data,
+ b_scene,
+ graph,
+ b_ntree,
+ BL::ShaderNode(*b_node));
}
if(node) {
@@ -979,10 +1007,22 @@ static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, Sha
}
}
-static void add_nodes(Scene *scene, BL::BlendData b_data, BL::Scene b_scene, ShaderGraph *graph, BL::ShaderNodeTree b_ntree)
+static void add_nodes(Scene *scene,
+ BL::RenderEngine b_engine,
+ BL::BlendData b_data,
+ BL::Scene b_scene,
+ ShaderGraph *graph,
+ BL::ShaderNodeTree b_ntree)
{
static const ProxyMap empty_proxy_map;
- add_nodes(scene, b_data, b_scene, graph, b_ntree, empty_proxy_map, empty_proxy_map);
+ add_nodes(scene,
+ b_engine,
+ b_data,
+ b_scene,
+ graph,
+ b_ntree,
+ empty_proxy_map,
+ empty_proxy_map);
}
/* Sync Materials */
@@ -1008,7 +1048,7 @@ void BlenderSync::sync_materials(bool update_all)
if(b_mat->use_nodes() && b_mat->node_tree()) {
BL::ShaderNodeTree b_ntree(b_mat->node_tree());
- add_nodes(scene, b_data, b_scene, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, graph, b_ntree);
}
else {
ShaderNode *closure, *out;
@@ -1051,7 +1091,7 @@ void BlenderSync::sync_world(bool update_all)
if(b_world && b_world.use_nodes() && b_world.node_tree()) {
BL::ShaderNodeTree b_ntree(b_world.node_tree());
- add_nodes(scene, b_data, b_scene, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, graph, b_ntree);
/* volume */
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
@@ -1137,7 +1177,7 @@ void BlenderSync::sync_lamps(bool update_all)
BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
- add_nodes(scene, b_data, b_scene, graph, b_ntree);
+ add_nodes(scene, b_engine, b_data, b_scene, graph, b_ntree);
}
else {
ShaderNode *closure, *out;