13 b.add_input<
decl::Color>(
"Color").default_value({0.5f, 0.5f, 0.5f, 1.0f});
14#define SOCK_COLOR_ID 0
16#define SOCK_COLOR_ATTR_ID 1
17 b.add_input<
decl::Float>(
"Density").default_value(1.0f).min(0.0f).max(1000.0f);
18#define SOCK_DENSITY_ID 2
19 b.add_input<
decl::String>(
"Density Attribute").default_value(
"density");
20#define SOCK_DENSITY_ATTR_ID 3
26#define SOCK_ANISOTROPY_ID 4
27 b.add_input<
decl::Color>(
"Absorption Color").default_value({0.0f, 0.0f, 0.0f, 1.0f});
28#define SOCK_ABSORPTION_COLOR_ID 5
29 b.add_input<
decl::Float>(
"Emission Strength").default_value(0.0f).min(0.0f).max(1000.0f);
30#define SOCK_EMISSION_ID 6
31 b.add_input<
decl::Color>(
"Emission Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
32#define SOCK_EMISSION_COLOR_ID 7
38#define SOCK_BLACKBODY_INTENSITY_ID 8
39 b.add_input<
decl::Color>(
"Blackbody Tint").default_value({1.0f, 1.0f, 1.0f, 1.0f});
40#define SOCK_BLACKBODY_TINT_ID 8
42 .default_value(1000.0f)
46 b.add_input<
decl::String>(
"Temperature Attribute").default_value(
"temperature");
52 const char *attribute_name,
55 if (
STREQ(attribute_name,
"color")) {
56 GPU_link(mat,
"node_attribute_color", *attribute_link, attribute_link);
58 else if (
STREQ(attribute_name,
"temperature")) {
59 GPU_link(mat,
"node_attribute_temperature", *attribute_link, attribute_link);
92 const char *attribute_name = value->
value;
93 if (attribute_name[0] ==
'\0') {
97 if (
STREQ(sock->name,
"Density Attribute")) {
101 else if (
STREQ(sock->name,
"Color Attribute")) {
105 else if (use_blackbody &&
STREQ(sock->name,
"Temperature Attribute")) {
112 static const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
137 "node_volume_principled",
148#undef SOCK_COLOR_ATTR_ID
149#undef SOCK_DENSITY_ID
150#undef SOCK_DENSITY_ATTR_ID
151#undef SOCK_ANISOTROPY_ID
152#undef SOCK_ABSORPTION_COLOR_ID
153#undef SOCK_EMISSION_ID
154#undef SOCK_EMISSION_COLOR_ID
155#undef SOCK_BLACKBODY_INTENSITY_ID
156#undef SOCK_BLACKBODY_TINT_ID
168 ntype.
ui_name =
"Principled Volume";
169 ntype.
ui_description =
"Combine all volume shading components into a single easy to use node";
172 ntype.
declare = file_ns::node_declare;
174 ntype.
gpu_fn = file_ns::node_shader_gpu_volume_principled;
#define NODE_CLASS_SHADER
#define SH_NODE_VOLUME_PRINCIPLED
#define LISTBASE_FOREACH(type, var, list)
#define BLT_I18NCONTEXT_ID_ID
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row)
@ GPU_MATFLAG_VOLUME_SCATTER
@ GPU_MATFLAG_VOLUME_ABSORPTION
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
GPUNodeLink * GPU_attribute_with_default(GPUMaterial *mat, eCustomDataType type, const char *name, GPUDefaultValue default_value)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void IMB_colormanagement_blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max)
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void node_register_type(bNodeType &ntype)
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_volume_principled(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void attribute_post_process(GPUMaterial *mat, const char *attribute_name, GPUNodeLink **attribute_link)
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool node_socket_not_white(const GPUNodeStack &socket)
bool node_socket_not_black(const GPUNodeStack &socket)
bool node_socket_not_zero(const GPUNodeStack &socket)
void register_node_type_sh_volume_principled()
#define SOCK_ABSORPTION_COLOR_ID
#define SOCK_BLACKBODY_INTENSITY_ID
std::string ui_description
NodeGPUExecFunction gpu_fn
const char * enum_name_legacy
NodeDeclareFunction declare