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);
84 GPUNodeLink *density =
nullptr, *color =
nullptr, *temperature =
nullptr;
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};
127 data = (
float *)
MEM_mallocN(
sizeof(
float) * size * 4,
"blackbody texture");
131 data = (
float *)
MEM_callocN(
sizeof(
float) * size * 4,
"blackbody black");
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.
declare = file_ns::node_declare;
170 ntype.
gpu_fn = file_ns::node_shader_gpu_volume_principled;
#define NODE_CLASS_SHADER
#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_with_default(GPUMaterial *mat, eCustomDataType type, const char *name, eGPUDefaultValue default_value)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
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)
local_group_size(16, 16) .push_constant(Type b
void *(* MEM_mallocN)(size_t len, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
void node_register_type(bNodeType *ntype)
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, int type, const char *name, short nclass)
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
NodeGPUExecFunction gpu_fn
NodeDeclareFunction declare