Code cleanup: remove copy of shader graph for bump, no longer needed.

This commit is contained in:
Brecht Van Lommel
2017-08-20 14:02:16 +02:00
parent e27a59d411
commit 0b07c2c8a2
7 changed files with 24 additions and 84 deletions

View File

@@ -1091,21 +1091,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 +1106,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 +1119,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();