Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_volume_principled.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (STREQ(sock->name, "Density Attribute")) { | ||||
| strcpy(((bNodeSocketValueString *)sock->default_value)->value, "density"); | strcpy(((bNodeSocketValueString *)sock->default_value)->value, "density"); | ||||
| } | } | ||||
| else if (STREQ(sock->name, "Temperature Attribute")) { | else if (STREQ(sock->name, "Temperature Attribute")) { | ||||
| strcpy(((bNodeSocketValueString *)sock->default_value)->value, "temperature"); | strcpy(((bNodeSocketValueString *)sock->default_value)->value, "temperature"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void node_shader_gpu_volume_attribute(GPUMaterial *mat, | |||||
| const char *name, | |||||
| GPUNodeLink **outcol, | |||||
| GPUNodeLink **outvec, | |||||
| GPUNodeLink **outf) | |||||
| { | |||||
| if (strcmp(name, "density") == 0) { | |||||
| GPU_link(mat, | |||||
| "node_attribute_volume_density", | |||||
| GPU_builtin(GPU_VOLUME_DENSITY), | |||||
| outcol, | |||||
| outvec, | |||||
| outf); | |||||
| } | |||||
| else if (strcmp(name, "color") == 0) { | |||||
| GPU_link( | |||||
| mat, "node_attribute_volume_color", GPU_builtin(GPU_VOLUME_COLOR), outcol, outvec, outf); | |||||
| } | |||||
| else if (strcmp(name, "flame") == 0) { | |||||
| GPU_link( | |||||
| mat, "node_attribute_volume_flame", GPU_builtin(GPU_VOLUME_FLAME), outcol, outvec, outf); | |||||
| } | |||||
| else if (strcmp(name, "temperature") == 0) { | |||||
| GPU_link(mat, | |||||
| "node_attribute_volume_temperature", | |||||
| GPU_builtin(GPU_VOLUME_FLAME), | |||||
| GPU_builtin(GPU_VOLUME_TEMPERATURE), | |||||
| outcol, | |||||
| outvec, | |||||
| outf); | |||||
| } | |||||
| else { | |||||
| *outcol = *outvec = *outf = NULL; | |||||
| } | |||||
| } | |||||
| static int node_shader_gpu_volume_principled(GPUMaterial *mat, | static int node_shader_gpu_volume_principled(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| /* Test if blackbody intensity is enabled. */ | /* Test if blackbody intensity is enabled. */ | ||||
| bool use_blackbody = (in[8].link || in[8].vec[0] != 0.0f); | bool use_blackbody = (in[8].link || in[8].vec[0] != 0.0f); | ||||
| /* Get volume attributes. */ | /* Get volume attributes. */ | ||||
| GPUNodeLink *density = NULL, *color = NULL, *temperature = NULL; | GPUNodeLink *density = NULL, *color = NULL, *temperature = NULL; | ||||
| for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | ||||
| if (sock->typeinfo->type != SOCK_STRING) { | if (sock->typeinfo->type != SOCK_STRING) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bNodeSocketValueString *value = sock->default_value; | bNodeSocketValueString *value = sock->default_value; | ||||
| GPUNodeLink *outcol, *outvec, *outf; | const char *attribute_name = value->value; | ||||
| if (attribute_name[0] == '\0') { | |||||
| continue; | |||||
| } | |||||
| if (STREQ(sock->name, "Density Attribute")) { | if (STREQ(sock->name, "Density Attribute")) { | ||||
| node_shader_gpu_volume_attribute(mat, value->value, &outcol, &outvec, &density); | density = GPU_volume_grid(mat, attribute_name); | ||||
| } | } | ||||
| else if (STREQ(sock->name, "Color Attribute")) { | else if (STREQ(sock->name, "Color Attribute")) { | ||||
| node_shader_gpu_volume_attribute(mat, value->value, &color, &outvec, &outf); | color = GPU_volume_grid(mat, attribute_name); | ||||
| } | } | ||||
| else if (use_blackbody && STREQ(sock->name, "Temperature Attribute")) { | else if (use_blackbody && STREQ(sock->name, "Temperature Attribute")) { | ||||
| node_shader_gpu_volume_attribute(mat, value->value, &outcol, &outvec, &temperature); | temperature = GPU_volume_grid(mat, attribute_name); | ||||
| } | } | ||||
| } | } | ||||
| /* Default values if attributes not found. */ | /* Default values if attributes not found. */ | ||||
| if (!density) { | if (!density) { | ||||
| static float one = 1.0f; | static float one = 1.0f; | ||||
| density = GPU_constant(&one); | density = GPU_constant(&one); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||