29#include <pxr/base/gf/vec3f.h>
30#include <pxr/usd/ar/packageUtils.h>
31#include <pxr/usd/usdShade/material.h>
32#include <pxr/usd/usdShade/shader.h>
40static const pxr::TfToken
a(
"a", pxr::TfToken::Immortal);
41static const pxr::TfToken
b(
"b", pxr::TfToken::Immortal);
42static const pxr::TfToken
bias(
"bias", pxr::TfToken::Immortal);
43static const pxr::TfToken
clearcoat(
"clearcoat", pxr::TfToken::Immortal);
45static const pxr::TfToken
diffuseColor(
"diffuseColor", pxr::TfToken::Immortal);
46static const pxr::TfToken
emissiveColor(
"emissiveColor", pxr::TfToken::Immortal);
47static const pxr::TfToken
file(
"file", pxr::TfToken::Immortal);
48static const pxr::TfToken
g(
"g", pxr::TfToken::Immortal);
49static const pxr::TfToken
ior(
"ior", pxr::TfToken::Immortal);
50static const pxr::TfToken
in(
"in", pxr::TfToken::Immortal);
51static const pxr::TfToken
metallic(
"metallic", pxr::TfToken::Immortal);
52static const pxr::TfToken
normal(
"normal", pxr::TfToken::Immortal);
53static const pxr::TfToken
occlusion(
"occlusion", pxr::TfToken::Immortal);
54static const pxr::TfToken
opacity(
"opacity", pxr::TfToken::Immortal);
56static const pxr::TfToken
r(
"r", pxr::TfToken::Immortal);
57static const pxr::TfToken
result(
"result", pxr::TfToken::Immortal);
58static const pxr::TfToken
rgb(
"rgb", pxr::TfToken::Immortal);
59static const pxr::TfToken
rgba(
"rgba", pxr::TfToken::Immortal);
60static const pxr::TfToken
roughness(
"roughness", pxr::TfToken::Immortal);
61static const pxr::TfToken
scale(
"scale", pxr::TfToken::Immortal);
63static const pxr::TfToken
specularColor(
"specularColor", pxr::TfToken::Immortal);
64static const pxr::TfToken
st(
"st", pxr::TfToken::Immortal);
65static const pxr::TfToken
varname(
"varname", pxr::TfToken::Immortal);
68static const pxr::TfToken
auto_(
"auto", pxr::TfToken::Immortal);
69static const pxr::TfToken
sRGB(
"sRGB", pxr::TfToken::Immortal);
70static const pxr::TfToken
raw(
"raw", pxr::TfToken::Immortal);
71static const pxr::TfToken
RAW(
"RAW", pxr::TfToken::Immortal);
74static const pxr::TfToken
black(
"black", pxr::TfToken::Immortal);
75static const pxr::TfToken
clamp(
"clamp", pxr::TfToken::Immortal);
76static const pxr::TfToken
repeat(
"repeat", pxr::TfToken::Immortal);
77static const pxr::TfToken
mirror(
"mirror", pxr::TfToken::Immortal);
78static const pxr::TfToken
wrapS(
"wrapS", pxr::TfToken::Immortal);
79static const pxr::TfToken
wrapT(
"wrapT", pxr::TfToken::Immortal);
82static const pxr::TfToken
rotation(
"rotation", pxr::TfToken::Immortal);
83static const pxr::TfToken
translation(
"translation", pxr::TfToken::Immortal);
88 pxr::TfToken::Immortal);
89static const pxr::TfToken
UsdUVTexture(
"UsdUVTexture", pxr::TfToken::Immortal);
90static const pxr::TfToken
UsdTransform2d(
"UsdTransform2d", pxr::TfToken::Immortal);
101static std::string
get_key(
const pxr::UsdShadeShader &usd_shader,
const char *tag)
103 std::string key = usd_shader.GetPath().GetAsString();
115 const pxr::UsdShadeShader &usd_shader,
116 const char *tag =
nullptr)
118 return node_cache.lookup_default(
get_key(usd_shader, tag),
nullptr);
124 const pxr::UsdShadeShader &usd_shader,
126 const char *tag =
nullptr)
128 node_cache.add(
get_key(usd_shader, tag), node);
133 const bContext *C,
bNodeTree *ntree,
const int type,
const float locx,
const float locy)
138 new_node->
locx = locx;
139 new_node->
locy = locy;
151 if (!source_socket) {
152 CLOG_ERROR(&
LOG,
"Couldn't find output socket %s", sock_out);
170 for (
const auto &PropertySpec : attribute.GetPropertyStack(pxr::UsdTimeCode::EarliestTime())) {
171 if (PropertySpec->HasDefaultValue() ||
172 PropertySpec->GetLayer()->GetNumTimeSamplesForPath(PropertySpec->GetPath()) > 0)
174 return PropertySpec->GetLayer();
178 return pxr::SdfLayerHandle();
186 STRNCPY(base_udim_path, file_path.c_str());
192 int tile_start, tile_range;
197 udim_tiles.
append(tile_number);
211 for (
int tile_number :
indices) {
228 if (opacity_input.HasConnectedSource()) {
233 if (opacity_input.GetAttr().HasAuthoredValue() && opacity_input.GetAttr().Get(&val)) {
234 float opacity = val.Get<
float>();
246 float default_value = 0.0f)
249 return default_value;
254 if (!opacity_threshold_input) {
255 return default_value;
259 if (opacity_threshold_input.GetAttr().HasAuthoredValue() &&
260 opacity_threshold_input.GetAttr().Get(&val))
262 return val.Get<
float>();
265 return default_value;
271 return pxr::TfToken();
276 if (!color_space_input) {
277 return pxr::TfToken();
280 pxr::VtValue color_space_val;
281 if (color_space_input.Get(&color_space_val) && color_space_val.IsHolding<pxr::TfToken>()) {
282 return color_space_val.Get<pxr::TfToken>();
285 return pxr::TfToken();
297 return default_value;
300 pxr::VtValue wrap_input_val;
301 if (!(wrap_input.Get(&wrap_input_val) && wrap_input_val.IsHolding<pxr::TfToken>())) {
302 return default_value;
305 pxr::TfToken wrap_val = wrap_input_val.Get<pxr::TfToken>();
323 return default_value;
330 pxr::UsdShadeShader &r_preview_surface)
336 if (pxr::UsdShadeShader surf_shader = usd_material.ComputeSurfaceSource()) {
338 pxr::TfToken shader_id;
340 r_preview_surface = surf_shader;
352 if (!(mtl && usd_preview)) {
358 if (diffuse_color_input.GetAttr().HasAuthoredValue() &&
359 diffuse_color_input.GetAttr().Get(&val) && val.IsHolding<pxr::GfVec3f>())
361 pxr::GfVec3f color = val.UncheckedGet<pxr::GfVec3f>();
370 if (metallic_input.GetAttr().HasAuthoredValue() && metallic_input.GetAttr().Get(&val) &&
371 val.IsHolding<
float>())
379 if (roughness_input.GetAttr().HasAuthoredValue() && roughness_input.GetAttr().Get(&val) &&
380 val.IsHolding<
float>())
387static pxr::UsdShadeInput
get_input(
const pxr::UsdShadeShader &usd_shader,
388 const pxr::TfToken &input_name)
390 pxr::UsdShadeInput input = usd_shader.GetInput(input_name);
395 for (
const pxr::UsdShadeConnectionSourceInfo &source_info : input.GetConnectedSources()) {
396 pxr::UsdShadeShader shader = pxr::UsdShadeShader(source_info.source.GetPrim());
397 pxr::UsdShadeInput secondary_input = shader.GetInput(source_info.sourceName);
398 if (secondary_input) {
399 input = secondary_input;
414 "%s: Error: Couldn't get input socket %s for node %s",
430void compute_node_loc(
const int column,
float *r_locx,
float *r_locy, NodePlacementContext *r_ctx)
432 if (!(r_locx && r_locy && r_ctx)) {
436 (*r_locx) = r_ctx->origx - column * r_ctx->horizontal_step;
438 if (column >= r_ctx->column_offsets.size()) {
439 r_ctx->column_offsets.append(0.0f);
442 (*r_locy) = r_ctx->origy - r_ctx->column_offsets[column];
446 r_ctx->column_offsets[column] += r_ctx->vertical_step + 10.0f;
452 : params_(
params), bmain_(bmain)
458 if (!(
bmain_ && usd_material)) {
462 std::string mtl_name = usd_material.GetPrim().GetName().GetString();
470 pxr::UsdShadeShader usd_preview;
488 const pxr::UsdShadeShader &usd_shader)
const
490 if (!(
bmain_ && mtl && usd_shader)) {
499 nullptr, &mtl->
id,
"Shader Nodetree",
"ShaderNodeTree");
503 bNode *principled =
add_node(
nullptr, ntree, SH_NODE_BSDF_PRINCIPLED, 0.0f, 300.0f);
507 "Couldn't create SH_NODE_BSDF_PRINCIPLED node for USD shader %s",
508 usd_shader.GetPath().GetAsString().c_str());
517 "Couldn't create SH_NODE_OUTPUT_MATERIAL node for USD shader %s",
518 usd_shader.GetPath().GetAsString().c_str());
523 link_nodes(ntree, principled,
"BSDF", output,
"Surface");
542 const pxr::UsdShadeShader &usd_shader)
const
557 set_node_input(diffuse_input, principled,
"Base Color", ntree, column, &context, extra);
560 float emission_strength = 0.0f;
565 emissive_input, principled,
"Emission Color", ntree, column, &context, extra))
567 emission_strength = 1.0f;
572 principled,
SOCK_IN,
"Emission Strength");
576 set_node_input(specular_input, principled,
"Specular Tint", ntree, column, &context);
580 set_node_input(metallic_input, principled,
"Metallic", ntree, column, &context);
584 set_node_input(roughness_input, principled,
"Roughness", ntree, column, &context);
588 set_node_input(coat_input, principled,
"Coat Weight", ntree, column, &context);
593 set_node_input(coat_roughness_input, principled,
"Coat Roughness", ntree, column, &context);
599 set_node_input(opacity_input, principled,
"Alpha", ntree, column, &context, extra);
602 if (pxr::UsdShadeInput ior_input = usd_shader.GetInput(
usdtokens::ior)) {
603 set_node_input(ior_input, principled,
"IOR", ntree, column, &context);
607 set_node_input(normal_input, principled,
"Normal", ntree, column, &context);
613 const char *dest_socket_name,
619 if (!(usd_input && dest_node && r_ctx)) {
623 if (usd_input.HasConnectedSource()) {
626 return follow_connection(usd_input, dest_node, dest_socket_name, ntree, column, r_ctx, extra);
633 CLOG_ERROR(&
LOG,
"Couldn't get destination node socket %s", dest_socket_name);
638 if (!usd_input.Get(&val)) {
640 "Couldn't get value for usd shader input %s",
641 usd_input.GetPrim().GetPath().GetAsString().c_str());
645 switch (sock->
type) {
647 if (val.IsHolding<
float>()) {
651 else if (val.IsHolding<pxr::GfVec3f>()) {
652 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
653 float average = (v3f[0] + v3f[1] + v3f[2]) / 3.0f;
659 if (val.IsHolding<pxr::GfVec3f>()) {
660 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
666 if (val.IsHolding<pxr::GfVec3f>()) {
667 pxr::GfVec3f v3f = val.UncheckedGet<pxr::GfVec3f>();
671 else if (val.IsHolding<pxr::GfVec2f>()) {
672 pxr::GfVec2f v2f = val.UncheckedGet<pxr::GfVec2f>();
679 "Unexpected type %s for destination node socket %s",
699 compute_node_loc(column, &locx, &locy, r_ctx);
705 normal_map.sock_input_name =
"Color";
706 normal_map.sock_output_name =
"Normal";
714 bool feeds_normal_map,
720 pxr::GfVec4f scale(1.0f, 1.0f, 1.0f, 1.0f);
721 pxr::GfVec4f bias(0.0f, 0.0f, 0.0f, 0.0f);
724 if (scale_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
725 scale = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
727 if (bias_input.Get(&val) && val.CanCast<pxr::GfVec4f>()) {
728 bias = pxr::VtValue::Cast<pxr::GfVec4f>(val).UncheckedGet<pxr::GfVec4f>();
732 if (scale == pxr::GfVec4f{1.0f, 1.0f, 1.0f, 1.0f} &&
733 bias == pxr::GfVec4f{0.0f, 0.0f, 0.0f, 0.0f})
739 if (feeds_normal_map && (scale[0] == 2.0f && scale[1] == 2.0f && scale[2] == 2.0f) &&
740 (bias[0] == -1.0f && bias[1] == -1.0f && bias[2] == -1.0f))
749 compute_node_loc(feeds_normal_map ? column + 1 : column, &locx, &locy, r_ctx);
753 const char *tag =
"scale_bias";
761 scale_bias.node =
node;
763 scale_bias.sock_input_name =
"Vector";
764 scale_bias.sock_output_name =
"Vector";
780 compute_node_loc(column, &locx, &locy, r_ctx);
785 adjust.sock_input_name =
"Vector";
786 adjust.sock_output_name =
"Vector";
797 const pxr::TfToken &usd_source_name,
807 const char *tag =
"separate_color";
813 compute_node_loc(column, &locx, &locy, r_ctx);
819 separate_color.node =
node;
820 separate_color.sock_input_name =
"Color";
823 separate_color.sock_output_name =
"Red";
826 separate_color.sock_output_name =
"Green";
829 separate_color.sock_output_name =
"Blue";
833 return separate_color;
843 compute_node_loc(column, &locx, &locy, r_ctx);
848 lessthan.sock_input_name =
"Value";
849 lessthan.sock_output_name =
"Value";
861 compute_node_loc(column, &locx, &locy, r_ctx);
867 oneminus.sock_input_name =
"Value_001";
868 oneminus.sock_output_name =
"Value";
878 const char *dest_socket_name,
884 if (!(usd_input && dest_node && dest_socket_name && ntree && r_ctx)) {
888 pxr::UsdShadeConnectableAPI source;
889 pxr::TfToken source_name;
890 pxr::UsdShadeAttributeType source_type;
892 usd_input.GetConnectedSource(&source, &source_name, &source_type);
894 if (!(source && source.GetPrim().IsA<pxr::UsdShadeShader>())) {
898 pxr::UsdShadeShader source_shader(source.GetPrim());
900 if (!source_shader) {
904 pxr::TfToken shader_id;
905 if (!source_shader.GetShaderId(&shader_id)) {
907 "Couldn't get shader id for source shader %s",
908 source_shader.GetPath().GetAsString().c_str());
918 const bool is_normal_map =
STREQ(dest_socket_name,
"Normal");
926 source_shader, source_name, ntree, column + shift, r_ctx);
927 if (separate_color.
node) {
933 source_shader, ntree, column + shift, is_normal_map, r_ctx);
937 bNode *target_node = dest_node;
938 const char *target_sock_name = dest_socket_name;
939 if (normal_map.node) {
942 if (scale_bias.
node) {
953 normal_map.sock_input_name);
955 target_node = scale_bias.
node;
960 target_node = normal_map.node;
961 target_sock_name = normal_map.sock_input_name;
964 link_nodes(ntree, normal_map.node, normal_map.sock_output_name, dest_node, dest_socket_name);
966 else if (scale_bias.
node) {
967 if (separate_color.
node) {
983 target_node = scale_bias.
node;
987 else if (separate_color.
node) {
993 target_node = separate_color.
node;
1006 target_node = lessthan.
node;
1021 source_shader, source_name, dest_node, dest_socket_name, ntree, column + 1, r_ctx);
1031 const pxr::TfToken &usd_source_name,
1033 const char *dest_socket_name,
1039 if (!usd_shader || !dest_node || !ntree || !dest_socket_name || !
bmain_ || !r_ctx) {
1045 if (tex_image ==
nullptr) {
1048 compute_node_loc(column, &locx, &locy, r_ctx);
1054 CLOG_ERROR(&
LOG,
"Couldn't create SH_NODE_TEX_IMAGE for node input %s", dest_socket_name);
1068 std::string source_socket_name = usd_source_name ==
usdtokens::a ?
"Alpha" :
"Color";
1070 link_nodes(ntree, tex_image, source_socket_name.c_str(), dest_node, dest_socket_name);
1073 if (pxr::UsdShadeInput st_input = usd_shader.GetInput(
usdtokens::st)) {
1074 set_node_input(st_input, tex_image,
"Vector", ntree, column, r_ctx);
1080 const char *dest_socket_name,
1085 if (!usd_shader || !dest_node || !ntree || !dest_socket_name || !
bmain_ || !r_ctx) {
1091 if (mapping ==
nullptr) {
1094 compute_node_loc(column, &locx, &locy, r_ctx);
1102 "%s: Couldn't create SH_NODE_MAPPING for node input %s",
1116 if (scale_input.Get(&val) && val.CanCast<pxr::GfVec2f>()) {
1117 pxr::GfVec2f scale_val = val.Cast<pxr::GfVec2f>().UncheckedGet<pxr::GfVec2f>();
1118 float scale[3] = {scale_val[0], scale_val[1], 1.0f};
1127 if (trans_input.Get(&val) && val.CanCast<pxr::GfVec2f>()) {
1128 pxr::GfVec2f trans_val = val.Cast<pxr::GfVec2f>().UncheckedGet<pxr::GfVec2f>();
1129 float loc[3] = {trans_val[0], trans_val[1], 0.0f};
1138 if (rot_input.Get(&val) && val.CanCast<
float>()) {
1139 float rot_val = val.Cast<
float>().UncheckedGet<float>() *
M_PI / 180.0f;
1140 float rot[3] = {0.0f, 0.0f, rot_val};
1148 link_nodes(ntree, mapping,
"Vector", dest_node, dest_socket_name);
1151 if (pxr::UsdShadeInput in_input = usd_shader.GetInput(
usdtokens::in)) {
1152 set_node_input(in_input, mapping,
"Vector", ntree, column, r_ctx);
1169 "Couldn't get file input property for USD shader %s",
1170 usd_shader.GetPath().GetAsString().c_str());
1176 if (file_input.HasConnectedSource()) {
1177 pxr::UsdShadeConnectableAPI source;
1178 pxr::TfToken source_name;
1179 pxr::UsdShadeAttributeType source_type;
1181 if (file_input.GetConnectedSource(&source, &source_name, &source_type)) {
1182 file_input = source.GetInput(source_name);
1186 "Couldn't get connected source for file input %s (%s)\n",
1187 file_input.GetPrim().GetPath().GetText(),
1188 file_input.GetFullName().GetText());
1192 pxr::VtValue file_val;
1193 if (!file_input.Get(&file_val) || !file_val.IsHolding<pxr::SdfAssetPath>()) {
1195 "Couldn't get file input value for USD shader %s",
1196 usd_shader.GetPath().GetAsString().c_str());
1200 const pxr::SdfAssetPath &asset_path = file_val.Get<pxr::SdfAssetPath>();
1201 std::string file_path = asset_path.GetResolvedPath();
1203 if (file_path.empty()) {
1205 file_path = asset_path.GetAssetPath();
1209 if (pxr::SdfLayerHandle layer_handle =
get_layer_handle(file_input.GetAttr())) {
1210 file_path = layer_handle->ComputeAbsolutePath(file_path);
1215 if (file_path.empty()) {
1217 "Couldn't resolve image asset '%s' for Texture Image node",
1218 asset_path.GetAssetPath().c_str());
1223 const bool is_relative = pxr::ArIsPackageRelativePath(file_path);
1226 std::string imported_file_source_path;
1228 if (import_textures) {
1229 imported_file_source_path = file_path;
1242 file_path =
import_asset(file_path.c_str(), textures_dir, name_collision_mode,
reports());
1253 const char *im_file = file_path.c_str();
1256 CLOG_WARN(&
LOG,
"Couldn't open image file '%s' for Texture Image node", im_file);
1264 tex_image->
id = &image->id;
1273 if (color_space.IsEmpty()) {
1274 color_space = file_input.GetAttr().GetColorSpace();
1277 if (color_space.IsEmpty()) {
1289 STRNCPY(image->colorspace_settings.name,
"sRGB");
1298 STRNCPY(image->colorspace_settings.name,
"Non-Color");
1304 if (import_textures && imported_file_source_path != file_path) {
1319 const pxr::TfToken & ,
1321 const char *dest_socket_name,
1326 if (!usd_shader || !dest_node || !ntree || !dest_socket_name || !
bmain_ || !r_ctx) {
1332 if (uv_map ==
nullptr) {
1335 compute_node_loc(column, &locx, &locy, r_ctx);
1341 CLOG_ERROR(&
LOG,
"Couldn't create SH_NODE_UVMAP for node input %s", dest_socket_name);
1353 if (varname_input) {
1354 for (
const pxr::UsdShadeConnectionSourceInfo &source_info :
1355 varname_input.GetConnectedSources())
1357 pxr::UsdShadeShader shader = pxr::UsdShadeShader(source_info.source.GetPrim());
1358 pxr::UsdShadeInput secondary_varname_input = shader.GetInput(source_info.sourceName);
1359 if (secondary_varname_input) {
1360 varname_input = secondary_varname_input;
1366 if (varname_input) {
1367 pxr::VtValue varname_val;
1370 if (varname_input.Get(&varname_val) && varname_val.CanCastToTypeid(
typeid(std::string))) {
1371 std::string varname = varname_val.Cast<std::string>().Get<std::string>();
1372 if (!varname.empty()) {
1381 link_nodes(ntree, uv_map,
"UV", dest_node, dest_socket_name);
1389 std::string usd_name =
make_safe_name(material->id.name + 2,
true);
1395 const pxr::SdfPath &usd_mat_path,
1402 const std::string *mat_name = usd_path_to_mat_name.
lookup_ptr(usd_mat_path.GetAsString());
1403 if (mat_name ==
nullptr) {
1408 BLI_assert_msg(mat !=
nullptr,
"Previously created material cannot be found any more");
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)
General operations, lookup, etc. for materials.
struct Material * BKE_material_add(struct Main *bmain, const char *name)
#define SH_NODE_TEX_IMAGE
#define SH_NODE_SEPARATE_COLOR
#define SH_NODE_VECTOR_MATH
#define SH_NODE_NORMAL_MAP
#define SH_NODE_OUTPUT_MATERIAL
void BKE_ntree_update_main_tree(Main *bmain, bNodeTree *ntree, NodeTreeUpdateExtraParams *params)
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(struct 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)
#define STRNCPY(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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue Hue Saturation Apply a color transformation in the HSV color model Specular Similar to the Principled BSDF node but uses the specular workflow instead of metallic
const Value * lookup_ptr(const Key &key) const
Value & lookup_or_add_default(const Key &key)
Value lookup_default(const Key &key, const Value &default_value) const
void append(const T &value)
Material * add_material(const pxr::UsdShadeMaterial &usd_material) const
USDMaterialReader(const USDImportParams ¶ms, Main *bmain)
void convert_usd_transform_2d(const pxr::UsdShadeShader &usd_shader, bNode *dest_node, const char *dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx) const
void convert_usd_primvar_reader_float2(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNode *dest_node, const char *dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx) const
void convert_usd_uv_texture(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNode *dest_node, const char *dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx, const ExtraLinkInfo &extra={}) const
bool set_node_input(const pxr::UsdShadeInput &usd_input, bNode *dest_node, const char *dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx, const ExtraLinkInfo &extra={}) const
bool follow_connection(const pxr::UsdShadeInput &usd_input, bNode *dest_node, const char *dest_socket_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx, const ExtraLinkInfo &extra={}) const
ReportList * reports() const
void import_usd_preview(Material *mtl, const pxr::UsdShadeShader &usd_shader) const
void set_principled_node_inputs(bNode *principled_node, bNodeTree *ntree, const pxr::UsdShadeShader &usd_shader) const
void load_tex_image(const pxr::UsdShadeShader &usd_shader, bNode *tex_image, const ExtraLinkInfo &extra={}) const
local_group_size(16, 16) .push_constant(Type b
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
ccl_global const KernelWorkTile * tile
ccl_device_inline float average(const float2 a)
void node_set_active(bNodeTree *ntree, bNode *node)
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)
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, const char *name, const char *idname)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
const char * temp_textures_dir()
void build_material_map(const Main *bmain, blender::Map< std::string, Material * > *r_mat_map)
static IntermediateNode add_normal_map(bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
std::string import_asset(const char *src, const char *import_dir, eUSDTexNameCollisionMode name_collision_mode, ReportList *reports)
bool is_udim_path(const std::string &path)
void set_id_props_from_prim(ID *id, const pxr::UsdPrim &prim, const eUSDAttrImportMode attr_import_mode, const pxr::UsdTimeCode time_code)
std::string make_safe_name(const std::string &name, bool allow_unicode)
Material * find_existing_material(const pxr::SdfPath &usd_mat_path, const USDImportParams ¶ms, const blender::Map< std::string, Material * > &mat_map, const blender::Map< std::string, std::string > &usd_path_to_mat_name)
@ USD_TEX_NAME_COLLISION_OVERWRITE
static IntermediateNode add_lessthan(bNodeTree *ntree, float threshold, int column, NodePlacementContext *r_ctx)
void ensure_usd_source_path_prop(const std::string &path, ID *id)
@ USD_MTL_NAME_COLLISION_MAKE_UNIQUE
static IntermediateNode add_oneminus(bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
static IntermediateNode add_scale_bias(const pxr::UsdShadeShader &usd_shader, bNodeTree *ntree, int column, bool feeds_normal_map, NodePlacementContext *r_ctx)
static IntermediateNode add_scale_bias_adjust(bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
static IntermediateNode add_separate_color(const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNodeTree *ntree, int column, NodePlacementContext *r_ctx)
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 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)
char surface_render_method
ShaderToNodeMap node_cache
eUSDTexImportMode import_textures_mode
char import_textures_dir[768]
eUSDTexNameCollisionMode tex_name_collision_mode
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 bNode * get_cached_node(const ShaderToNodeMap &node_cache, const pxr::UsdShadeShader &usd_shader, const char *tag=nullptr)
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 bNode * add_node(const bContext *C, bNodeTree *ntree, const int type, const float locx, const float locy)
static blender::Vector< int > get_udim_tiles(const std::string &file_path)
static bNodeSocket * get_input_socket(bNode *node, const char *identifier, ReportList *reports)
static void cache_node(ShaderToNodeMap &node_cache, const pxr::UsdShadeShader &usd_shader, bNode *node, const char *tag=nullptr)
static int get_image_extension(const pxr::UsdShadeShader &usd_shader, const int default_value)
static std::string get_key(const pxr::UsdShadeShader &usd_shader, const char *tag)
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 char *sock_out, bNode *dest, const char *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)