18 b.add_input<
decl::Color>(
"Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
20 "Scale factor of the subsurface scattering radius");
22 .default_value({1.0f, 0.2f, 0.1f})
25 .
description(
"Scattering radius per color channel (RGB), multiplied with Scale");
60 GPU_link(mat,
"world_normals_get", &
in[6].link);
70 const int sss_method = node->
custom1;
73 if (
STR_ELEM(sock->name,
"IOR",
"Anisotropy")) {
76 if (
STR_ELEM(sock->name,
"Roughness")) {
86 if (to_type_ != NodeItem::Type::BSDF) {
90 NodeItem
color = get_input_value(
"Color", NodeItem::Type::Color3);
91 NodeItem scale = get_input_value(
"Scale", NodeItem::Type::Float);
92# if MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38
93 NodeItem radius = get_input_value(
"Radius", NodeItem::Type::Vector3);
95 NodeItem radius = get_input_value(
"Radius", NodeItem::Type::Color3);
97 NodeItem anisotropy = get_input_value(
"Anisotropy", NodeItem::Type::Float);
98 NodeItem normal = get_input_link(
"Normal", NodeItem::Type::Vector3);
100 return create_node(
"subsurface_bsdf",
101 NodeItem::Type::BSDF,
102 {{
"weight", val(1.0f)},
104 {
"radius", radius *
scale},
105 {
"anisotropy", anisotropy},
106 {
"normal", normal}});
121 ntype.
ui_name =
"Subsurface Scattering";
123 "Subsurface multiple scattering shader to simulate light entering the surface and bouncing "
124 "internally.\nTypically used for materials such as skin, wax, marble or milk";
127 ntype.
declare = file_ns::node_declare;
129 ntype.
draw_buttons = file_ns::node_shader_buts_subsurface;
131 ntype.
initfunc = file_ns::node_shader_init_subsurface_scattering;
132 ntype.
gpu_fn = file_ns::node_shader_gpu_subsurface_scattering;
133 ntype.
updatefunc = file_ns::node_shader_update_subsurface_scattering;
#define NODE_CLASS_SHADER
#define SH_NODE_SUBSURFACE_SCATTERING
#define LISTBASE_FOREACH(type, var, list)
@ SHD_SUBSURFACE_RANDOM_WALK
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
bool GPU_link(GPUMaterial *mat, const char *name,...)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
static void node_shader_update_subsurface_scattering(bNodeTree *ntree, bNode *node)
static void node_shader_buts_subsurface(uiLayout *layout, bContext *, PointerRNA *ptr)
static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_init_subsurface_scattering(bNodeTree *, bNode *node)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_subsurface_scattering()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool object_shader_nodes_poll(const bContext *C)
NodeMaterialXFunction materialx_fn
std::string ui_description
bool(* add_ui_poll)(const bContext *C)
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)