bool Material::on_frame_begin( const Project& project, const Assembly& assembly) { m_surface_shader = get_uncached_surface_shader(); m_bsdf = get_uncached_bsdf(); m_edf = get_uncached_edf(); m_alpha_map = get_uncached_alpha_map(); const Source* displacement_source = m_inputs.source("displacement_map"); if (displacement_source) { if (dynamic_cast<const TextureSource*>(displacement_source) == 0) { RENDERER_LOG_ERROR( "while defining material \"%s\": a texture instance must be bound " "to the \"displacement_map\" input; disabling displacement map for this material.", get_name()); } else { const TextureSource* displacement_map = static_cast<const TextureSource*>(displacement_source); const Texture& texture = displacement_map->get_texture_instance().get_texture(); if (texture.get_color_space() != ColorSpaceLinearRGB) { RENDERER_LOG_WARNING( "while defining material \"%s\": color space for displacement map \"%s\" " "should be \"%s\" but is \"%s\" instead; expect artifacts and/or slowdowns.", get_name(), texture.get_name(), color_space_name(ColorSpaceLinearRGB), color_space_name(texture.get_color_space())); } // Retrieve the displacement method and create the normal modifier. const string displacement_method = m_params.get_required<string>("displacement_method", "bump"); if (displacement_method == "bump") { const double amplitude = m_params.get_optional<double>("bump_amplitude", 1.0); m_normal_modifier = new BumpMappingModifier(displacement_map, 2.0, amplitude); } else if (displacement_method == "normal") m_normal_modifier = new NormalMappingModifier(displacement_map); else { RENDERER_LOG_ERROR( "while defining material \"%s\": invalid value \"%s\" for parameter " "\"displacement_method\"; disabling displacement map for this material.", get_name(), displacement_method.c_str()); } } } return true; }
bool Material::has_emission() const { return get_uncached_edf() != 0; }