|
Blender V5.0
|
#include <usd_reader_material.hh>
Public Member Functions | |
| USDMaterialReader (const USDImportParams ¶ms, Main &bmain) | |
| Material * | add_material (const pxr::UsdShadeMaterial &usd_material, bool read_usd_preview=true) const |
| void | import_usd_preview (Material *mtl, const pxr::UsdShadeMaterial &usd_material) const |
| ReportList * | reports () const |
Protected Member Functions | |
| void | import_usd_preview_nodes (Material *mtl, const pxr::UsdShadeMaterial &usd_material, const pxr::UsdShadeShader &usd_shader) const |
| void | set_principled_node_inputs (bNode *principled_node, bNodeTree *ntree, const pxr::UsdShadeShader &usd_shader) const |
| bool | set_displacement_node_inputs (bNodeTree *ntree, bNode *output, const pxr::UsdShadeShader &usd_shader) const |
| bool | set_node_input (const pxr::UsdShadeInput &usd_input, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx, const ExtraLinkInfo &extra={}) const |
| bool | follow_connection (const pxr::UsdShadeInput &usd_input, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx, const ExtraLinkInfo &extra={}) const |
| void | convert_usd_uv_texture (const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx, const ExtraLinkInfo &extra={}) const |
| void | convert_usd_transform_2d (const pxr::UsdShadeShader &usd_shader, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx) const |
| void | load_tex_image (const pxr::UsdShadeShader &usd_shader, bNode *tex_image, const ExtraLinkInfo &extra={}) const |
| void | convert_usd_primvar_reader_float2 (const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx) const |
| void | convert_usd_primvar_reader_generic (const pxr::UsdShadeShader &usd_shader, StringRef output_type, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx) const |
By default, the USDMaterialReader creates a Blender material with the same name as the USD material. If the USD material has a #UsdPreviewSurface source, the Blender material's viewport display color, roughness and metallic properties are set to the corresponding #UsdPreoviewSurface inputs.
If the Import USD Preview option is enabled, the current implementation converts #UsdPreviewSurface to Blender nodes as follows:
Limitations: arbitrary primvar readers or UsdTransform2d not yet supported. For #UsdUVTexture, only the file, st and #sourceColorSpace inputs are handled.
TODO(makowalski): Investigate adding support for converting additional shaders and inputs. Supporting certain types of inputs, such as texture scale and bias, will probably require creating Blender Group nodes with the corresponding inputs.
Definition at line 112 of file usd_reader_material.hh.
| blender::io::usd::USDMaterialReader::USDMaterialReader | ( | const USDImportParams & | params, |
| Main & | bmain ) |
Definition at line 455 of file usd_reader_material.cc.
References params.
| Material * blender::io::usd::USDMaterialReader::add_material | ( | const pxr::UsdShadeMaterial & | usd_material, |
| bool | read_usd_preview = true ) const |
Definition at line 460 of file usd_reader_material.cc.
References BKE_material_add(), Material::id, id_us_min(), import_usd_preview(), blender::bke::node_tree_add_tree_embedded(), Material::nodetree, and blender::io::usd::set_id_props_from_prim().
Referenced by blender::io::usd::utils::assign_materials(), and blender::io::usd::USDStageReader::import_all_materials().
|
protected |
This function creates a Blender UV Map node, under the simplifying assumption that UsdPrimvarReader_float2 shaders output UV coordinates.
Definition at line 1434 of file usd_reader_material.cc.
References add_node(), blender::io::usd::NodePlacementContext::cache_node(), blender::io::usd::NodePlacementContext::compute_node_loc(), blender::io::usd::NodePlacementContext::get_cached_node(), blender::StringRefBase::is_empty(), link_nodes(), SH_NODE_UVMAP, bNode::storage, STRNCPY(), NodeShaderUVMap::uv_map, and usdtokens::varname().
Referenced by follow_connection().
|
protected |
Definition at line 1493 of file usd_reader_material.cc.
References add_node(), blender::io::usd::NodePlacementContext::cache_node(), blender::io::usd::NodePlacementContext::compute_node_loc(), ELEM, blender::io::usd::NodePlacementContext::get_cached_node(), link_nodes(), NodeShaderAttribute::name, SH_NODE_ATTRIBUTE, bNode::storage, STRNCPY(), and usdtokens::varname().
Referenced by follow_connection().
|
protected |
Definition at line 1202 of file usd_reader_material.cc.
References add_node(), blender::io::usd::NodePlacementContext::cache_node(), blender::io::usd::NodePlacementContext::compute_node_loc(), copy_v3_v3(), bNode::custom1, blender::io::usd::NodePlacementContext::get_cached_node(), get_input(), get_input_socket(), usdtokens::in(), blender::StringRefBase::is_empty(), link_nodes(), M_PI, reports(), rot, usdtokens::rotation(), usdtokens::scale(), set_node_input(), SH_NODE_MAPPING, TEXMAP_TYPE_POINT, and usdtokens::translation().
Referenced by follow_connection().
|
protected |
Definition at line 1161 of file usd_reader_material.cc.
References usdtokens::a(), add_node(), blender::io::usd::NodePlacementContext::cache_node(), blender::io::usd::NodePlacementContext::compute_node_loc(), blender::io::usd::NodePlacementContext::get_cached_node(), blender::StringRefBase::is_empty(), link_nodes(), load_tex_image(), set_node_input(), SH_NODE_TEX_IMAGE, and usdtokens::st().
Referenced by follow_connection().
|
protected |
Follow the connected source of the USD input to create corresponding inputs for the given Blender node.
Definition at line 971 of file usd_reader_material.cc.
References blender::io::usd::add_lessthan(), blender::io::usd::add_normal_map(), blender::io::usd::add_oneminus(), blender::io::usd::add_scale_bias(), blender::io::usd::add_scale_bias_adjust(), blender::io::usd::add_separate_color(), CLOG_WARN, blender::io::usd::configure_displacement(), convert_usd_primvar_reader_float2(), convert_usd_primvar_reader_generic(), convert_usd_transform_2d(), convert_usd_uv_texture(), blender::StringRef::drop_prefix(), invert(), blender::StringRefBase::is_empty(), link_nodes(), LOG, blender::io::usd::IntermediateNode::node, blender::io::usd::node_graph_output_source(), blender::io::usd::ExtraLinkInfo::opacity_threshold, blender::StringRefBase::rfind(), blender::io::usd::IntermediateNode::sock_input_name, blender::io::usd::IntermediateNode::sock_output_name, blender::StringRefBase::startswith(), usdtokens::UsdPrimvarReader_float2(), usdtokens::UsdTransform2d(), and usdtokens::UsdUVTexture().
Referenced by set_node_input().
| void blender::io::usd::USDMaterialReader::import_usd_preview | ( | Material * | mtl, |
| const pxr::UsdShadeMaterial & | usd_material ) const |
Definition at line 485 of file usd_reader_material.cc.
References get_usd_preview_surface(), import_usd_preview_nodes(), and set_viewport_material_props().
Referenced by add_material(), and blender::io::usd::USDStageReader::call_material_import_hooks().
|
protected |
Create the Principled BSDF shader node network.
Definition at line 502 of file usd_reader_material.cc.
References add_node(), BKE_ntree_update_after_single_tree_change(), Material::displacement_method, Material::id, link_nodes(), MA_DISPLACEMENT_BOTH, MA_SURFACE_METHOD_FORWARD, needs_blend(), blender::bke::node_set_active(), blender::bke::node_tree_add_tree_embedded(), Material::nodetree, output, set_displacement_node_inputs(), set_principled_node_inputs(), SH_NODE_BSDF_PRINCIPLED, SH_NODE_OUTPUT_MATERIAL, and Material::surface_render_method.
Referenced by import_usd_preview().
|
protected |
Load the texture image node's texture from the path given by the USD shader's file input value.
Definition at line 1269 of file usd_reader_material.cc.
References add_udim_tiles(), usdtokens::auto_(), BKE_image_has_packedfile(), BKE_image_load_exists(), BKE_image_packfiles(), BLI_delete(), BLI_is_dir(), CLOG_WARN, COLOR_ROLE_DATA, COLOR_ROLE_DEFAULT_BYTE, Image::colorspace_settings, ELEM, blender::io::usd::ensure_usd_source_path_prop(), NodeTexImage::extension, usdtokens::file(), get_image_extension(), get_layer_handle(), get_source_color_space(), get_udim_tiles(), bNode::id, Image::id, ID_BLEND_PATH, IMB_colormanagement_role_colorspace_name_get(), IMB_colormanagement_srgb_colorspace_name_get(), blender::io::usd::import_asset(), blender::io::usd::ExtraLinkInfo::is_color_corrected, blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::io::usd::is_udim_path(), LOG, ColorManagedColorspaceSettings::name, usdtokens::RAW(), usdtokens::raw(), reports(), SH_NODE_TEX_IMAGE, usdtokens::sRGB(), bNode::storage, STRNCPY_UTF8, blender::io::usd::temp_textures_dir(), bNode::type_legacy, blender::io::usd::USD_TEX_IMPORT_NONE, blender::io::usd::USD_TEX_IMPORT_PACK, and blender::io::usd::USD_TEX_NAME_COLLISION_OVERWRITE.
Referenced by convert_usd_uv_texture().
|
inline |
Get the wmJobWorkerStatus-provided reports list pointer, to use with the BKE_report API.
Definition at line 126 of file usd_reader_material.hh.
Referenced by convert_usd_transform_2d(), and load_tex_image().
|
protected |
Definition at line 622 of file usd_reader_material.cc.
References add_node(), bNodeSocket::default_value, usdtokens::displacement(), blender::io::usd::ExtraLinkInfo::is_color_corrected, link_nodes(), blender::bke::node_find_socket(), output, set_node_input(), SH_NODE_DISPLACEMENT, and SOCK_IN.
Referenced by import_usd_preview_nodes().
|
protected |
Convert the given USD shader input to an input on the given Blender node.
Definition at line 665 of file usd_reader_material.cc.
References average(), blender::StringRefNull::c_str(), CLOG_ERROR, CLOG_WARN, copy_v2_v2(), copy_v3_v3(), bNodeSocket::default_value, follow_connection(), bNodeSocket::idname, LOG, blender::bke::node_find_socket(), SOCK_FLOAT, SOCK_IN, SOCK_RGBA, SOCK_VECTOR, and bNodeSocket::type.
Referenced by convert_usd_transform_2d(), convert_usd_uv_texture(), set_displacement_node_inputs(), and set_principled_node_inputs().
|
protected |
Definition at line 551 of file usd_reader_material.cc.
References usdtokens::clearcoat(), usdtokens::clearcoatRoughness(), bNodeSocket::default_value, usdtokens::diffuseColor(), usdtokens::emissiveColor(), get_opacity_threshold(), usdtokens::ior(), blender::io::usd::ExtraLinkInfo::is_color_corrected, usdtokens::metallic(), blender::bke::node_find_socket(), usdtokens::normal(), usdtokens::opacity(), blender::io::usd::ExtraLinkInfo::opacity_threshold, usdtokens::roughness(), set_node_input(), SOCK_IN, and usdtokens::specularColor().
Referenced by import_usd_preview_nodes().