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:
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/graph.cpp22
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/nodes.cpp12
-rw-r--r--intern/cycles/render/nodes.h26
-rw-r--r--intern/cycles/render/osl.cpp28
-rw-r--r--intern/cycles/render/shader.cpp16
-rw-r--r--intern/cycles/render/shader.h6
-rw-r--r--intern/cycles/render/svm.cpp38
-rw-r--r--intern/cycles/render/svm.h3
9 files changed, 51 insertions, 103 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 2d810ff664f..41e7e0205b0 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -221,28 +221,6 @@ OutputNode *ShaderGraph::output()
return (OutputNode*)nodes.front();
}
-ShaderGraph *ShaderGraph::copy()
-{
- ShaderGraph *newgraph = new ShaderGraph();
-
- /* copy nodes */
- ShaderNodeSet nodes_all;
- foreach(ShaderNode *node, nodes)
- nodes_all.insert(node);
-
- ShaderNodeMap nodes_copy;
- copy_nodes(nodes_all, nodes_copy);
-
- /* add nodes (in same order, so output is still first) */
- newgraph->clear_nodes();
- foreach(ShaderNode *node, nodes)
- newgraph->add(nodes_copy[node]);
-
- newgraph->simplified = simplified;
-
- return newgraph;
-}
-
void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
{
assert(!finalized);
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 72e391991a7..f0fd789c6bd 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -151,6 +151,7 @@ public:
virtual bool has_surface_emission() { return false; }
virtual bool has_surface_transparent() { return false; }
virtual bool has_surface_bssrdf() { return false; }
+ virtual bool has_bump() { return false; }
virtual bool has_bssrdf_bump() { return false; }
virtual bool has_spatial_varying() { return false; }
virtual bool has_object_dependency() { return false; }
@@ -245,8 +246,6 @@ public:
ShaderGraph();
~ShaderGraph();
- ShaderGraph *copy();
-
ShaderNode *add(ShaderNode *node);
OutputNode *output();
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 90a68a06cb5..2b682756c6a 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1801,6 +1801,14 @@ BsdfBaseNode::BsdfBaseNode(const NodeType *node_type)
special_type = SHADER_SPECIAL_TYPE_CLOSURE;
}
+bool BsdfBaseNode::has_bump()
+{
+ /* detect if anything is plugged into the normal input besides the default */
+ ShaderInput *normal_in = input("Normal");
+ return (normal_in && normal_in->link &&
+ normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
+}
+
/* BSDF Closure */
BsdfNode::BsdfNode(const NodeType *node_type)
@@ -2439,9 +2447,7 @@ void PrincipledBsdfNode::compile(OSLCompiler& compiler)
bool PrincipledBsdfNode::has_bssrdf_bump()
{
- /* detect if anything is plugged into the normal input besides the default */
- ShaderInput *normal_in = input("Normal");
- return (normal_in->link && normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY);
+ return has_surface_bssrdf() && has_bump();
}
/* Translucent BSDF Closure */
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index c0271a3c8eb..ec4c7c7c50d 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -326,6 +326,16 @@ class BsdfBaseNode : public ShaderNode {
public:
BsdfBaseNode(const NodeType *node_type);
+ bool has_spatial_varying() { return true; }
+ virtual ClosureType get_closure_type() { return closure; }
+ virtual bool has_bump();
+
+ virtual bool equals(const ShaderNode& /*other*/)
+ {
+ /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
+ return false;
+ }
+
ClosureType closure;
};
@@ -334,19 +344,11 @@ public:
explicit BsdfNode(const NodeType *node_type);
SHADER_NODE_BASE_CLASS(BsdfNode)
- bool has_spatial_varying() { return true; }
void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL);
- virtual ClosureType get_closure_type() { return closure; }
float3 color;
float3 normal;
float surface_mix_weight;
-
- virtual bool equals(const ShaderNode& /*other*/)
- {
- /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
- return false;
- }
};
class AnisotropicBsdfNode : public BsdfNode {
@@ -373,7 +375,6 @@ class PrincipledBsdfNode : public BsdfBaseNode {
public:
SHADER_NODE_CLASS(PrincipledBsdfNode)
- bool has_spatial_varying() { return true; }
bool has_surface_bssrdf();
bool has_bssrdf_bump();
void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius,
@@ -390,13 +391,6 @@ public:
float surface_mix_weight;
ClosureType distribution, distribution_orig;
- virtual bool equals(const ShaderNode * /*other*/)
- {
- /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */
- return false;
- }
-
- ClosureType get_closure_type() { return closure; }
bool has_integrator_dependency();
void attributes(Shader *shader, AttributeRequestSet *attributes);
};
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index c337079b09f..5c5ac6e2be9 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -721,6 +721,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
current_shader->has_surface_bssrdf = true;
current_shader->has_bssrdf_bump = true; /* can't detect yet */
}
+ current_shader->has_bump = true; /* can't detect yet */
}
if(node->has_spatial_varying()) {
@@ -1029,6 +1030,9 @@ void OSLCompiler::generate_nodes(const ShaderNodeSet& nodes)
if(node->has_bssrdf_bump())
current_shader->has_bssrdf_bump = true;
}
+ if(node->has_bump()) {
+ current_shader->has_bump = true;
+ }
}
else if(current_type == SHADER_TYPE_VOLUME) {
if(node->has_spatial_varying())
@@ -1091,21 +1095,14 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
ShaderGraph *graph = shader->graph;
ShaderNode *output = (graph)? graph->output(): NULL;
- /* copy graph for shader with bump mapping */
- if(output->input("Surface")->link && output->input("Displacement")->link)
- if(!shader->graph_bump)
- shader->graph_bump = shader->graph->copy();
+ bool has_bump = (shader->displacement_method != DISPLACE_TRUE) &&
+ output->input("Surface")->link && output->input("Displacement")->link;
/* finalize */
shader->graph->finalize(scene,
- false,
- shader->has_integrator_dependency);
- if(shader->graph_bump) {
- shader->graph_bump->finalize(scene,
- true,
- shader->has_integrator_dependency,
- shader->displacement_method == DISPLACE_BOTH);
- }
+ has_bump,
+ shader->has_integrator_dependency,
+ shader->displacement_method == DISPLACE_BOTH);
current_shader = shader;
@@ -1113,7 +1110,8 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_surface_bssrdf = false;
- shader->has_bssrdf_bump = false;
+ shader->has_bump = has_bump;
+ shader->has_bssrdf_bump = has_bump;
shader->has_volume = false;
shader->has_displacement = false;
shader->has_surface_spatial_varying = false;
@@ -1125,8 +1123,8 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
if(shader->used && graph && output->input("Surface")->link) {
shader->osl_surface_ref = compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
- if(shader->graph_bump && shader->displacement_method != DISPLACE_TRUE)
- shader->osl_surface_bump_ref = compile_type(shader, shader->graph_bump, SHADER_TYPE_BUMP);
+ if(has_bump)
+ shader->osl_surface_bump_ref = compile_type(shader, shader->graph, SHADER_TYPE_BUMP);
else
shader->osl_surface_bump_ref = OSL::ShaderGroupRef();
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 493e01de363..86378dfb495 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -177,7 +177,6 @@ Shader::Shader()
pass_id = 0;
graph = NULL;
- graph_bump = NULL;
has_surface = false;
has_surface_transparent = false;
@@ -185,6 +184,7 @@ Shader::Shader()
has_surface_bssrdf = false;
has_volume = false;
has_displacement = false;
+ has_bump = false;
has_bssrdf_bump = false;
has_surface_spatial_varying = false;
has_volume_spatial_varying = false;
@@ -204,7 +204,6 @@ Shader::Shader()
Shader::~Shader()
{
delete graph;
- delete graph_bump;
}
bool Shader::is_constant_emission(float3 *emission)
@@ -239,9 +238,7 @@ void Shader::set_graph(ShaderGraph *graph_)
/* assign graph */
delete graph;
- delete graph_bump;
graph = graph_;
- graph_bump = NULL;
/* Store info here before graph optimization to make sure that
* nodes that get optimized away still count. */
@@ -458,15 +455,11 @@ void ShaderManager::device_update_common(Device *device,
flag |= SD_VOLUME_MIS;
if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_CUBIC)
flag |= SD_VOLUME_CUBIC;
- if(shader->graph_bump)
+ if(shader->has_bump)
flag |= SD_HAS_BUMP;
if(shader->displacement_method != DISPLACE_BUMP)
flag |= SD_HAS_DISPLACEMENT;
- /* shader with bump mapping */
- if(shader->displacement_method != DISPLACE_TRUE && shader->graph_bump)
- flag |= SD_HAS_BSSRDF_BUMP;
-
/* constant emission check */
float3 constant_emission = make_float3(0.0f, 0.0f, 0.0f);
if(shader->is_constant_emission(&constant_emission))
@@ -608,11 +601,6 @@ void ShaderManager::get_requested_features(Scene *scene,
Shader *shader = scene->shaders[i];
/* Gather requested features from all the nodes from the graph nodes. */
get_requested_graph_features(shader->graph, requested_features);
- /* Gather requested features from the graph itself. */
- if(shader->graph_bump) {
- get_requested_graph_features(shader->graph_bump,
- requested_features);
- }
ShaderNode *output_node = shader->graph->output();
if(output_node->input("Displacement")->link != NULL) {
requested_features->nodes_features |= NODE_FEATURE_BUMP;
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index b6714b13247..79a67d6756a 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -89,11 +89,6 @@ public:
/* shader graph */
ShaderGraph *graph;
- /* shader graph with auto bump mapping included, we compile two shaders,
- * with and without bump, because the displacement method is a mesh
- * level setting, so we need to handle both */
- ShaderGraph *graph_bump;
-
/* sampling */
bool use_mis;
bool use_transparent_shadow;
@@ -121,6 +116,7 @@ public:
bool has_volume;
bool has_displacement;
bool has_surface_bssrdf;
+ bool has_bump;
bool has_bssrdf_bump;
bool has_surface_spatial_varying;
bool has_volume_spatial_varying;
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 48287d872d4..32f89897970 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -521,6 +521,9 @@ void SVMCompiler::generate_closure_node(ShaderNode *node,
if(node->has_bssrdf_bump())
current_shader->has_bssrdf_bump = true;
}
+ if(node->has_bump()) {
+ current_shader->has_bump = true;
+ }
}
}
@@ -799,29 +802,21 @@ void SVMCompiler::compile(Scene *scene,
Summary *summary)
{
/* copy graph for shader with bump mapping */
- ShaderNode *node = shader->graph->output();
+ ShaderNode *output = shader->graph->output();
int start_num_svm_nodes = svm_nodes.size();
const double time_start = time_dt();
- if(node->input("Surface")->link && node->input("Displacement")->link)
- if(!shader->graph_bump)
- shader->graph_bump = shader->graph->copy();
+ bool has_bump = (shader->displacement_method != DISPLACE_TRUE) &&
+ output->input("Surface")->link && output->input("Displacement")->link;
/* finalize */
{
scoped_timer timer((summary != NULL)? &summary->time_finalize: NULL);
shader->graph->finalize(scene,
- false,
- shader->has_integrator_dependency);
- }
-
- if(shader->graph_bump) {
- scoped_timer timer((summary != NULL)? &summary->time_finalize_bump: NULL);
- shader->graph_bump->finalize(scene,
- true,
- shader->has_integrator_dependency,
- shader->displacement_method == DISPLACE_BOTH);
+ has_bump,
+ shader->has_integrator_dependency,
+ shader->displacement_method == DISPLACE_BOTH);
}
current_shader = shader;
@@ -830,7 +825,8 @@ void SVMCompiler::compile(Scene *scene,
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_surface_bssrdf = false;
- shader->has_bssrdf_bump = false;
+ shader->has_bump = has_bump;
+ shader->has_bssrdf_bump = has_bump;
shader->has_volume = false;
shader->has_displacement = false;
shader->has_surface_spatial_varying = false;
@@ -839,9 +835,9 @@ void SVMCompiler::compile(Scene *scene,
shader->has_integrator_dependency = false;
/* generate bump shader */
- if(shader->displacement_method != DISPLACE_TRUE && shader->graph_bump) {
+ if(has_bump) {
scoped_timer timer((summary != NULL)? &summary->time_generate_bump: NULL);
- compile_type(shader, shader->graph_bump, SHADER_TYPE_BUMP);
+ compile_type(shader, shader->graph, SHADER_TYPE_BUMP);
svm_nodes[index].y = svm_nodes.size();
svm_nodes.insert(svm_nodes.end(),
current_svm_nodes.begin(),
@@ -853,7 +849,7 @@ void SVMCompiler::compile(Scene *scene,
scoped_timer timer((summary != NULL)? &summary->time_generate_surface: NULL);
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
/* only set jump offset if there's no bump shader, as the bump shader will fall thru to this one if it exists */
- if(shader->displacement_method == DISPLACE_TRUE || !shader->graph_bump) {
+ if(!has_bump) {
svm_nodes[index].y = svm_nodes.size();
}
svm_nodes.insert(svm_nodes.end(),
@@ -895,7 +891,6 @@ SVMCompiler::Summary::Summary()
: num_svm_nodes(0),
peak_stack_usage(0),
time_finalize(0.0),
- time_finalize_bump(0.0),
time_generate_surface(0.0),
time_generate_bump(0.0),
time_generate_volume(0.0),
@@ -911,10 +906,7 @@ string SVMCompiler::Summary::full_report() const
report += string_printf("Peak stack usage: %d\n", peak_stack_usage);
report += string_printf("Time (in seconds):\n");
- report += string_printf(" Finalize: %f\n", time_finalize);
- report += string_printf(" Bump finalize: %f\n", time_finalize_bump);
- report += string_printf("Finalize: %f\n", time_finalize +
- time_finalize_bump);
+ report += string_printf("Finalize: %f\n", time_finalize);
report += string_printf(" Surface: %f\n", time_generate_surface);
report += string_printf(" Bump: %f\n", time_generate_bump);
report += string_printf(" Volume: %f\n", time_generate_volume);
diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h
index abbd9e50610..98ef5fa05d8 100644
--- a/intern/cycles/render/svm.h
+++ b/intern/cycles/render/svm.h
@@ -74,9 +74,6 @@ public:
/* Time spent on surface graph finalization. */
double time_finalize;
- /* Time spent on bump graph finalization. */
- double time_finalize_bump;
-
/* Time spent on generating SVM nodes for surface shader. */
double time_generate_surface;