|
Blender V4.5
|
General operations, lookup, etc. for materials. More...
#include <optional>Go to the source code of this file.
Functions | |
Module | |
| void | BKE_materials_init () |
| void | BKE_materials_exit () |
Materials | |
| void | BKE_object_materials_sync_length (Main *bmain, Object *ob, ID *id) |
| void | BKE_objects_materials_sync_length_all (Main *bmain, ID *id) |
| void | BKE_object_material_resize (Main *bmain, Object *ob, short totcol, bool do_id_user) |
| void | BKE_object_material_remap (Object *ob, const unsigned int *remap) |
| void | BKE_object_material_remap_calc (Object *ob_dst, Object *ob_src, short *remap_src_to_dst) |
| void | BKE_object_material_from_eval_data (Main *bmain, Object *ob_orig, const ID *data_eval) |
| Material * | BKE_material_add (Main *bmain, const char *name) |
| Material * | BKE_gpencil_material_add (Main *bmain, const char *name) |
| void | BKE_gpencil_material_attr_init (Material *ma) |
| void | BKE_material_make_node_previews_dirty (Material *ma) |
RNA API | |
| void | BKE_id_materials_copy (Main *bmain, ID *id_src, ID *id_dst) |
| void | BKE_id_material_resize (Main *bmain, ID *id, short totcol, bool do_id_user) |
| void | BKE_id_material_append (Main *bmain, ID *id, Material *ma) |
| Material * | BKE_id_material_pop (Main *bmain, ID *id, int index) |
| void | BKE_id_material_clear (Main *bmain, ID *id) |
Evaluation API | |
| Material * | BKE_object_material_get_eval (Object *ob, short act) |
| const Material * | BKE_object_material_get_eval (const Object &ob, const ID &data, short act) |
| int | BKE_object_material_count_eval (const Object *ob) |
| int | BKE_object_material_count_eval (const Object &ob, const ID &data) |
| std::optional< int > | BKE_id_material_index_max_eval (const ID &id) |
| int | BKE_id_material_used_eval (const ID &id) |
| int | BKE_id_material_used_with_fallback_eval (const ID &id) |
| int | BKE_object_material_used_with_fallback_eval (const Object &ob) |
| void | BKE_id_material_eval_assign (ID *id, int slot, Material *material) |
| void | BKE_id_material_eval_ensure_default_slot (ID *id) |
Rendering | |
| void | ramp_blend (int type, float r_col[3], float fac, const float col[3]) |
Default Materials | |
TODO: Explain expected usages? Seems to be primarily defined for GPU/viewport code?
| |
| Material * | BKE_material_default_empty () |
| Material * | BKE_material_default_holdout () |
| Material * | BKE_material_default_surface () |
| Material * | BKE_material_default_volume () |
| Material * | BKE_material_default_gpencil () |
| void | BKE_material_defaults_free_gpu () |
Dependency graph evaluation | |
| void | BKE_material_eval (Depsgraph *depsgraph, Material *material) |
General operations, lookup, etc. for materials.
Definition in file BKE_material.hh.
| anonymous enum |
| Enumerator | |
|---|---|
| BKE_MAT_ASSIGN_EXISTING | |
| BKE_MAT_ASSIGN_USERPREF | |
| BKE_MAT_ASSIGN_OBDATA | |
| BKE_MAT_ASSIGN_OBJECT | |
Definition at line 77 of file BKE_material.hh.
Definition at line 931 of file blenkernel/intern/material.cc.
References BKE_material_default_gpencil(), and BKE_object_material_get().
Referenced by blender::ed::greasepencil::grease_pencil_material_reveal_exec(), and blender::ed::greasepencil::material_isolate_exec().
Definition at line 312 of file blenkernel/intern/material.cc.
References BKE_gpencil_material_attr_init(), and BKE_material_add().
Referenced by BKE_grease_pencil_object_material_new(), BLO_update_defaults_startup_blend(), and new_material_exec().
| void BKE_gpencil_material_attr_init | ( | Material * | ma | ) |
Definition at line 263 of file blenkernel/intern/material.cc.
References ARRAY_SET_ITEMS, MaterialGPencilStyle::fill_rgba, MaterialGPencilStyle::flag, GP_MATERIAL_STROKE_SHOW, Material::gp_style, MEM_callocN(), MaterialGPencilStyle::mix_factor, MaterialGPencilStyle::mix_rgba, MaterialGPencilStyle::stroke_rgba, MaterialGPencilStyle::texture_offset, MaterialGPencilStyle::texture_pixsize, and MaterialGPencilStyle::texture_scale.
Referenced by BKE_gpencil_material_add(), BKE_gpencil_material_settings(), and material_default_gpencil_init().
| MaterialGPencilStyle * BKE_gpencil_material_settings | ( | Object * | ob, |
| short | act ) |
Definition at line 943 of file blenkernel/intern/material.cc.
References BKE_gpencil_material_attr_init(), BKE_material_default_gpencil(), BKE_object_material_get(), and Material::gp_style.
Referenced by blender::draw::overlay::GreasePencil::draw_grease_pencil(), blender::draw::gpencil::gpencil_material_pool_create(), blender::draw::gpencil::gpencil_object_cache_add(), blender::ed::greasepencil::grease_pencil_texture_gradient_exec(), blender::ed::greasepencil::material_isolate_exec(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::skip_strokes_with_locked_material(), and blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::stroke_eraser().
Definition at line 585 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_objects_materials_sync_length_all(), DEG_id_tag_update(), DEG_relations_tag_update(), ID_RECALC_SYNC_TO_EVAL, id_us_plus(), MEM_calloc_arrayN(), and MEM_freeN().
Definition at line 391 of file blenkernel/intern/material.cc.
References BLI_assert, GS, ID_CU_LEGACY, ID_CV, ID_GD_LEGACY, ID_GP, ID_MB, ID_ME, ID_PT, ID_VO, ID::name, and OB_DATA_SUPPORT_ID.
Referenced by blender::ed::object::add_grease_pencil_materials_for_conversion(), blender::nodes::node_geo_set_material_cc::assign_material_to_id_geometry(), BKE_id_material_append(), BKE_id_material_assign(), BKE_id_material_clear(), BKE_id_material_eval_assign(), BKE_id_material_pop(), BKE_id_material_resize(), BKE_id_materials_copy(), BKE_object_material_from_eval_data(), BKE_object_material_get_eval(), blender::ed::object::copy_materials_to_new_geometry_object(), and mesh_separate_material_assign_mat_nr().
Definition at line 1063 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_objects_materials_sync_length_all(), DEG_id_tag_update(), DEG_relations_tag_update(), Material::id, ID_RECALC_GEOMETRY, ID_RECALC_SYNC_TO_EVAL, id_us_min(), id_us_plus(), MAXMAT, MEM_calloc_arrayN(), and MEM_freeN().
Definition at line 647 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_objects_materials_sync_length_all(), DEG_id_tag_update(), DEG_relations_tag_update(), ID_RECALC_SYNC_TO_EVAL, id_us_min(), material_data_index_clear_id(), and MEM_freeN().
Referenced by mesh_separate_material_assign_mat_nr().
Definition at line 855 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BLI_assert, BLI_assert_unreachable, ELEM, i, and MEM_reallocN.
Referenced by blender::nodes::node_geo_set_material_cc::assign_material_to_id_geometry(), BKE_id_material_eval_ensure_default_slot(), blender::geometry::execute_realize_mesh_tasks(), and blender::nodes::node_geo_set_material_cc::node_geo_exec().
| void BKE_id_material_eval_ensure_default_slot | ( | ID * | id | ) |
Add an empty material slot if the id has no material slots. This material slot allows the material to be overwritten by object-linked materials.
Definition at line 882 of file blenkernel/intern/material.cc.
References BKE_id_material_eval_assign(), and BKE_id_material_len_p().
Referenced by blender::nodes::node_geo_set_material_cc::assign_material_to_id_geometry(), blender::nodes::node_geo_mesh_primitive_circle_cc::create_circle_mesh(), blender::nodes::node_geo_mesh_primitive_ico_sphere_cc::create_ico_sphere_mesh(), blender::nodes::node_geo_grid_to_mesh_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_cone_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_cube_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_cylinder_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_grid_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_line_cc::node_geo_exec(), and blender::nodes::node_geo_mesh_primitive_uv_sphere_cc::node_geo_exec().
| std::optional< int > BKE_id_material_index_max_eval | ( | const ID & | id | ) |
Returns the maximum material index used by the geometry. This returns zero if the geometry is empty or if all material indices are negative.
Definition at line 808 of file blenkernel/intern/material.cc.
References BLI_assert_unreachable, GS, ID_CU_LEGACY, ID_CV, ID_GD_LEGACY, ID_GP, ID_MB, ID_ME, ID_PT, and ID_VO.
Referenced by BKE_id_material_used_eval(), and BKE_id_material_used_with_fallback_eval().
| short * BKE_id_material_len_p | ( | ID * | id | ) |
Definition at line 419 of file blenkernel/intern/material.cc.
References BLI_assert, GS, ID_CU_LEGACY, ID_CV, ID_GD_LEGACY, ID_GP, ID_MB, ID_ME, ID_PT, ID_VO, ID::name, and OB_DATA_SUPPORT_ID.
Referenced by blender::ed::object::add_grease_pencil_materials_for_conversion(), blender::ed::object::add_type_with_obdata(), blender::nodes::node_geo_set_material_cc::assign_material_to_id_geometry(), BKE_id_material_append(), BKE_id_material_assign(), BKE_id_material_clear(), BKE_id_material_eval_assign(), BKE_id_material_eval_ensure_default_slot(), BKE_id_material_pop(), BKE_id_material_resize(), BKE_id_materials_copy(), BKE_object_material_count_eval(), BKE_object_material_count_eval(), BKE_object_material_from_eval_data(), BKE_object_material_get_eval(), BKE_object_materials_sync_length(), BKE_objects_materials_sync_length_all(), blender::ed::object::copy_materials_to_new_geometry_object(), and mesh_separate_material_assign_mat_nr().
Definition at line 609 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_objects_materials_sync_length_all(), DEG_id_tag_update(), DEG_relations_tag_update(), ID_RECALC_SYNC_TO_EVAL, id_us_min(), material_data_index_remove_id(), MEM_freeN(), MEM_reallocN, and ret.
Definition at line 550 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), DEG_id_tag_update(), DEG_relations_tag_update(), i, ID_RECALC_SYNC_TO_EVAL, id_us_min(), MEM_freeN(), and MEM_recallocN.
Referenced by BKE_object_materials_sync_length(), and mesh_separate_material_assign_mat_nr().
| int BKE_id_material_used_eval | ( | const ID & | id | ) |
Returns how many material slots the geometry may use (based on the maximum material index).
Definition at line 835 of file blenkernel/intern/material.cc.
References BKE_id_material_index_max_eval().
Referenced by blender::ed::object::copy_materials_to_new_geometry_object().
| int BKE_id_material_used_with_fallback_eval | ( | const ID & | id | ) |
Gets the number of material slots used by the geometry. The corresponding material for each slot can be retrieved with BKE_object_material_get_eval.
These two functions give the same result when the mesh is provided itself, or an object that uses the mesh.
NOTE: This may be higher or lower than the number of material slots on the object or object-data. However, it is always at least 1 (the fallback).
Definition at line 843 of file blenkernel/intern/material.cc.
References BKE_id_material_index_max_eval().
Referenced by BKE_object_material_used_with_fallback_eval(), blender::draw::mesh_batch_cache_init(), blender::draw::mesh_batch_cache_valid(), blender::draw::pointcloud_batch_cache_init(), and blender::draw::pointcloud_batch_cache_valid().
Definition at line 529 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), DEG_id_tag_update(), DEG_relations_tag_update(), ID_RECALC_SYNC_TO_EVAL, id_us_plus(), and MEM_dupallocN().
Referenced by BKE_mesh_to_pointcloud(), BKE_pointcloud_to_mesh(), and blender::bke::greasepencil::convert::legacy_gpencil_to_grease_pencil().
Definition at line 303 of file blenkernel/intern/material.cc.
References BKE_id_new().
Referenced by blender::io::usd::USDMaterialReader::add_material(), blender::io::alembic::utils::assign_materials(), BKE_gpencil_material_add(), get_or_create_current_material(), blender::io::obj::get_or_create_material(), Freestyle::BlenderStrokeRenderer::GetStrokeShader(), blender::bke::tests::IDSubDataTestData::IDSubDataTestData(), blender::io::fbx::import_material(), blender::bke::tests::MaterialTestData::MaterialTestData(), new_material_exec(), blender::animrig::tests::KeyframingTest::SetUp(), blender::nodes::tests::TEST_F(), blender::nodes::tests::TEST_F(), blender::nodes::tests::TEST_F(), blender::nodes::tests::TEST_F(), and DocumentImporter::writeMaterial().
| Material * BKE_material_default_empty | ( | ) |
Definition at line 2136 of file blenkernel/intern/material.cc.
References default_material_empty.
Referenced by blender::workbench::Instance::get_material().
| Material * BKE_material_default_gpencil | ( | ) |
Definition at line 2156 of file blenkernel/intern/material.cc.
References default_material_gpencil.
Referenced by BKE_gpencil_material(), BKE_gpencil_material_settings(), and BKE_grease_pencil_object_material_ensure_from_brush().
| Material * BKE_material_default_holdout | ( | ) |
Definition at line 2141 of file blenkernel/intern/material.cc.
References default_material_holdout.
| Material * BKE_material_default_surface | ( | ) |
Definition at line 2146 of file blenkernel/intern/material.cc.
References default_material_surface.
Referenced by ED_node_shader_default(), and blender::eevee::MaterialModule::MaterialModule().
| Material * BKE_material_default_volume | ( | ) |
Definition at line 2151 of file blenkernel/intern/material.cc.
References default_material_volume.
Referenced by ED_node_shader_default(), and blender::eevee::MaterialModule::MaterialModule().
| void BKE_material_defaults_free_gpu | ( | ) |
Definition at line 2161 of file blenkernel/intern/material.cc.
References default_materials, ListBase::first, GPU_material_free(), Material::gpumaterial, and i.
Referenced by GPU_exit(), and GPU_materials_free().
| void BKE_material_eval | ( | Depsgraph * | depsgraph, |
| Material * | material ) |
Definition at line 2019 of file blenkernel/intern/material.cc.
References DEG_debug_print_eval(), depsgraph, GPU_material_free(), Material::gpumaterial, Material::id, and ID::name.
| void BKE_material_make_node_previews_dirty | ( | Material * | ma | ) |
Definition at line 296 of file blenkernel/intern/material.cc.
References Material::nodetree, and nodetree_mark_previews_dirty_reccursive().
Referenced by ED_render_engine_changed().
| void BKE_materials_exit | ( | ) |
Definition at line 2188 of file blenkernel/intern/material.cc.
References BKE_id_free(), default_materials, i, and Material::id.
Referenced by blender::bke::tests::LibQueryTest::TearDownTestSuite(), blender::bke::tests::LibRemapTest::TearDownTestSuite(), blender::nodes::tests::NodeTest::TearDownTestSuite(), and WM_exit_ex().
| void BKE_materials_init | ( | ) |
Definition at line 2173 of file blenkernel/intern/material.cc.
References BLI_assert_msg, default_material_empty, default_material_gpencil, default_material_holdout, default_material_surface, default_material_volume, default_materials, i, material_default_create(), material_default_gpencil_init(), material_default_holdout_init(), material_default_surface_init(), and material_default_volume_init().
Referenced by main(), blender::bke::tests::LibQueryTest::SetUpTestSuite(), blender::bke::tests::LibRemapTest::SetUpTestSuite(), and blender::nodes::tests::NodeTest::SetUpTestSuite().
| void BKE_object_material_array_assign | ( | Main * | bmain, |
| Object * | ob, | ||
| Material *** | matar, | ||
| int | totcol, | ||
| bool | to_object_only ) |
Definition at line 1331 of file blenkernel/intern/material.cc.
References Object::actcol, BKE_MAT_ASSIGN_OBJECT, BKE_MAT_ASSIGN_USERPREF, BKE_object_material_assign(), BKE_object_material_slot_remove(), i, Object::matbits, and Object::totcol.
Referenced by ED_grease_pencil_join_objects_exec(), blender::ed::greasepencil::grease_pencil_separate_layer(), blender::ed::greasepencil::grease_pencil_separate_material(), blender::ed::greasepencil::grease_pencil_separate_selected(), material_slot_copy_exec(), mesh_separate_arrays(), and mesh_separate_tagged().
Definition at line 325 of file blenkernel/intern/material.cc.
References Object::data, ELEM, Curve::mat, Curves::mat, Mesh::mat, MetaBall::mat, PointCloud::mat, Volume::mat, GreasePencil::material_array, OB_CURVES, OB_CURVES_LEGACY, OB_FONT, OB_GREASE_PENCIL, OB_MBALL, OB_MESH, OB_POINTCLOUD, OB_SURF, OB_VOLUME, and Object::type.
Referenced by BKE_object_duplicate(), BKE_object_material_get_p(), BKE_object_material_remap(), BKE_object_material_slot_find_index(), BKE_object_material_slot_remove(), blender::deg::DepsgraphNodeBuilder::build_object_data(), blender::deg::DepsgraphRelationBuilder::build_object_data(), blender::ed::greasepencil::grease_pencil_separate_layer(), blender::ed::greasepencil::grease_pencil_separate_material(), blender::ed::greasepencil::grease_pencil_separate_selected(), blender::ed::object::make_local_exec(), material_slot_copy_exec(), mesh_separate_arrays(), mesh_separate_tagged(), object_material_assign(), blender::ed::space_node::preview_prepare_scene(), preview_prepare_scene(), and similar_face_select_exec().
| void BKE_object_material_assign | ( | Main * | bmain, |
| Object * | ob, | ||
| Material * | ma, | ||
| short | act, | ||
| int | assign_type ) |
Definition at line 1208 of file blenkernel/intern/material.cc.
References object_material_assign().
Referenced by MeshImporter::assign_material_to_geom(), blender::ed::greasepencil::bake_grease_pencil_animation_exec(), BKE_grease_pencil_object_material_new(), BKE_object_material_array_assign(), BKE_object_material_ensure(), BKE_object_material_slot_add(), blender::ed::object::drop_named_material_invoke(), get_or_create_current_material(), grease_pencil_object_material_ensure_from_brush_pinned(), blender::bke::tests::IDSubDataTestData::IDSubDataTestData(), blender::ed::object::make_links_data_exec(), blender::ed::outliner::material_drop_invoke(), blender::animrig::tests::KeyframingTest::SetUp(), blender::ed::object::single_mat_users(), and ui_drop_material_exec().
| void BKE_object_material_assign_single_obdata | ( | Main * | bmain, |
| Object * | ob, | ||
| Material * | ma, | ||
| short | act ) |
Similar to BKE_object_material_assign with BKE_MAT_ASSIGN_OBDATA type, but does not scan whole Main for other usages of the same obdata. Only use in cases where you know that the object's obdata is only used by this one object.
Definition at line 1213 of file blenkernel/intern/material.cc.
References BKE_MAT_ASSIGN_OBDATA, and object_material_assign().
Referenced by blender::io::alembic::utils::assign_materials(), and blender::io::usd::utils::assign_materials().
Same as above but allows using a custom ID as data instead of Object.data.
Definition at line 797 of file blenkernel/intern/material.cc.
References BKE_id_material_len_p(), BLI_assert, data, Object::data, DEG_is_evaluated(), OB_EMPTY, Object::totcol, and Object::type.
| int BKE_object_material_count_eval | ( | const Object * | ob | ) |
Gets the number of material slots on the evaluated object. This is the maximum of the number of material slots on the object and geometry.
Definition at line 785 of file blenkernel/intern/material.cc.
References BKE_id_material_len_p(), BLI_assert, Object::data, DEG_is_evaluated(), get_evaluated_object_data_with_materials(), OB_EMPTY, Object::totcol, and Object::type.
Referenced by BKE_object_material_get_eval(), blender::draw::sculpt_batches_get_ex(), blender::io::hydra::CurvesData::write_materials(), and blender::io::hydra::VolumeData::write_materials().
Definition at line 917 of file blenkernel/intern/material.cc.
References BKE_MAT_ASSIGN_USERPREF, BKE_object_material_assign(), BKE_object_material_index_get(), BKE_object_material_slot_add(), and Object::totcol.
Referenced by blender::ed::greasepencil::clipboard_materials_remap(), and blender::ed::greasepencil::grease_pencil_material_copy_to_object_exec().
Copy materials from evaluated geometry to the original geometry of an object.
Definition at line 1296 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_object_materials_sync_length(), Object::data, DEG_get_original(), ELEM, i, Material::id, id_us_min(), id_us_plus(), MEM_calloc_arrayN(), and MEM_SAFE_FREE.
Referenced by blender::ed::object::apply_grease_pencil_for_modifier(), blender::ed::object::apply_grease_pencil_for_modifier_all_keyframes(), blender::ed::object::convert_curves_component_to_curves(), blender::ed::object::convert_curves_to_grease_pencil(), blender::ed::object::convert_curves_to_mesh(), blender::ed::object::convert_grease_pencil_component_to_curves(), blender::ed::object::convert_grease_pencil_to_mesh(), blender::ed::object::convert_mesh_to_mesh(), blender::ed::object::modifier_apply_obdata(), and blender::ed::geometry::store_result_geometry().
Definition at line 711 of file blenkernel/intern/material.cc.
References BKE_object_material_get_p(), Material::gp_style, OB_GREASE_PENCIL, and Object::type.
Referenced by InstanceWriter::add_material_bindings(), blender::ed::greasepencil::add_materials_to_map(), animdata_filter_ds_materials(), blender::io::usd::USDCurvesWriter::assign_materials(), blender::ed::greasepencil::bake_grease_pencil_animation_exec(), blender::ed::object::bake_object_check(), bc_has_animations(), BKE_gpencil_material(), BKE_gpencil_material_settings(), BKE_grease_pencil_object_material_ensure_by_name(), BKE_grease_pencil_object_material_ensure_from_brush(), BKE_grease_pencil_object_material_from_brush_get(), BKE_grease_pencil_object_material_index_get_by_name(), BKE_object_material_index_get(), BKE_object_material_index_get_with_hint(), BKE_object_material_remap_calc(), BKE_texpaint_slots_refresh_object(), buttons_context_path_material(), GeometryExporter::create_mesh_primitive_list(), blender::ed::greasepencil::image_render::draw_grease_pencil_strokes(), blender::ed::object::drop_named_material_tooltip(), ED_mesh_join_objects_exec(), ED_object_assign_active_image(), ED_object_get_active_image(), ED_object_texture_paint_mode_enter_ex(), ED_paint_proj_mesh_data_check(), AnimationExporter::export_curve_animation(), blender::ui::greasepencil::eyedropper_add_material(), eyedropper_cryptomatte_sample_view3d_fl(), blender::bke::paint::canvas::get_active_slot(), blender::ed::sculpt_paint::canvas::get_active_slot(), BCAnimationCurve::get_animation_name(), blender::ed::greasepencil::get_boundary_bounds(), blender::ed::space_node::get_context_path_node_shader(), get_default_texture_layer_name_for_object(), blender::ed::greasepencil::get_fill_material_indices(), blender::modifier::greasepencil::get_grease_pencil_material_passes(), blender::ed::greasepencil::get_hidden_material_indices(), blender::ed::greasepencil::get_locked_material_indices(), get_or_create_current_material(), blender::ed::greasepencil::get_visible_boundary_strokes(), blender::ed::greasepencil::grease_pencil_copy_strokes_exec(), blender::ed::sculpt_paint::grease_pencil_fill_invoke(), blender::ed::greasepencil::grease_pencil_material_copy_to_object_exec(), blender::ed::greasepencil::grease_pencil_material_hide_exec(), blender::ed::greasepencil::grease_pencil_material_lock_all_exec(), blender::ed::greasepencil::grease_pencil_material_lock_unselected_exec(), blender::ed::greasepencil::grease_pencil_material_lock_unused_exec(), blender::ed::greasepencil::grease_pencil_material_unlock_all_exec(), imapaint_pick_uv(), CryptomatteSession::init(), Freestyle::BlenderFileLoader::insertShapeNode(), join_mesh_single(), lineart_load_tri_task(), blender::ed::object::make_links_data_exec(), blender::ed::greasepencil::material_enum_itemf(), material_slot_assign_exec(), material_slot_de_select(), blender::ed::object::mesh_to_grease_pencil_get_material_list(), blender::modify_fill_color(), blender::modify_fill_color(), blender::modify_stroke_color(), blender::modify_stroke_color(), blender::ed::object::object_grease_pencil_add_exec(), blender::ed::object::object_select_all_by_material(), blender::ed::object::object_select_linked_exec(), ForEachMaterialFunctor< Functor >::operator()(), paint_sample_color(), proj_paint_state_mesh_eval_init(), psys_cache_paths(), psys_get_particle_on_path(), psys_thread_context_init(), shader_get_from_context(), blender::ed::object::single_mat_users(), texture_paint_add_texture_paint_slot_invoke(), and versioning_eevee_shadow_settings().
Same as above, but uses the given geometry data instead of ob.data. This is useful for instances. The alternative is to use BKE_object_replace_data_on_shallow_copy which is more hacky.
Definition at line 745 of file blenkernel/intern/material.cc.
References BKE_id_material_array_p(), BKE_id_material_len_p(), BKE_object_material_count_eval(), BLI_assert, clamp_i(), data, DEG_is_evaluated(), Object::mat, Object::matbits, and Object::totcol.
On evaluated objects the number of materials on an object and its data might go out of sync. This is because during evaluation materials can be added/removed on the object data.
For rendering or exporting we generally use the materials on the object data. However, some material indices might be overwritten by the object.
Definition at line 739 of file blenkernel/intern/material.cc.
References BKE_object_material_get_eval(), data, and get_evaluated_object_data_with_materials().
Referenced by BKE_object_material_get_eval(), blender::ed::object::copy_materials_to_new_geometry_object(), ED_object_get_active_image(), blender::workbench::Instance::get_material(), lineart_identify_corner_tri_feature_edges(), blender::draw::overlay::Particles::object_sync(), blender::io::obj::OBJMesh::OBJMesh(), blender::io::hydra::CurvesData::write_materials(), blender::io::hydra::MeshData::write_materials(), and blender::io::hydra::VolumeData::write_materials().
Definition at line 670 of file blenkernel/intern/material.cc.
References BKE_object_material_array_p(), BKE_object_material_len_p(), clamp_i(), Object::mat, Object::matbits, and Object::totcol.
Referenced by BKE_object_material_get(), and new_material_exec().
Definition at line 893 of file blenkernel/intern/material.cc.
References BKE_object_material_get(), BKE_object_material_len_p(), and i.
Referenced by blender::ed::greasepencil::bake_grease_pencil_animation_exec(), bake_strokes(), BKE_object_material_ensure(), BKE_object_material_index_get_with_hint(), blender::generate_strokes(), blender::modifier::greasepencil::get_filtered_stroke_mask(), blender::ed::sculpt_paint::grease_pencil_fill_init(), grease_pencil_object_material_ensure_from_brush_pinned(), blender::ed::greasepencil::grease_pencil_primitive_invoke(), blender::ed::greasepencil::grease_pencil_stroke_material_set_exec(), blender::modify_drawing(), blender::ed::sculpt_paint::greasepencil::PaintOperation::on_stroke_begin(), and blender::ed::sculpt_paint::greasepencil::PaintOperation::on_stroke_done().
A version of BKE_object_material_index_get that takes an index to test first.
| hint_index | When this index is in a valid range, test it first. Useful when an active-index is preferred but may not match the material. |
Definition at line 906 of file blenkernel/intern/material.cc.
References BKE_object_material_get(), BKE_object_material_index_get(), and BKE_object_material_len_p().
Referenced by material_slot_de_select().
| short * BKE_object_material_len_p | ( | Object * | ob | ) |
Definition at line 358 of file blenkernel/intern/material.cc.
References Object::data, ELEM, GreasePencil::material_array_num, OB_CURVES, OB_CURVES_LEGACY, OB_FONT, OB_GREASE_PENCIL, OB_MBALL, OB_MESH, OB_POINTCLOUD, OB_SURF, OB_VOLUME, Curve::totcol, Curves::totcol, Mesh::totcol, MetaBall::totcol, PointCloud::totcol, Volume::totcol, and Object::type.
Referenced by blender::ed::greasepencil::active_grease_pencil_material_poll(), blender::ed::greasepencil::add_materials_to_map(), BKE_grease_pencil_object_material_index_get_by_name(), BKE_object_material_get_p(), BKE_object_material_index_get(), BKE_object_material_index_get_with_hint(), BKE_object_material_remap(), BKE_object_material_slot_find_index(), BKE_object_material_slot_remove(), blender::deg::DepsgraphNodeBuilder::build_object_data(), blender::deg::DepsgraphRelationBuilder::build_object_data(), blender::ui::greasepencil::eyedropper_add_material(), blender::modifier::greasepencil::get_grease_pencil_material_passes(), blender::ed::greasepencil::grease_pencil_separate_layer(), blender::ed::greasepencil::grease_pencil_separate_material(), blender::ed::greasepencil::grease_pencil_separate_selected(), blender::ed::greasepencil::material_isolate_exec(), material_slot_copy_exec(), mesh_separate_arrays(), mesh_separate_tagged(), blender::modify_stroke_by_material(), object_material_assign(), and versioning_eevee_shadow_settings().
Definition at line 1218 of file blenkernel/intern/material.cc.
References BKE_curve_material_remap(), BKE_grease_pencil_material_remap(), BKE_mesh_material_remap(), BKE_object_material_array_p(), BKE_object_material_len_p(), BLI_array_permute, BLI_assert, Object::data, ELEM, Object::mat, Object::matbits, OB_CURVES_LEGACY, OB_FONT, OB_GREASE_PENCIL, OB_MESH, OB_SURF, Object::totcol, and Object::type.
Referenced by material_slot_move_exec().
Calculate a material remapping from ob_src to ob_dst.
| remap_src_to_dst | An array the size of ob_src->totcol where index values are filled in which map to ob_dst materials. |
Definition at line 1248 of file blenkernel/intern/material.cc.
References BKE_object_material_get(), BLI_ghash_free(), BLI_ghash_lookup_p(), BLI_ghash_ptr_new_ex(), BLI_ghash_reinsert(), i, POINTER_AS_INT, POINTER_FROM_INT, and Object::totcol.
Referenced by BMD_mesh_intersection().
Definition at line 970 of file blenkernel/intern/material.cc.
References DEG_id_tag_update(), DEG_relations_tag_update(), i, Object::id, ID_RECALC_GEOMETRY, ID_RECALC_SYNC_TO_EVAL, id_us_min(), Object::mat, Object::matbits, MEM_calloc_arrayN(), MEM_freeN(), and Object::totcol.
Referenced by BKE_object_materials_sync_length(), BKE_objects_materials_sync_length_all(), and blender::ed::object::convert_mesh_to_grease_pencil().
| set_active | Set the newly added slot as active material slot of the object. Usually that is wanted when adding a material slot, so it's the default. |
Definition at line 1385 of file blenkernel/intern/material.cc.
References Object::actcol, BKE_MAT_ASSIGN_USERPREF, BKE_object_material_assign(), MAXMAT, and Object::totcol.
Referenced by blender::ed::greasepencil::bake_grease_pencil_animation_exec(), BKE_grease_pencil_object_material_new(), BKE_object_material_ensure(), grease_pencil_object_material_ensure_from_brush_pinned(), material_slot_add_exec(), and new_material_exec().
Definition at line 1358 of file blenkernel/intern/material.cc.
References BKE_object_material_array_p(), and BKE_object_material_len_p().
Referenced by BKE_grease_pencil_object_material_alt_ensure_from_brush().
Definition at line 1403 of file blenkernel/intern/material.cc.
References Object::actcol, BKE_displist_free(), BKE_object_material_array_p(), BKE_object_material_len_p(), CLOG_ERROR, Object::data, ELEM, ListBase::first, Material::id, id_us_min(), LOG, material_data_index_remove_id(), MEM_freeN(), OB_CURVES_LEGACY, OB_FONT, OB_GREASE_PENCIL, OB_MESH, OB_SURF, object_material_active_index_sanitize(), Main::objects, Object::runtime, Object::totcol, and Object::type.
Referenced by BKE_object_material_array_assign(), material_slot_remove_all_exec(), material_slot_remove_exec(), material_slot_remove_unused_exec(), and blender::ed::greasepencil::remove_unused_materials().
| bool BKE_object_material_slot_used | ( | Object * | object, |
| short | actcol ) |
Definition at line 473 of file blenkernel/intern/material.cc.
References BKE_curve_material_index_used(), BKE_grease_pencil_material_index_used(), BKE_mesh_material_index_used(), BKE_object_supports_material_slots(), GS, ID_CU_LEGACY, ID_GP, ID_MB, ID_ME, LISTBASE_FOREACH, ID::name, OB_DATA_SUPPORT_ID, and Object::particlesystem.
Referenced by blender::ed::greasepencil::grease_pencil_material_lock_unused_exec(), blender::ed::greasepencil::grease_pencil_separate_material(), material_slot_remove_unused_exec(), and blender::ed::greasepencil::remove_unused_materials().
| int BKE_object_material_used_with_fallback_eval | ( | const Object & | ob | ) |
Definition at line 849 of file blenkernel/intern/material.cc.
References BKE_id_material_used_with_fallback_eval(), data, and get_evaluated_object_data_with_materials().
Referenced by blender::draw::gpencil::gpencil_material_pool_create(), blender::draw::gpencil::gpencil_object_cache_add(), blender::eevee::MaterialModule::material_array_get(), blender::draw::mesh_render_data_create(), blender::workbench::Instance::mesh_sync(), and blender::draw::overlay::Prepass::object_sync().
Make the object's material array the same size as its data ID's material array.
Definition at line 1014 of file blenkernel/intern/material.cc.
References BKE_id_material_len_p(), BKE_id_material_resize(), BKE_object_material_resize(), Object::id, ID_TAG_MISSING, object_material_active_index_sanitize(), ID::tag, and Object::totcol.
Referenced by blender::ed::object::add_type_with_obdata(), BKE_mesh_assign_object(), BKE_object_material_from_eval_data(), Freestyle::BlenderStrokeRenderer::GenerateStrokeMesh(), libblock_remap_data_postprocess_obdata_relink(), loose_data_instantiate_obdata_process(), blender::ed::object::make_links_data_exec(), object_blend_read_after_liblink(), blender::ed::object::object_convert_exec(), object_material_assign(), and placeholders_ensure_valid().
Ensure that every object using this data has a material array of the correct size.
Definition at line 1036 of file blenkernel/intern/material.cc.
References BKE_id_material_len_p(), BKE_main_lock(), BKE_main_unlock(), BKE_object_material_resize(), BLI_assert, Object::data, ListBase::first, Object::id, ID::next, object_material_active_index_sanitize(), Main::objects, and ID::us.
Referenced by BKE_id_material_append(), BKE_id_material_assign(), BKE_id_material_clear(), BKE_id_material_pop(), ED_mesh_join_objects_exec(), mesh_separate_material_assign_mat_nr(), and object_material_assign().
Definition at line 1748 of file blenkernel/intern/material.cc.
References Material::nodetree, ntree_foreach_texnode_recursive(), PAINT_SLOT_COLOR_ATTRIBUTE, PAINT_SLOT_IMAGE, FindTexPaintNodeData::r_node, texpaint_slot_node_find_cb(), Material::texpaintslot, and Material::tot_slots.
Definition at line 1649 of file blenkernel/intern/material.cc.
References count, count_texture_nodes_recursive(), DEG_id_tag_update(), fill_texpaint_slots_recursive(), Material::id, ID_RECALC_SHADING, ID_RECALC_SYNC_TO_EVAL, IMAGEPAINT_MODE_IMAGE, ToolSettings::imapaint, material_paint_slot_filter(), MEM_calloc_arrayN(), MEM_SAFE_FREE, ImagePaintSettings::mode, blender::bke::node_get_active_paint_canvas(), Material::nodetree, Material::paint_active_slot, Material::paint_clone_slot, Material::texpaintslot, Scene::toolsettings, and Material::tot_slots.
Referenced by BKE_texpaint_slots_refresh_object(), ED_paint_proj_mesh_data_check(), paint_sample_color(), and proj_paint_add_slot().
Definition at line 1713 of file blenkernel/intern/material.cc.
References BKE_object_material_get(), BKE_texpaint_slot_refresh_cache(), i, and Object::totcol.
Referenced by ED_editors_init_for_undo(), ED_object_texture_paint_mode_enter_ex(), scene_changed(), and sculpt_update_object().
| void ramp_blend | ( | int | type, |
| float | r_col[3], | ||
| float | fac, | ||
| const float | col[3] ) |
| r_col | current value. |
| col | new value. |
| fac | Zero for is no change. |
Definition at line 1768 of file blenkernel/intern/material.cc.
References col, fabsf, hsv_to_rgb(), MA_RAMP_ADD, MA_RAMP_BLEND, MA_RAMP_BURN, MA_RAMP_COLOR, MA_RAMP_DARK, MA_RAMP_DIFF, MA_RAMP_DIV, MA_RAMP_DODGE, MA_RAMP_EXCLUSION, MA_RAMP_HUE, MA_RAMP_LIGHT, MA_RAMP_LINEAR, MA_RAMP_MULT, MA_RAMP_OVERLAY, MA_RAMP_SAT, MA_RAMP_SCREEN, MA_RAMP_SOFT, MA_RAMP_SUB, MA_RAMP_VAL, max_ff(), min_ff(), and rgb_to_hsv().
Referenced by blender::nodes::node_sh_mix_cc::MixColorFunction::call(), blender::nodes::node_shader_mix_rgb_cc::MixRGBFunction::call(), colorfn(), colorfn(), colorfn(), do_proc(), Freestyle_blendRamp(), and blender::nodes::node_composite_mixrgb_cc::node_build_multi_function().