Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c34
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_info.c26
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_principled.c47
3 files changed, 34 insertions, 73 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index fa0b8955c58..6b5d46e250b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -42,28 +42,18 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
{
NodeShaderAttribute *attr = node->storage;
- /* FIXME : if an attribute layer (like vertex color) has one of these names,
- * it will not work as expected. */
- if (strcmp(attr->name, "density") == 0) {
- return GPU_stack_link(
- mat, node, "node_attribute_volume_density", in, out, GPU_builtin(GPU_VOLUME_DENSITY));
- }
- else if (strcmp(attr->name, "color") == 0) {
- return GPU_stack_link(
- mat, node, "node_attribute_volume_color", in, out, GPU_builtin(GPU_VOLUME_COLOR));
- }
- else if (strcmp(attr->name, "flame") == 0) {
- return GPU_stack_link(
- mat, node, "node_attribute_volume_flame", in, out, GPU_builtin(GPU_VOLUME_FLAME));
- }
- else if (strcmp(attr->name, "temperature") == 0) {
- return GPU_stack_link(mat,
- node,
- "node_attribute_volume_temperature",
- in,
- out,
- GPU_builtin(GPU_VOLUME_FLAME),
- GPU_builtin(GPU_VOLUME_TEMPERATURE));
+ if (GPU_material_is_volume_shader(mat)) {
+ if (out[0].hasoutput) {
+ out[0].link = GPU_volume_grid(mat, attr->name);
+ }
+ if (out[1].hasoutput) {
+ out[1].link = GPU_volume_grid(mat, attr->name);
+ }
+ if (out[2].hasoutput) {
+ out[2].link = GPU_volume_grid(mat, attr->name);
+ }
+
+ return 1;
}
else {
GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_info.c b/source/blender/nodes/shader/nodes/node_shader_volume_info.c
index c91c82eee6c..7ccc00f1af3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_info.c
@@ -28,21 +28,25 @@ static bNodeSocketTemplate sh_node_volume_info_out[] = {
};
static int node_shader_gpu_volume_info(GPUMaterial *mat,
- bNode *node,
+ bNode *UNUSED(node),
bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
+ GPUNodeStack *UNUSED(in),
GPUNodeStack *out)
{
+ if (out[0].hasoutput) {
+ out[0].link = GPU_volume_grid(mat, "color");
+ }
+ if (out[1].hasoutput) {
+ out[1].link = GPU_volume_grid(mat, "density");
+ }
+ if (out[2].hasoutput) {
+ out[2].link = GPU_volume_grid(mat, "flame");
+ }
+ if (out[3].hasoutput) {
+ out[3].link = GPU_volume_grid(mat, "temperature");
+ }
- return GPU_stack_link(mat,
- node,
- "node_volume_info",
- in,
- out,
- GPU_builtin(GPU_VOLUME_DENSITY),
- GPU_builtin(GPU_VOLUME_COLOR),
- GPU_builtin(GPU_VOLUME_FLAME),
- GPU_builtin(GPU_VOLUME_TEMPERATURE));
+ return true;
}
void register_node_type_sh_volume_info(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
index d82ef1a03e9..92e1b3435c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
@@ -54,42 +54,6 @@ static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *
}
}
-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,
bNode *node,
bNodeExecData *UNUSED(execdata),
@@ -108,16 +72,19 @@ static int node_shader_gpu_volume_principled(GPUMaterial *mat,
}
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")) {
- 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")) {
- 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")) {
- node_shader_gpu_volume_attribute(mat, value->value, &outcol, &outvec, &temperature);
+ temperature = GPU_volume_grid(mat, attribute_name);
}
}