From 9bc177d8ded4ba498762813a0d5106005fef0e67 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 4 Aug 2020 17:56:39 +0300 Subject: Materials: support true float4 attributes in the Attribute node. Add a new Alpha socket to the Attribute node that outputs the fourth component of the attribute. Currently the only such attribute is vertex color, but there may be more in the future. If the attribute has no alpha channel, the expected value is 1. The Cycles code is already refactored and committed by Brecht. Ref D2057 --- source/blender/nodes/shader/nodes/node_shader_attribute.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/nodes') 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; } -- cgit v1.2.3