27 b.add_input<
decl::Color>(
"Color"_ustr).default_value({0.8f, 0.8f, 0.8f, 1.0f});
29 .default_value(0.005f)
32 .
description(
"Scale factor of the subsurface scattering radius");
34 .default_value({1.0f, 0.2f, 0.1f})
37 .description(
"Scattering radius per color channel (RGB), multiplied with Scale");
54 "Directionality of volume scattering within the subsurface medium. "
55 "Zero scatters uniformly in all directions, positive values scatter more in the forward "
56 "direction, and negative values scatter more backwards. "
57 "For example, skin has been measured to have an anisotropy of 0.8");
59 b.add_input<
decl::Float>(
"Weight"_ustr).available(is_gpu_internal);
89 float random_walk_scale = 1.0f;
91 random_walk_scale = 4.0f *
M_PI;
93 random_walk_radius_scale =
GPU_constant(&random_walk_scale);
97 "node_subsurface_scattering",
100 random_walk_radius_scale,
107 const int sss_method =
node->custom1;
125 if (to_type_ != NodeItem::Type::BSDF) {
129 NodeItem
color = get_input_value(
"Color", NodeItem::Type::Color3);
130 NodeItem
scale = get_input_value(
"Scale", NodeItem::Type::Float);
131# if MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38
132 NodeItem radius = get_input_value(
"Radius", NodeItem::Type::Vector3);
134 NodeItem radius = get_input_value(
"Radius", NodeItem::Type::Color3);
136 NodeItem anisotropy = get_input_value(
"Anisotropy", NodeItem::Type::Float);
137 NodeItem normal = get_input_link(
"Normal", NodeItem::Type::Vector3);
139 return create_node(
"subsurface_bsdf",
140 NodeItem::Type::BSDF,
141 {{
"weight", val(1.0f)},
144 {
"anisotropy", anisotropy},
145 {
"normal", normal}});
160 ntype.
ui_name =
"Subsurface Scattering";
162 "Subsurface multiple scattering shader to simulate light entering the surface and bouncing "
163 "internally.\nTypically used for materials such as skin, wax, marble or milk";
166 ntype.
declare = file_ns::node_declare;
169 ntype.
draw_buttons = file_ns::node_shader_buts_subsurface;
171 ntype.
initfunc = file_ns::node_shader_init_subsurface_scattering;
172 ntype.
gpu_fn = file_ns::node_shader_gpu_subsurface_scattering;
173 ntype.
updatefunc = file_ns::node_shader_update_subsurface_scattering;
#define NODE_CLASS_SHADER
#define SH_NODE_SUBSURFACE_SCATTERING
float3x3 scale(float3x3 mat, float2 scale)
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
constexpr StringRefNull radius
static void node_shader_update_subsurface_scattering(bNodeTree *ntree, bNode *node)
static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_subsurface(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_init_subsurface_scattering(bNodeTree *, bNode *node)
@ ITEM_R_SPLIT_EMPTY_NAME
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
bool object_shader_nodes_poll(const bContext *C)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_constant(const float *num)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void search_link_ops_for_shader_bsdf_node(nodes::GatherLinkSearchOpParams ¶ms)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
void register_node_type_sh_subsurface_scattering()
GPUNodeLink * GPU_shading_data()
@ SHD_SUBSURFACE_RANDOM_WALK
@ SHD_SUBSURFACE_RANDOM_WALK_LEGACY
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
static constexpr int _160
NodeMaterialXFunction materialx_fn
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)