Cycles: Fix missing features gathering from the bump graph
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 1 Jun 2015 10:52:00 +0000 (15:52 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 1 Jun 2015 14:49:52 +0000 (19:49 +0500)
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h

index 2f8eabbf0a9cb07c0838d5dea26362f717eb85eb..d73d73a0ca822dfd624126611b6bcad3fc5be799 100644 (file)
@@ -481,24 +481,39 @@ void ShaderManager::add_default(Scene *scene)
        }
 }
 
-void ShaderManager::get_requested_features(Scene *scene, int& max_group, int& features)
+/* NOTE: Expects max_group and features to be initialized in the callee. */
+void ShaderManager::get_requested_graph_features(ShaderGraph *graph,
+                                                 int& max_group,
+                                                 int& features)
+{
+       foreach(ShaderNode *node, graph->nodes) {
+               max_group = min(max_group, node->get_group());
+               features |= node->get_feature();
+               if(node->special_type == SHADER_SPECIAL_TYPE_CLOSURE) {
+                       BsdfNode *bsdf_node = static_cast<BsdfNode*>(node);
+                       if(CLOSURE_IS_VOLUME(bsdf_node->closure)) {
+                               features |= NODE_FEATURE_VOLUME;
+                       }
+               }
+       }
+}
+
+void ShaderManager::get_requested_features(Scene *scene,
+                                           int& max_group,
+                                           int& features)
 {
        max_group = NODE_GROUP_LEVEL_0;
        features = 0;
        for(int i = 0; i < scene->shaders.size(); i++) {
                Shader *shader = scene->shaders[i];
                /* Gather requested features from all the nodes from the graph nodes. */
-               foreach(ShaderNode *node, shader->graph->nodes) {
-                       max_group = min(max_group, node->get_group());
-                       features |= node->get_feature();
-                       if(node->special_type == SHADER_SPECIAL_TYPE_CLOSURE) {
-                               BsdfNode *bsdf_node = static_cast<BsdfNode*>(node);
-                               if(CLOSURE_IS_VOLUME(bsdf_node->closure)) {
-                                       features |= NODE_FEATURE_VOLUME;
-                               }
-                       }
-               }
+               get_requested_graph_features(shader->graph, max_group, features);
                /* Gather requested features from the graph itself. */
+               if(shader->graph_bump) {
+                       get_requested_graph_features(shader->graph_bump,
+                                                    max_group,
+                                                    features);
+               }
                ShaderNode *output_node = shader->graph->output();
                if(output_node->input("Displacement")->link != NULL) {
                        features |= NODE_FEATURE_BUMP;
index 27b239601d0d8ec1036a9d667a0b742afed34341..64d45635ef124b7af6b1283dbfa281dfdf3397c1 100644 (file)
@@ -166,7 +166,9 @@ public:
        static void add_default(Scene *scene);
 
        /* Selective nodes compilation. */
-       void get_requested_features(Scene *scene, int& max_group, int& features);
+       void get_requested_features(Scene *scene,
+                                   int& max_group,
+                                   int& features);
 
 protected:
        ShaderManager();
@@ -178,6 +180,10 @@ protected:
        static vector<float> beckmann_table;
 
        size_t beckmann_table_offset;
+
+       void get_requested_graph_features(ShaderGraph *graph,
+                                         int& max_group,
+                                         int& features);
 };
 
 CCL_NAMESPACE_END