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:
authorJacques Lucke <jacques@blender.org>2020-12-03 18:25:48 +0300
committerJacques Lucke <jacques@blender.org>2020-12-03 18:25:48 +0300
commit107231eb956a953c89a2ab134371988ebe338c59 (patch)
treeb8e46bf488b089766e5f2e41dd9affd096efd38c /source/blender/nodes
parent2c181521ec0c4e0fca579fb512801410570800fb (diff)
Geometry Nodes: improve support for Color attributes
* Add typed attribute accessors for color attributes. * Support implicit conversions between colors and floats.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/NOD_geometry_exec.hh2
-rw-r--r--source/blender/nodes/intern/node_tree_multi_function.cc4
2 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 2b95f76d06b..fde576d7429 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -26,6 +26,8 @@
namespace blender::nodes {
+using bke::Color4fReadAttribute;
+using bke::Color4fWriteAttribute;
using bke::Float3ReadAttribute;
using bke::Float3WriteAttribute;
using bke::FloatReadAttribute;
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index 8440e996651..ec5527a2970 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -204,6 +204,10 @@ static DataTypeConversions create_implicit_conversions()
conversions, "float3 to Color4f", [](float3 a) { return Color4f(a.x, a.y, a.z, 1.0f); });
add_implicit_conversion<Color4f, float3>(
conversions, "Color4f to float3", [](Color4f a) { return float3(a.r, a.g, a.b); });
+ add_implicit_conversion<float, Color4f>(
+ conversions, "float to Color4f", [](float a) { return Color4f(a, a, a, 1.0f); });
+ add_implicit_conversion<Color4f, float>(
+ conversions, "Color4f to float", [](Color4f a) { return rgb_to_grayscale(a); });
return conversions;
}