36#include <pxr/base/gf/vec3f.h>
37#include <pxr/usd/ar/packageUtils.h>
38#include <pxr/usd/usdShade/material.h>
39#include <pxr/usd/usdShade/shader.h>
47static const pxr::TfToken
a(
"a", pxr::TfToken::Immortal);
48static const pxr::TfToken
b(
"b", pxr::TfToken::Immortal);
49static const pxr::TfToken
bias(
"bias", pxr::TfToken::Immortal);
50static const pxr::TfToken
clearcoat(
"clearcoat", pxr::TfToken::Immortal);
52static const pxr::TfToken
diffuseColor(
"diffuseColor", pxr::TfToken::Immortal);
53static const pxr::TfToken
displacement(
"displacement", pxr::TfToken::Immortal);
54static const pxr::TfToken
emissiveColor(
"emissiveColor", pxr::TfToken::Immortal);
55static const pxr::TfToken
file(
"file", pxr::TfToken::Immortal);
56static const pxr::TfToken
g(
"g", pxr::TfToken::Immortal);
57static const pxr::TfToken
ior(
"ior", pxr::TfToken::Immortal);
58static const pxr::TfToken
in(
"in", pxr::TfToken::Immortal);
59static const pxr::TfToken
metallic(
"metallic", pxr::TfToken::Immortal);
60static const pxr::TfToken
normal(
"normal", pxr::TfToken::Immortal);
61static const pxr::TfToken
occlusion(
"occlusion", pxr::TfToken::Immortal);
62static const pxr::TfToken
opacity(
"opacity", pxr::TfToken::Immortal);
64static const pxr::TfToken
r(
"r", pxr::TfToken::Immortal);
65static const pxr::TfToken
rgb(
"rgb", pxr::TfToken::Immortal);
66static const pxr::TfToken
rgba(
"rgba", pxr::TfToken::Immortal);
67static const pxr::TfToken
roughness(
"roughness", pxr::TfToken::Immortal);
68static const pxr::TfToken
scale(
"scale", pxr::TfToken::Immortal);
70static const pxr::TfToken
specularColor(
"specularColor", pxr::TfToken::Immortal);
71static const pxr::TfToken
st(
"st", pxr::TfToken::Immortal);
72static const pxr::TfToken
varname(
"varname", pxr::TfToken::Immortal);
75static const pxr::TfToken
auto_(
"auto", pxr::TfToken::Immortal);
76static const pxr::TfToken
sRGB(
"sRGB", pxr::TfToken::Immortal);
77static const pxr::TfToken
raw(
"raw", pxr::TfToken::Immortal);
78static const pxr::TfToken
RAW(
"RAW", pxr::TfToken::Immortal);
81static const pxr::TfToken
black(
"black", pxr::TfToken::Immortal);
82static const pxr::TfToken
clamp(
"clamp", pxr::TfToken::Immortal);
83static const pxr::TfToken
repeat(
"repeat", pxr::TfToken::Immortal);
84static const pxr::TfToken
mirror(
"mirror", pxr::TfToken::Immortal);
85static const pxr::TfToken
wrapS(
"wrapS", pxr::TfToken::Immortal);
86static const pxr::TfToken
wrapT(
"wrapT", pxr::TfToken::Immortal);
89static const pxr::TfToken
rotation(
"rotation", pxr::TfToken::Immortal);
90static const pxr::TfToken
translation(
"translation", pxr::TfToken::Immortal);
95 pxr::TfToken::Immortal);
96static const pxr::TfToken
UsdUVTexture(
"UsdUVTexture", pxr::TfToken::Immortal);
97static const pxr::TfToken
UsdTransform2d(
"UsdTransform2d", pxr::TfToken::Immortal);
120 if (!source_socket) {
141 for (
const auto &PropertySpec : attribute.GetPropertyStack(pxr::UsdTimeCode::EarliestTime())) {
142 if (PropertySpec->HasDefaultValue() ||
143 PropertySpec->GetLayer()->GetNumTimeSamplesForPath(PropertySpec->GetPath()) > 0)
145 return PropertySpec->GetLayer();
149 return pxr::SdfLayerHandle();
157 STRNCPY(base_udim_path, file_path.c_str());
163 int tile_start, tile_range;
168 udim_tiles.
append(tile_number);
185 bool remove_first =
true;
187 for (
int tile_number :
indices) {
190 remove_first =
false;
211 if (opacity_input.HasConnectedSource()) {
216 if (opacity_input.GetAttr().HasAuthoredValue() && opacity_input.GetAttr().Get(&val)) {
217 float opacity = val.Get<
float>();
229 float default_value = 0.0f)
232 return default_value;
237 if (!opacity_threshold_input) {
238 return default_value;
242 if (opacity_threshold_input.GetAttr().HasAuthoredValue() &&
243 opacity_threshold_input.GetAttr().Get(&val))
245 return val.Get<
float>();
248 return default_value;
254 return pxr::TfToken();
259 if (!color_space_input) {
260 return pxr::TfToken();
263 pxr::VtValue color_space_val;
264 if (color_space_input.Get(&color_space_val) && color_space_val.IsHolding<pxr::TfToken>()) {
265 return color_space_val.UncheckedGet<pxr::TfToken>();
268 return pxr::TfToken();
280 return default_value;
283 pxr::VtValue wrap_input_val;
284 if (!(wrap_input.Get(&wrap_input_val) && wrap_input_val.IsHolding<pxr::TfToken>())) {
285 return default_value;
288 pxr::TfToken wrap_val = wrap_input_val.UncheckedGet<pxr::TfToken>();
306 return default_value;
313 pxr::UsdShadeShader &r_preview_surface)
319 if (pxr::UsdShadeShader surf_shader = usd_material.ComputeSurfaceSource()) {
321 pxr::TfToken shader_id;
323 r_preview_surface = surf_shader;
335 if (!(mtl && usd_preview)) {
341 if (diffuse_color_input.GetAttr().HasAuthoredValue() &&
342 diffuse_color_input.GetAttr().Get(&val) && val.IsHolding<pxr::GfVec3f>())
344 pxr::GfVec3f color = val.UncheckedGet<pxr::GfVec3f>();
355 if (metallic_input.GetAttr().HasAuthoredValue() && metallic_input.GetAttr().Get(&val) &&
356 val.IsHolding<
float>())
358 mtl->
metallic = val.UncheckedGet<
float>();
364 if (roughness_input.GetAttr().HasAuthoredValue() && roughness_input.GetAttr().Get(&val) &&
365 val.IsHolding<
float>())
367 mtl->
roughness = val.UncheckedGet<
float>();
372static pxr::UsdShadeInput
get_input(
const pxr::UsdShadeShader &usd_shader,
373 const pxr::TfToken &input_name)
375 pxr::UsdShadeInput
input = usd_shader.GetInput(input_name);
380 for (
const pxr::UsdShadeConnectionSourceInfo &source_info :
input.GetConnectedSources()) {
381 pxr::UsdShadeShader shader = pxr::UsdShadeShader(source_info.source.GetPrim());
382 pxr::UsdShadeInput secondary_input = shader.GetInput(source_info.sourceName);
383 if (secondary_input) {
384 input = secondary_input;
401 "%s: Error: Couldn't get input socket %s for node %s",
434 std::string key = usd_shader.GetPath().GetAsString();
456 : params_(
params), bmain_(bmain)
461 const bool read_usd_preview)
const
467 std::string mtl_name = usd_material.GetPrim().GetName().GetString();
472 &bmain_, &mtl->
id,
"USD Material Node Tree",
"ShaderNodeTree");
475 if (read_usd_preview) {
486 const pxr::UsdShadeMaterial &usd_material)
const
490 pxr::UsdShadeShader usd_preview;
496 if (params_.import_usd_preview) {
503 const pxr::UsdShadeMaterial &usd_material,
504 const pxr::UsdShadeShader &usd_shader)
const
506 if (!(mtl && usd_shader)) {
517 nullptr, &mtl->
id,
"Shader Nodetree",
"ShaderNodeTree");
533 if (pxr::UsdShadeShader disp_shader = usd_material.ComputeDisplacementSource()) {
544 if (params_.set_material_blend) {
553 const pxr::UsdShadeShader &usd_shader)
const
568 set_node_input(diffuse_input, principled,
"Base Color", ntree, column, context, extra);
571 float emission_strength = 0.0f;
576 emissive_input, principled,
"Emission Color", ntree, column, context, extra))
578 emission_strength = 1.0f;
583 *principled,
SOCK_IN,
"Emission Strength");
587 set_node_input(specular_input, principled,
"Specular Tint", ntree, column, context);
591 set_node_input(metallic_input, principled,
"Metallic", ntree, column, context);
595 set_node_input(roughness_input, principled,
"Roughness", ntree, column, context);
599 set_node_input(coat_input, principled,
"Coat Weight", ntree, column, context);
604 set_node_input(coat_roughness_input, principled,
"Coat Roughness", ntree, column, context);
610 set_node_input(opacity_input, principled,
"Alpha", ntree, column, context, extra);
613 if (pxr::UsdShadeInput ior_input = usd_shader.GetInput(
usdtokens::ior)) {
614 set_node_input(ior_input, principled,
"IOR", ntree, column, context);
618 set_node_input(normal_input, principled,
"Normal", ntree, column, context);
624 const pxr::UsdShadeShader &usd_shader)
const
628 if (!displacement_input) {
644 set_node_input(displacement_input, displacement_node, height, ntree, column, context, extra);
649 if (!displacement_input.HasConnectedSource()) {
652 *displacement_node,
SOCK_IN,
"Midlevel");
661 link_nodes(ntree, displacement_node,
"Displacement",
output,
"Displacement");
673 if (!(usd_input && dest_node)) {
677 if (usd_input.HasConnectedSource()) {
680 return follow_connection(usd_input, dest_node, dest_socket_name, ntree, column, ctx, extra);
687 CLOG_ERROR(&
LOG,
"Couldn't get destination node socket %s", dest_socket_name.
c_str());
692 if (!usd_input.Get(&val)) {
694 "Couldn't get value for usd shader input %s",
695 usd_input.GetPrim().GetPath().GetAsString().c_str());
699 switch (sock->
type) {
701 if (val.IsHolding<
float>()) {
705 else if (val.IsHolding<pxr::GfVec3f>()) {
706 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
707 float average = (v3f[0] + v3f[1] + v3f[2]) / 3.0f;
713 if (val.IsHolding<pxr::GfVec3f>()) {
714 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
720 if (val.IsHolding<pxr::GfVec3f>()) {
721 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
725 else if (val.IsHolding<pxr::GfVec2f>()) {
726 pxr::GfVec2f v2f = val.UncheckedGet<pxr::GfVec2f>();
733 "Unexpected type %s for destination node socket %s",
735 dest_socket_name.
c_str());
765 bool feeds_normal_map,
771 pxr::GfVec4f scale(1.0f, 1.0f, 1.0f, 1.0f);
772 pxr::GfVec4f bias(0.0f, 0.0f, 0.0f, 0.0f);
775 if (scale_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
776 scale = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
778 if (bias_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
779 bias = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
783 if (scale == pxr::GfVec4f{1.0f, 1.0f, 1.0f, 1.0f} &&
784 bias == pxr::GfVec4f{0.0f, 0.0f, 0.0f, 0.0f})
790 if (feeds_normal_map && (scale[0] == 2.0f && scale[1] == 2.0f && scale[2] == 2.0f) &&
791 (bias[0] == -1.0f && bias[1] == -1.0f && bias[2] == -1.0f))
810 scale_bias.
node = node;
845 const pxr::TfToken &usd_source_name,
865 separate_color.
node = node;
879 return separate_color;
924 pxr::GfVec4f scale(1.0f, 1.0f, 1.0f, 1.0f);
925 pxr::GfVec4f bias(0.0f, 0.0f, 0.0f, 0.0f);
928 if (scale_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
929 scale = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
931 if (bias_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
932 bias = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
935 const float scale_avg = (scale[0] + scale[1] + scale[2]) / 3.0f;
936 const float bias_avg = (bias[0] + bias[1] + bias[2]) / 3.0f;
945 const pxr::TfToken &output_name)
948 pxr::UsdShadeOutput
output = node_graph.GetOutput(output_name);
950 return pxr::UsdShadeShader();
953 pxr::UsdShadeAttributeVector attrs = pxr::UsdShadeUtils::GetValueProducingAttributes(
output);
955 return pxr::UsdShadeShader();
958 pxr::UsdAttribute attr = attrs[0];
960 std::pair<pxr::TfToken, pxr::UsdShadeAttributeType> name_and_type =
961 pxr::UsdShadeUtils::GetBaseNameAndType(attr.GetName());
963 pxr::UsdShadeShader shader(attr.GetPrim());
964 if (name_and_type.second != pxr::UsdShadeAttributeType::Output || !shader) {
965 return pxr::UsdShadeShader();
979 if (!(usd_input && dest_node && !dest_socket_name.
is_empty() && ntree)) {
983 pxr::UsdShadeConnectableAPI source;
984 pxr::TfToken source_name;
985 pxr::UsdShadeAttributeType source_type;
987 usd_input.GetConnectedSource(&source, &source_name, &source_type);
993 const pxr::UsdPrim source_prim = source.GetPrim();
994 pxr::UsdShadeShader source_shader;
995 if (source_prim.IsA<pxr::UsdShadeShader>()) {
996 source_shader = pxr::UsdShadeShader(source_prim);
998 else if (source_prim.IsA<pxr::UsdShadeNodeGraph>()) {
999 pxr::UsdShadeNodeGraph node_graph(source_prim);
1003 if (!source_shader) {
1007 pxr::TfToken shader_id;
1008 if (!source_shader.GetShaderId(&shader_id)) {
1010 "Couldn't get shader id for source shader %s",
1011 source_shader.GetPath().GetAsString().c_str());
1021 const bool is_normal_map = dest_socket_name ==
"Normal";
1022 if (is_normal_map) {
1029 source_shader, source_name, ntree, column + shift, ctx);
1030 if (separate_color.
node) {
1036 if (dest_socket_name ==
"Height") {
1040 scale_bias =
add_scale_bias(source_shader, ntree, column + shift, is_normal_map, ctx);
1045 bNode *target_node = dest_node;
1047 if (normal_map.
node) {
1050 if (scale_bias.
node) {
1063 target_node = scale_bias.
node;
1068 target_node = normal_map.
node;
1074 else if (scale_bias.
node) {
1075 if (separate_color.
node) {
1077 separate_color.
node,
1084 separate_color.
node,
1091 target_node = scale_bias.
node;
1095 else if (separate_color.
node) {
1098 separate_color.
node,
1103 target_node = separate_color.
node;
1116 if (separate_color.
node) {
1118 separate_color.
node,
1124 target_node = lessthan.
node;
1140 source_shader, source_name, dest_node, dest_socket_name, ntree, column + 1, ctx);
1147 StringRef shader_id_name(shader_id.GetString());
1148 if (shader_id_name.
startswith(
"UsdPrimvarReader_")) {
1150 if (type_offset >= 0) {
1153 source_shader, output_type, dest_node, dest_socket_name, ntree, column + 1, ctx);
1162 const pxr::TfToken &usd_source_name,
1170 if (!usd_shader || !dest_node || !ntree || dest_socket_name.
is_empty()) {
1176 if (tex_image ==
nullptr) {
1194 link_nodes(ntree, tex_image, source_socket_name, dest_node, dest_socket_name);
1197 if (pxr::UsdShadeInput st_input = usd_shader.GetInput(
usdtokens::st)) {
1198 set_node_input(st_input, tex_image,
"Vector", ntree, column, ctx);
1209 if (!usd_shader || !dest_node || !ntree || dest_socket_name.
is_empty()) {
1215 if (mapping ==
nullptr) {
1229 if (scale_input.Get(&val) && val.CanCast<pxr::GfVec2f>()) {
1230 pxr::GfVec2f scale_val = val.Cast<pxr::GfVec2f>().UncheckedGet<pxr::GfVec2f>();
1231 float scale[3] = {scale_val[0], scale_val[1], 1.0f};
1240 if (trans_input.Get(&val) && val.CanCast<pxr::GfVec2f>()) {
1241 pxr::GfVec2f trans_val = val.Cast<pxr::GfVec2f>().UncheckedGet<pxr::GfVec2f>();
1242 float location[3] = {trans_val[0], trans_val[1], 0.0f};
1251 if (rot_input.Get(&val) && val.CanCast<
float>()) {
1252 float rot_val = val.Cast<
float>().UncheckedGet<float>() *
M_PI / 180.0f;
1253 float rot[3] = {0.0f, 0.0f, rot_val};
1261 link_nodes(ntree, mapping,
"Vector", dest_node, dest_socket_name);
1264 if (pxr::UsdShadeInput in_input = usd_shader.GetInput(
usdtokens::in)) {
1282 "Couldn't get file input property for USD shader %s",
1283 usd_shader.GetPath().GetAsString().c_str());
1289 if (file_input.HasConnectedSource()) {
1290 pxr::UsdShadeConnectableAPI source;
1291 pxr::TfToken source_name;
1292 pxr::UsdShadeAttributeType source_type;
1294 if (file_input.GetConnectedSource(&source, &source_name, &source_type)) {
1295 file_input = source.GetInput(source_name);
1299 "Couldn't get connected source for file input %s (%s)\n",
1300 file_input.GetPrim().GetPath().GetText(),
1301 file_input.GetFullName().GetText());
1305 pxr::VtValue file_val;
1306 if (!file_input.Get(&file_val) || !file_val.IsHolding<pxr::SdfAssetPath>()) {
1308 "Couldn't get file input value for USD shader %s",
1309 usd_shader.GetPath().GetAsString().c_str());
1313 const pxr::SdfAssetPath &asset_path = file_val.UncheckedGet<pxr::SdfAssetPath>();
1314 std::string file_path = asset_path.GetResolvedPath();
1316 if (file_path.empty()) {
1318 file_path = asset_path.GetAssetPath();
1322 if (pxr::SdfLayerHandle layer_handle =
get_layer_handle(file_input.GetAttr())) {
1323 file_path = layer_handle->ComputeAbsolutePath(file_path);
1328 if (file_path.empty()) {
1330 "Couldn't resolve image asset '%s' for Texture Image node",
1331 asset_path.GetAssetPath().c_str());
1336 const bool is_relative = pxr::ArIsPackageRelativePath(file_path);
1337 const bool import_textures = params_.import_textures_mode !=
USD_TEX_IMPORT_NONE && is_relative;
1339 std::string imported_file_source_path;
1341 if (import_textures) {
1342 imported_file_source_path = file_path;
1348 params_.import_textures_dir;
1353 params_.tex_name_collision_mode;
1366 const char *im_file = file_path.c_str();
1369 CLOG_WARN(&
LOG,
"Couldn't open image file '%s' for Texture Image node", im_file);
1377 tex_image->
id = &image->
id;
1386 if (color_space.IsEmpty()) {
1387 color_space = file_input.GetAttr().GetColorSpace();
1390 if (color_space.IsEmpty()) {
1420 if (import_textures && imported_file_source_path != file_path) {
1435 const pxr::TfToken & ,
1442 if (!usd_shader || !dest_node || !ntree || dest_socket_name.
is_empty()) {
1448 if (uv_map ==
nullptr) {
1462 if (varname_input) {
1463 for (
const pxr::UsdShadeConnectionSourceInfo &source_info :
1464 varname_input.GetConnectedSources())
1466 pxr::UsdShadeShader shader = pxr::UsdShadeShader(source_info.source.GetPrim());
1467 pxr::UsdShadeInput secondary_varname_input = shader.GetInput(source_info.sourceName);
1468 if (secondary_varname_input) {
1469 varname_input = secondary_varname_input;
1475 if (varname_input) {
1476 pxr::VtValue varname_val;
1479 if (varname_input.Get(&varname_val) && varname_val.CanCastToTypeid(
typeid(std::string))) {
1480 std::string varname = varname_val.Cast<std::string>().Get<std::string>();
1481 if (!varname.empty()) {
1490 link_nodes(ntree, uv_map,
"UV", dest_node, dest_socket_name);
1501 if (!usd_shader || !dest_node || !ntree) {
1507 if (attribute ==
nullptr) {
1521 if (varname_input) {
1522 for (
const pxr::UsdShadeConnectionSourceInfo &source_info :
1523 varname_input.GetConnectedSources())
1525 pxr::UsdShadeShader shader = pxr::UsdShadeShader(source_info.source.GetPrim());
1526 pxr::UsdShadeInput secondary_varname_input = shader.GetInput(source_info.sourceName);
1527 if (secondary_varname_input) {
1528 varname_input = secondary_varname_input;
1534 if (varname_input) {
1535 pxr::VtValue varname_val;
1538 if (varname_input.Get(&varname_val) && varname_val.CanCastToTypeid(
typeid(std::string))) {
1539 std::string varname = varname_val.Cast<std::string>().Get<std::string>();
1540 if (!varname.empty()) {
1549 if (
ELEM(output_type,
"float",
"int")) {
1550 link_nodes(ntree, attribute,
"Fac", dest_node, dest_socket_name);
1552 else if (
ELEM(output_type,
"float3",
"float4")) {
1553 link_nodes(ntree, attribute,
"Color", dest_node, dest_socket_name);
1555 else if (
ELEM(output_type,
"vector",
"normal",
"point")) {
1556 link_nodes(ntree, attribute,
"Vector", dest_node, dest_socket_name);
1565 r_mat_map.
add_new(material->id.name + 2, material);
void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
Image * BKE_image_load_exists(Main *bmain, const char *filepath, bool *r_exists=nullptr)
bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, int *r_tile_range)
bool BKE_image_has_packedfile(const Image *image)
ImageTile * BKE_image_add_tile(Image *ima, int tile_number, const char *label)
bool BKE_image_remove_tile(Image *ima, ImageTile *tile)
General operations, lookup, etc. for materials.
Material * BKE_material_add(Main *bmain, const char *name)
#define SH_NODE_TEX_IMAGE
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_SEPARATE_COLOR
#define SH_NODE_VECTOR_MATH
#define SH_NODE_NORMAL_MAP
#define SH_NODE_OUTPUT_MATERIAL
#define SH_NODE_DISPLACEMENT
#define SH_NODE_ATTRIBUTE
void BKE_ntree_update_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams ¶ms={})
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert_msg(a, msg)
File and directory operations.
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
char * STRNCPY(char(&dst)[N], const char *src)
#define STRNCPY_UTF8(dst, src)
#define POINTER_AS_INT(i)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define ID_BLEND_PATH(_bmain, _id)
@ MA_SURFACE_METHOD_FORWARD
@ NODE_VECTOR_MATH_MULTIPLY_ADD
@ SHD_IMAGE_EXTENSION_MIRROR
@ SHD_IMAGE_EXTENSION_CLIP
@ SHD_IMAGE_EXTENSION_REPEAT
@ SHD_IMAGE_EXTENSION_EXTEND
@ COLOR_ROLE_DEFAULT_BYTE
const char * IMB_colormanagement_srgb_colorspace_name_get()
const char * IMB_colormanagement_role_colorspace_name_get(int role)
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
constexpr int64_t rfind(char c, int64_t pos=INT64_MAX) const
constexpr bool is_empty() const
constexpr bool startswith(StringRef prefix) const
constexpr const char * c_str() const
constexpr StringRef drop_prefix(int64_t n) const
void append(const T &value)
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_transform_2d(const pxr::UsdShadeShader &usd_shader, bNode *dest_node, const StringRefNull dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext &ctx) const
Material * add_material(const pxr::UsdShadeMaterial &usd_material, bool read_usd_preview=true) const
void import_usd_preview_nodes(Material *mtl, const pxr::UsdShadeMaterial &usd_material, const pxr::UsdShadeShader &usd_shader) const
USDMaterialReader(const USDImportParams ¶ms, Main &bmain)
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
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
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
ReportList * reports() 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 set_principled_node_inputs(bNode *principled_node, bNodeTree *ntree, const pxr::UsdShadeShader &usd_shader) const
void import_usd_preview(Material *mtl, const pxr::UsdShadeMaterial &usd_material) const
void load_tex_image(const pxr::UsdShadeShader &usd_shader, bNode *tex_image, const ExtraLinkInfo &extra={}) const
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
const ccl_global KernelWorkTile * tile
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
int node_count_socket_links(const bNodeTree &ntree, const bNodeSocket &sock)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
void node_set_active(bNodeTree &ntree, bNode &node)
const char * temp_textures_dir()
static IntermediateNode add_separate_color(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNodeTree *ntree, int column, NodePlacementContext &ctx)
Map< std::string, bNode * > ShaderToNodeMap
bool is_udim_path(const std::string &path)
static IntermediateNode add_scale_bias_adjust(bNodeTree *ntree, int column, NodePlacementContext &ctx)
static IntermediateNode add_scale_bias(const pxr::UsdShadeShader &usd_shader, bNodeTree *ntree, int column, bool feeds_normal_map, NodePlacementContext &ctx)
void build_material_map(const Main *bmain, blender::Map< std::string, Material * > &r_mat_map)
Material * find_existing_material(const pxr::SdfPath &usd_mat_path, const USDImportParams ¶ms, const blender::Map< std::string, Material * > &mat_map, const blender::Map< pxr::SdfPath, Material * > &usd_path_to_mat)
static pxr::UsdShadeShader node_graph_output_source(const pxr::UsdShadeNodeGraph &node_graph, const pxr::TfToken &output_name)
@ USD_TEX_NAME_COLLISION_OVERWRITE
static IntermediateNode add_oneminus(bNodeTree *ntree, int column, NodePlacementContext &ctx)
static IntermediateNode add_normal_map(bNodeTree *ntree, int column, NodePlacementContext &ctx)
void set_id_props_from_prim(ID *id, const pxr::UsdPrim &prim, const eUSDPropertyImportMode property_import_mode, const pxr::UsdTimeCode time_code)
void ensure_usd_source_path_prop(const std::string &path, ID *id)
@ USD_MTL_NAME_COLLISION_MAKE_UNIQUE
std::string import_asset(const std::string &src, const char *import_dir, eUSDTexNameCollisionMode name_collision_mode, ReportList *reports)
static void configure_displacement(const pxr::UsdShadeShader &usd_shader, bNode *displacement_node)
static IntermediateNode add_lessthan(bNodeTree *ntree, float threshold, int column, NodePlacementContext &ctx)
VecBase< float, 2 > float2
static const pxr::TfToken sRGB("sRGB", pxr::TfToken::Immortal)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
static const pxr::TfToken bias("bias", pxr::TfToken::Immortal)
static const pxr::TfToken opacity("opacity", pxr::TfToken::Immortal)
static const pxr::TfToken UsdPreviewSurface("UsdPreviewSurface", pxr::TfToken::Immortal)
static const pxr::TfToken sourceColorSpace("sourceColorSpace", pxr::TfToken::Immortal)
static const pxr::TfToken clearcoat("clearcoat", pxr::TfToken::Immortal)
static const pxr::TfToken varname("varname", pxr::TfToken::Immortal)
static const pxr::TfToken emissiveColor("emissiveColor", pxr::TfToken::Immortal)
static const pxr::TfToken RAW("RAW", pxr::TfToken::Immortal)
static const pxr::TfToken r("r", pxr::TfToken::Immortal)
static const pxr::TfToken UsdUVTexture("UsdUVTexture", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken rotation("rotation", pxr::TfToken::Immortal)
static const pxr::TfToken ior("ior", pxr::TfToken::Immortal)
static const pxr::TfToken rgba("rgba", pxr::TfToken::Immortal)
static const pxr::TfToken translation("translation", pxr::TfToken::Immortal)
static const pxr::TfToken raw("raw", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
static const pxr::TfToken in("in", pxr::TfToken::Immortal)
static const pxr::TfToken occlusion("occlusion", pxr::TfToken::Immortal)
static const pxr::TfToken auto_("auto", pxr::TfToken::Immortal)
static const pxr::TfToken clearcoatRoughness("clearcoatRoughness", pxr::TfToken::Immortal)
static const pxr::TfToken scale("scale", pxr::TfToken::Immortal)
static const pxr::TfToken file("file", pxr::TfToken::Immortal)
static const pxr::TfToken mirror("mirror", pxr::TfToken::Immortal)
static const pxr::TfToken opacityThreshold("opacityThreshold", pxr::TfToken::Immortal)
static const pxr::TfToken normal("normal", pxr::TfToken::Immortal)
static const pxr::TfToken clamp("clamp", pxr::TfToken::Immortal)
static const pxr::TfToken black("black", pxr::TfToken::Immortal)
static const pxr::TfToken UsdTransform2d("UsdTransform2d", pxr::TfToken::Immortal)
static const pxr::TfToken displacement("displacement", pxr::TfToken::Immortal)
static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal)
static const pxr::TfToken repeat("repeat", pxr::TfToken::Immortal)
static const pxr::TfToken metallic("metallic", pxr::TfToken::Immortal)
static const pxr::TfToken diffuseColor("diffuseColor", pxr::TfToken::Immortal)
static const pxr::TfToken wrapS("wrapS", pxr::TfToken::Immortal)
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)
static const pxr::TfToken specularColor("specularColor", pxr::TfToken::Immortal)
static const pxr::TfToken wrapT("wrapT", pxr::TfToken::Immortal)
static const pxr::TfToken a("a", pxr::TfToken::Immortal)
static const pxr::TfToken UsdPrimvarReader_float2("UsdPrimvarReader_float2", pxr::TfToken::Immortal)
ColorManagedColorspaceSettings colorspace_settings
struct bNodeTree * nodetree
char surface_render_method
const float horizontal_step_
bNode * get_cached_node(const pxr::UsdShadeShader &usd_shader, const blender::StringRef tag={}) const
const float vertical_step_
void cache_node(const pxr::UsdShadeShader &usd_shader, bNode *node, const blender::StringRef tag={})
float2 compute_node_loc(int column)
Vector< float, 8 > column_offsets_
std::string get_key(const pxr::UsdShadeShader &usd_shader, const blender::StringRef tag) const
ShaderToNodeMap node_cache_
void * BKE_image_get_tile
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 pxr::UsdShadeInput get_input(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &input_name)
static bool needs_blend(const pxr::UsdShadeShader &usd_shader)
static blender::Vector< int > get_udim_tiles(const std::string &file_path)
static int get_image_extension(const pxr::UsdShadeShader &usd_shader, const int default_value)
static bNodeSocket * get_input_socket(bNode *node, const blender::StringRefNull identifier, ReportList *reports)
static bool get_usd_preview_surface(const pxr::UsdShadeMaterial &usd_material, pxr::UsdShadeShader &r_preview_surface)
static pxr::SdfLayerHandle get_layer_handle(const pxr::UsdAttribute &attribute)
static void link_nodes(bNodeTree *ntree, bNode *source, const blender::StringRefNull sock_out, bNode *dest, const blender::StringRefNull sock_in)
static void set_viewport_material_props(Material *mtl, const pxr::UsdShadeShader &usd_preview)
static void add_udim_tiles(Image *image, const blender::Vector< int > &indices)
static bNode * add_node(bNodeTree *ntree, const int type, const blender::float2 loc)