24 auto set_parametrization_reflectance = [](
bNode &
node) {
28 auto set_parametrization_pigment_concentration = [](
bNode &
node) {
32 auto set_parametrization_direct_absorption = [](
bNode &
node) {
47 .default_value({0.017513f, 0.005763f, 0.002059f, 1.0f})
48 .description(
"The RGB color of the strand. Only used in Direct Coloring")
55 .description(
"Hair pigment. Specify its absolute quantity between 0 and 1")
56 .make_available(set_parametrization_pigment_concentration);
63 "Fraction of pheomelanin in melanin, gives yellowish to reddish color, as opposed to "
64 "the brownish to black color of eumelanin")
65 .make_available(set_parametrization_pigment_concentration);
67 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
68 .description(
"Additional color used for dyeing the hair")
71 .default_value({0.245531f, 0.52f, 1.365f})
75 "Specifies energy absorption per unit length as light passes through the hair. A higher "
76 "value leads to a darker color")
77 .make_available(set_parametrization_direct_absorption);
84 "The ratio of the minor axis to the major axis of an elliptical cross-section. "
85 "Recommended values are 0.8~1 for Asian hair, 0.65~0.9 for Caucasian hair, 0.5~0.65 for "
86 "African hair. The major axis is aligned with the curve normal, which is not supported "
88 .make_available(set_model_huang);
94 .description(
"Hair roughness. A low value leads to a metallic look");
100 .make_available(set_model_chiang);
107 "Simulate a shiny coat by reducing the roughness to the given factor only for the first "
108 "light bounce (diffuse). Range [0, 1] is equivalent to a reduction of [0%, 100%] of the "
109 "original roughness")
110 .make_available(set_model_chiang);
112 .default_value(1.55f)
116 "Index of refraction determines how much the ray is bent. At 1.0 rays pass straight "
118 "like in a transparent material; higher values cause larger deflection in angle. "
120 "value is 1.55 (the IOR of keratin)");
122 .default_value(2.0f *
float(
M_PI) / 180.0f)
127 "The tilt angle of the cuticle scales (the outermost part of the hair). They are always "
128 "tilted towards the hair root. The value is usually between 2 and 4 for human hair");
134 .description(
"Vary the melanin concentration for each strand")
135 .make_available(set_parametrization_pigment_concentration);
141 .description(
"Vary roughness values for each strand");
143 b.add_input<
decl::Float>(
"Weight"_ustr).available(is_gpu_internal);
144 b.add_input<
decl::Float>(
"Reflection"_ustr,
"R lobe"_ustr)
150 "Optional factor for modulating the first light bounce off the hair surface. The color "
151 "of this component is always white. Keep this 1.0 for physical correctness")
152 .make_available(set_model_huang);
153 b.add_input<
decl::Float>(
"Transmission"_ustr,
"TT lobe"_ustr)
159 "Optional factor for modulating the transmission component. Picks up the color of the "
160 "pigment inside the hair. Keep this 1.0 for physical correctness")
161 .make_available(set_model_huang);
162 b.add_input<
decl::Float>(
"Secondary Reflection"_ustr,
"TRT lobe"_ustr)
168 "Optional factor for modulating the component which is transmitted into the hair, "
169 "reflected off the backside of the hair and then transmitted out of the hair. This "
170 "component is oriented approximately around the incoming direction, and picks up the "
171 "color of the pigment inside the hair. Keep this 1.0 for physical correctness")
172 .make_available(set_model_huang);
198 int parametrization =
data->parametrization;
199 int model =
data->model;
210 else if (
STREQ(sock.
name,
"Melanin Redness")) {
218 else if (
STREQ(sock.
name,
"Absorption Coefficient")) {
222 else if (
STREQ(sock.
name,
"Random Color")) {
226 else if (
STREQ(sock.
name,
"Radial Roughness")) {
232 else if (
STREQ(sock.
name,
"Aspect Ratio")) {
235 else if (
STR_ELEM(sock.
name,
"Reflection",
"Transmission",
"Secondary Reflection")) {
263 ntype.
ui_name =
"Principled Hair BSDF";
264 ntype.
ui_description =
"Physically-based, easy-to-use shader for rendering hair and fur";
267 ntype.
declare = file_ns::node_declare;
270 ntype.
draw_buttons = file_ns::node_shader_buts_principled_hair;
272 ntype.
initfunc = file_ns::node_shader_init_hair_principled;
273 ntype.
updatefunc = file_ns::node_shader_update_hair_principled;
274 ntype.
gpu_fn = file_ns::node_shader_gpu_hair_principled;
#define NODE_CLASS_SHADER
#define SH_NODE_BSDF_HAIR_PRINCIPLED
void make_available(bNode &node) const
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
static void node_shader_init_hair_principled(bNodeTree *, bNode *node)
static int node_shader_gpu_hair_principled(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_update_hair_principled(bNodeTree *ntree, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_principled_hair(ui::Layout &layout, bContext *, PointerRNA *ptr)
@ ITEM_R_SPLIT_EMPTY_NAME
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ SHD_PRINCIPLED_HAIR_CHIANG
@ SHD_PRINCIPLED_HAIR_HUANG
bool object_cycles_shader_nodes_poll(const bContext *C)
void register_node_type_sh_bsdf_hair_principled()
@ SHD_PRINCIPLED_HAIR_PIGMENT_CONCENTRATION
@ SHD_PRINCIPLED_HAIR_REFLECTANCE
@ SHD_PRINCIPLED_HAIR_DIRECT_ABSORPTION
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
BMesh const char void * data
void search_link_ops_for_shader_bsdf_node(nodes::GatherLinkSearchOpParams ¶ms)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_shading_data()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
static constexpr int _240
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
void(*) updatefunc(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
bool(*) add_ui_poll(const bContext *C)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)