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:
authorHans Goudey <h.goudey@me.com>2022-07-26 16:37:08 +0300
committerHans Goudey <h.goudey@me.com>2022-07-26 16:37:38 +0300
commit1998269b109f65373336087da7f9751a3c3317f3 (patch)
tree5aa1123e516fd2874fa6626dcba193aec88cacde /source/blender/nodes
parent5945a90df99b919229c876c2fd294f035e24831a (diff)
Refactor: Extract color attributes as generic attributes
Previously there was a special extraction process for "vertex colors" that copied the color data to the GPU with a special format. Instead, this patch replaces this with use of the generic attribute extraction. This reduces the number of code paths, allowing easier optimization in the future. To make it possible to use the generic extraction system for attributes but also assign aliases for use by shaders, some changes are necessary. First, the GPU material attribute can now store whether it actually refers to the default color attribute, rather than a specific name. This replaces the hack to use `CD_MCOL` in the color attribute shader node. Second, the extraction code checks the names against the default and active names and assigns aliases if the request corresponds to a special active attribute. Finally, support for byte color attributes was added to the generic attribute extraction. Differential Revision: https://developer.blender.org/D15205
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vertex_color.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
index 830f02d8df1..c636cc976e6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
@@ -42,9 +42,8 @@ static int node_shader_gpu_vertex_color(GPUMaterial *mat,
GPUNodeStack *out)
{
NodeShaderVertexColor *vertexColor = (NodeShaderVertexColor *)node->storage;
- /* NOTE: using CD_AUTO_FROM_NAME instead of CD_MCOL or CD_PROP_COLOR for named attributes
- * as geometry nodes may overwrite data which will also change the eCustomDataType.
- * This will also make EEVEE and Cycles
+ /* NOTE: Using #CD_AUTO_FROM_NAME is necessary because there are multiple color attribute types,
+ * and the type may change during evaluation anyway. This will also make EEVEE and Cycles
* consistent. See T93179. */
GPUNodeLink *vertexColorLink;
@@ -53,7 +52,7 @@ static int node_shader_gpu_vertex_color(GPUMaterial *mat,
vertexColorLink = GPU_attribute(mat, CD_AUTO_FROM_NAME, vertexColor->layer_name);
}
else { /* Fall back on active render color attribute. */
- vertexColorLink = GPU_attribute(mat, CD_MCOL, vertexColor->layer_name);
+ vertexColorLink = GPU_attribute_default_color(mat);
}
return GPU_stack_link(mat, node, "node_vertex_color", in, out, vertexColorLink);