void InputBinder::bind(const Scene& scene) { try { // Build the symbol table of the scene. SymbolTable scene_symbols; build_scene_symbol_table(scene, scene_symbols); // Bind all inputs of all entities in the scene. bind_scene_entities_inputs(scene, scene_symbols); // Bind all inputs of all entities in all assemblies. for (const_each<AssemblyContainer> i = scene.assemblies(); i; ++i) { assert(m_assembly_info.empty()); bind_assembly_entities_inputs(scene, scene_symbols, *i); } } catch (const ExceptionUnknownEntity& e) { RENDERER_LOG_ERROR( "while binding inputs of \"%s\": could not locate entity \"%s\".", e.get_context_path().c_str(), e.string()); ++m_error_count; } }
void InputBinder::bind(const Scene& scene) { // Build the symbol table of the scene. SymbolTable scene_symbols; build_scene_symbol_table( scene, scene_symbols); // Bind all inputs of all entities in the scene. bind_scene_entities_inputs( scene, scene_symbols); // Bind inputs of all entities in assemblies. for (const_each<AssemblyContainer> i = scene.assemblies(); i; ++i) { // Retrieve the assembly. const Assembly& assembly = *i; // Build the symbol table of the assembly. SymbolTable assembly_symbols; build_assembly_symbol_table( assembly, assembly_symbols); // Bind all inputs of all entities in the assembly. bind_assembly_entities_inputs( scene, scene_symbols, assembly, assembly_symbols); } }
void InputBinder::bind_assembly_entities_inputs( const Scene& scene, const SymbolTable& scene_symbols, const Assembly& assembly) { // Build the symbol table of the assembly. SymbolTable assembly_symbols; build_assembly_symbol_table(assembly, assembly_symbols); // Push the assembly and its symbol table to the stack. AssemblyInfo info; info.m_assembly = &assembly; info.m_assembly_symbols = &assembly_symbols; m_assembly_info.push_back(info); // Bind textures to texture instances. // Other entities might need to access the textures bound to texture instances, // so binding of textures to texture instances must come first. for (each<TextureInstanceContainer> i = assembly.texture_instances(); i; ++i) { i->unbind_texture(); for (AssemblyInfoIt j = m_assembly_info.rbegin(); j != m_assembly_info.rend(); ++j) i->bind_texture(j->m_assembly->textures()); i->bind_texture(scene.textures()); i->check_texture(); } // Bind BSDFs inputs. for (each<BSDFContainer> i = assembly.bsdfs(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolBSDF), *i); } // Bind BSSRDFs inputs. for (each<BSSRDFContainer> i = assembly.bssrdfs(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolBSSRDF), *i); } // Bind EDFs inputs. for (each<EDFContainer> i = assembly.edfs(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolEDF), *i); } #ifdef APPLESEED_WITH_OSL // Bind ShaderGroups inputs. for (each<ShaderGroupContainer> i = assembly.shader_groups(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolShaderGroup), *i); } #endif // Bind surface shaders inputs. for (each<SurfaceShaderContainer> i = assembly.surface_shaders(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolSurfaceShader), *i); } // Bind materials inputs. for (each<MaterialContainer> i = assembly.materials(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolMaterial), *i); } // Bind lights inputs. for (each<LightContainer> i = assembly.lights(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolLight), *i); } // Bind objects inputs. for (each<ObjectContainer> i = assembly.objects(); i; ++i) { bind_assembly_entity_inputs( scene, scene_symbols, SymbolTable::symbol_name(SymbolTable::SymbolObject), *i); } // Bind objects to object instances. This must be done before binding materials. for (each<ObjectInstanceContainer> i = assembly.object_instances(); i; ++i) { i->unbind_object(); for (AssemblyInfoIt j = m_assembly_info.rbegin(); j != m_assembly_info.rend(); ++j) i->bind_object(j->m_assembly->objects()); i->check_object(); } // Bind materials to object instances. for (each<ObjectInstanceContainer> i = assembly.object_instances(); i; ++i) { i->unbind_materials(); for (AssemblyInfoIt j = m_assembly_info.rbegin(); j != m_assembly_info.rend(); ++j) i->bind_materials(j->m_assembly->materials()); i->check_materials(); } // Bind assemblies to assembly instances. for (each<AssemblyInstanceContainer> i = assembly.assembly_instances(); i; ++i) { i->unbind_assembly(); for (AssemblyInfoIt j = m_assembly_info.rbegin(); j != m_assembly_info.rend(); ++j) i->bind_assembly(j->m_assembly->assemblies()); i->bind_assembly(scene.assemblies()); i->check_assembly(); } // Recurse into child assemblies. for (const_each<AssemblyContainer> i = assembly.assemblies(); i; ++i) bind_assembly_entities_inputs(scene, scene_symbols, *i); // Pop the information about this assembly from the stack. m_assembly_info.pop_back(); }