Blender V4.3
usd_reader_material.cc File Reference
#include "usd_reader_material.hh"
#include "usd_asset_utils.hh"
#include "usd_reader_utils.hh"
#include "usd_utils.hh"
#include "BKE_appdir.hh"
#include "BKE_image.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_node.hh"
#include "BKE_node_tree_update.hh"
#include "BKE_report.hh"
#include "BLI_fileops.h"
#include "BLI_map.hh"
#include "BLI_math_vector.h"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLI_vector.hh"
#include "DNA_material_types.h"
#include <pxr/base/gf/vec3f.h>
#include <pxr/usd/ar/packageUtils.h>
#include <pxr/usd/usdShade/material.h>
#include <pxr/usd/usdShade/shader.h>
#include "CLG_log.h"

Go to the source code of this file.

Classes

struct  blender::io::usd::IntermediateNode
 

Namespaces

namespace  usdtokens
 
namespace  blender
 
namespace  blender::io
 
namespace  blender::io::usd
 

Functions

static const pxr::TfToken usdtokens::a ("a", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::b ("b", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::bias ("bias", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::clearcoat ("clearcoat", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::clearcoatRoughness ("clearcoatRoughness", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::diffuseColor ("diffuseColor", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::emissiveColor ("emissiveColor", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::file ("file", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::g ("g", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::ior ("ior", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::in ("in", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::metallic ("metallic", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::normal ("normal", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::occlusion ("occlusion", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::opacity ("opacity", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::opacityThreshold ("opacityThreshold", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::r ("r", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::result ("result", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::rgb ("rgb", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::rgba ("rgba", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::roughness ("roughness", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::scale ("scale", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::sourceColorSpace ("sourceColorSpace", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::specularColor ("specularColor", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::st ("st", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::varname ("varname", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::auto_ ("auto", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::sRGB ("sRGB", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::raw ("raw", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::RAW ("RAW", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::black ("black", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::clamp ("clamp", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::repeat ("repeat", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::mirror ("mirror", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::wrapS ("wrapS", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::wrapT ("wrapT", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::rotation ("rotation", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::translation ("translation", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::UsdPreviewSurface ("UsdPreviewSurface", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::UsdPrimvarReader_float2 ("UsdPrimvarReader_float2", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::UsdUVTexture ("UsdUVTexture", pxr::TfToken::Immortal)
 
static const pxr::TfToken usdtokens::UsdTransform2d ("UsdTransform2d", pxr::TfToken::Immortal)
 
static std::string get_key (const pxr::UsdShadeShader &usd_shader, const char *tag)
 
static bNodeget_cached_node (const ShaderToNodeMap &node_cache, const pxr::UsdShadeShader &usd_shader, const char *tag=nullptr)
 
static void cache_node (ShaderToNodeMap &node_cache, const pxr::UsdShadeShader &usd_shader, bNode *node, const char *tag=nullptr)
 
static bNodeadd_node (const bContext *C, bNodeTree *ntree, const int type, const float locx, const float locy)
 
static void link_nodes (bNodeTree *ntree, bNode *source, const char *sock_out, bNode *dest, const char *sock_in)
 
static pxr::SdfLayerHandle get_layer_handle (const pxr::UsdAttribute &attribute)
 
static blender::Vector< intget_udim_tiles (const std::string &file_path)
 
static void add_udim_tiles (Image *image, const blender::Vector< int > &indices)
 
static bool needs_blend (const pxr::UsdShadeShader &usd_shader)
 
static float get_opacity_threshold (const pxr::UsdShadeShader &usd_shader, float default_value=0.0f)
 
static pxr::TfToken get_source_color_space (const pxr::UsdShadeShader &usd_shader)
 
static int get_image_extension (const pxr::UsdShadeShader &usd_shader, const int default_value)
 
static bool get_usd_preview_surface (const pxr::UsdShadeMaterial &usd_material, pxr::UsdShadeShader &r_preview_surface)
 
static void set_viewport_material_props (Material *mtl, const pxr::UsdShadeShader &usd_preview)
 
static pxr::UsdShadeInput get_input (const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &input_name)
 
static bNodeSocketget_input_socket (bNode *node, const char *identifier, ReportList *reports)
 
static IntermediateNode blender::io::usd::add_normal_map (bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
 
static IntermediateNode blender::io::usd::add_scale_bias (const pxr::UsdShadeShader &usd_shader, bNodeTree *ntree, int column, bool feeds_normal_map, NodePlacementContext *r_ctx)
 
static IntermediateNode blender::io::usd::add_scale_bias_adjust (bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
 
static IntermediateNode blender::io::usd::add_separate_color (const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
 
static IntermediateNode blender::io::usd::add_lessthan (bNodeTree *ntree, float threshold, int column, NodePlacementContext *r_ctx)
 
static IntermediateNode blender::io::usd::add_oneminus (bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
 
void blender::io::usd::build_material_map (const Main *bmain, blender::Map< std::string, Material * > *r_mat_map)
 
Materialblender::io::usd::find_existing_material (const pxr::SdfPath &usd_mat_path, const USDImportParams &params, const blender::Map< std::string, Material * > &mat_map, const blender::Map< std::string, std::string > &usd_path_to_mat_name)
 

Variables

static CLG_LogRef LOG = {"io.usd"}
 

Function Documentation

◆ add_node()

◆ add_udim_tiles()

static void add_udim_tiles ( Image * image,
const blender::Vector< int > & indices )
static

◆ cache_node()

◆ get_cached_node()

static bNode * get_cached_node ( const ShaderToNodeMap & node_cache,
const pxr::UsdShadeShader & usd_shader,
const char * tag = nullptr )
static

◆ get_image_extension()

◆ get_input()

◆ get_input_socket()

static bNodeSocket * get_input_socket ( bNode * node,
const char * identifier,
ReportList * reports )
static

◆ get_key()

static std::string get_key ( const pxr::UsdShadeShader & usd_shader,
const char * tag )
static

Generate a key for caching a Blender node created for a given USD shader by returning the shader prim path with an optional tag suffix. The tag can be specified in order to generate a unique key when more than one Blender node is created for the USD shader.

Definition at line 101 of file usd_reader_material.cc.

Referenced by cache_node(), and get_cached_node().

◆ get_layer_handle()

static pxr::SdfLayerHandle get_layer_handle ( const pxr::UsdAttribute & attribute)
static

◆ get_opacity_threshold()

static float get_opacity_threshold ( const pxr::UsdShadeShader & usd_shader,
float default_value = 0.0f )
static

◆ get_source_color_space()

static pxr::TfToken get_source_color_space ( const pxr::UsdShadeShader & usd_shader)
static

◆ get_udim_tiles()

◆ get_usd_preview_surface()

static bool get_usd_preview_surface ( const pxr::UsdShadeMaterial & usd_material,
pxr::UsdShadeShader & r_preview_surface )
static

◆ link_nodes()

◆ needs_blend()

static bool needs_blend ( const pxr::UsdShadeShader & usd_shader)
static

◆ set_viewport_material_props()

static void set_viewport_material_props ( Material * mtl,
const pxr::UsdShadeShader & usd_preview )
static

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"io.usd"}
static

Definition at line 35 of file usd_reader_material.cc.

Referenced by link_nodes().