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:
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c2
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c5
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c5
4 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 2d76e793fc0..39c3119cc39 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -478,7 +478,7 @@ static void codegen_call_functions(DynStr *ds, GPUNodeGraph *graph, GPUOutput *f
BLI_dynstr_appendf(ds, "cons%d", input->id);
}
else if (input->source == GPU_SOURCE_ATTR) {
- BLI_dynstr_appendf(ds, "var%d", input->attr->id);
+ codegen_convert_datatype(ds, input->attr->gputype, input->type, "var", input->attr->id);
}
BLI_dynstr_append(ds, ", ");
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index c890d56994f..fdf8ba172cb 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -132,7 +132,10 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
case GPU_NODE_LINK_ATTR:
input->source = GPU_SOURCE_ATTR;
input->attr = link->attr;
- input->attr->gputype = type;
+ /* Failsafe handling if the same attribute is used with different datatypes for
+ * some reason (only really makes sense with float/vec2/vec3/vec4 though). This
+ * can happen if mixing the generic Attribute node with specialized ones. */
+ CLAMP_MIN(input->attr->gputype, type);
break;
case GPU_NODE_LINK_CONSTANT:
input->source = (type == GPU_CLOSURE) ? GPU_SOURCE_STRUCT : GPU_SOURCE_CONSTANT;
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
index 10e1b4563bc..631d91c89d6 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
@@ -1,6 +1,7 @@
-void node_attribute(vec3 attr, out vec4 outcol, out vec3 outvec, out float outf)
+void node_attribute(vec4 attr, out vec4 outcol, out vec3 outvec, out float outf, out float outalpha)
{
- outcol = vec4(attr, 1.0);
- outvec = attr;
- outf = avg(attr);
+ outcol = vec4(attr.xyz, 1.0);
+ outvec = attr.xyz;
+ outf = avg(attr.xyz);
+ outalpha = attr.w;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 4fd0ce4f1ef..37472aeec2e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -25,6 +25,7 @@ static bNodeSocketTemplate sh_node_attribute_out[] = {
{SOCK_RGBA, N_("Color")},
{SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
+ {SOCK_FLOAT, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR},
{-1, ""},
};
@@ -52,6 +53,10 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
if (out[2].hasoutput) {
out[2].link = GPU_volume_grid(mat, attr->name, GPU_VOLUME_DEFAULT_0);
}
+ if (out[3].hasoutput) {
+ static const float default_alpha = 1.0f;
+ out[3].link = GPU_constant(&default_alpha);
+ }
return 1;
}