30 const char *identifier,
37 BLI_assert(socket && socket->type == property_type);
41 switch (property_type) {
45 socket->default_value);
46 r_property[0] = socket_def_value->
value;
52 socket->default_value);
59 socket->default_value);
79 r_linked_sockets.
clear();
87 if (
STREQ(curr_socket->bsocket()->identifier, dest_socket_id.
c_str())) {
88 dest_socket = curr_socket;
94 r_linked_sockets.
resize(linked_sockets.
size());
95 r_linked_sockets = linked_sockets;
106 const bNode *parent_node = socket->bnode();
123 Image *tex_image =
reinterpret_cast<Image *
>(tex_node->
id);
132 "Packed image found:'%s'. Unpack and place the image in the same "
133 "directory as the .MTL file.\n",
143 unsigned short numlen;
181 const bNode *bnode =
nullptr;
183 bnode = bsdf_node->
bnode();
192 float spec_exponent = (1.0f -
roughness);
193 spec_exponent *= spec_exponent * 1000.0f;
205 float refraction_index = 1.0f;
214 const bool transparent = dissolved != 1.0f;
221 float3 emission_col{0.0f};
222 float emission_strength = 0.0f;
227 mul_v3_fl(emission_col, emission_strength);
247 else if (transparent) {
251 r_mtl_mat.
Ns = spec_exponent;
256 r_mtl_mat.
Ka = {1.0f, 1.0f, 1.0f};
258 r_mtl_mat.
Kd = diffuse_col;
260 r_mtl_mat.
Ke = emission_col;
261 r_mtl_mat.
Ni = refraction_index;
262 r_mtl_mat.
d = dissolved;
288 const bNode *normal_map_node{
nullptr};
302 float emission_strength = 0.0f;
304 if (emission_strength == 0.0f) {
310 bnode, *
node_tree, texture_map.value.dest_socket_id, linked_sockets);
319 if (tex_image_filepath.empty()) {
327 if (normal_map_node) {
336 texture_map.value.image_path = tex_image_filepath;
345 std::replace(mtlmat.
name.begin(), mtlmat.
name.end(),
' ',
'_');
bool BKE_image_has_filepath(const struct Image *ima)
bool BKE_image_has_packedfile(const struct Image *image)
#define SH_NODE_BSDF_PRINCIPLED
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
int BLI_path_sequence_decode(const char *string, char *head, char *tail, unsigned short *r_digits_len)
void BLI_path_sequence_encode(char *string, const char *head, const char *tail, unsigned short numlen, int pic)
const char * BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
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 Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input 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 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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block SH_NODE_TEX_IMAGE
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value SH_NODE_NORMAL_MAP
constexpr int64_t size() const
constexpr T * data() const
constexpr const T & first() const
constexpr int64_t size() const
constexpr const char * c_str() const
void resize(const int64_t new_size)
bNodeType * typeinfo() const
Span< const NodeRef * > nodes_by_type(StringRefNull idname) const
static const nodes::NodeRef * find_bsdf_node(const nodes::NodeTreeRef *nodetree)
static const bNode * get_node_of_type(Span< const nodes::OutputSocketRef * > sockets_list, const int node_type)
static std::string get_image_filepath(const bNode *tex_node)
static void linked_sockets_to_dest_id(const bNode *dest_node, const nodes::NodeTreeRef &node_tree, StringRefNull dest_socket_id, Vector< const nodes::OutputSocketRef * > &r_linked_sockets)
MTLMaterial mtlmaterial_for_material(const Material *material)
static void store_bsdf_properties(const nodes::NodeRef *bsdf_node, const Material *material, MTLMaterial &r_mtl_mat)
static void store_image_textures(const nodes::NodeRef *bsdf_node, const nodes::NodeTreeRef *node_tree, const Material *material, MTLMaterial &r_mtl_mat)
static void copy_property_from_node(const eNodeSocketDatatype property_type, const bNode *node, const char *identifier, MutableSpan< float > r_property)
static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal)
static const pxr::TfToken specular("specular", pxr::TfToken::Immortal)
struct bNodeTree * nodetree
struct bNodeType * typeinfo
Map< const eMTLSyntaxElement, tex_map_XX > texture_maps