Geometry Nodes: Add color to boolean implicit conversion

This conversion works the same way as a combination of the existing
color to float3 to boolean conversions, so the boolean result will be
false if the color is black, otherwise true, and the alpha is ignored.
This commit is contained in:
Hans Goudey 2021-03-10 10:51:44 -05:00
parent 7f07eff588
commit 1e7b2d0bc6
1 changed files with 3 additions and 0 deletions

View File

@ -206,6 +206,9 @@ static DataTypeConversions create_implicit_conversions()
return (a) ? Color4f(1.0f, 1.0f, 1.0f, 1.0f) : Color4f(0.0f, 0.0f, 0.0f, 1.0f);
});
add_implicit_conversion<Color4f, bool>(conversions, "Color4f to boolean", [](Color4f a) {
return a.r == 0.0f && a.g == 0.0f && a.b == 0.0f;
});
add_implicit_conversion<Color4f, float>(
conversions, "Color4f to float", [](Color4f a) { return rgb_to_grayscale(a); });
add_implicit_conversion<Color4f, float2>(