Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryComponent &component) | ||||
| const std::string result_name = params.get_input<std::string>("Result"); | const std::string result_name = params.get_input<std::string>("Result"); | ||||
| const std::string input_name = params.get_input<std::string>("Attribute"); | const std::string input_name = params.get_input<std::string>("Attribute"); | ||||
| /* Always output a color attribute for now. We might want to allow users to customize. | /* Always output a color attribute for now. We might want to allow users to customize. | ||||
| * Using the type of an existing attribute could work, but does not have a real benefit | * Using the type of an existing attribute could work, but does not have a real benefit | ||||
| * currently. */ | * currently. */ | ||||
| const AttributeDomain result_domain = get_result_domain(component, input_name, result_name); | const AttributeDomain result_domain = get_result_domain(component, input_name, result_name); | ||||
| OutputAttribute_Typed<Color4f> attribute_result = | OutputAttribute_Typed<ColorGeometry4f> attribute_result = | ||||
| component.attribute_try_get_for_output_only<Color4f>(result_name, result_domain); | component.attribute_try_get_for_output_only<ColorGeometry4f>(result_name, result_domain); | ||||
| if (!attribute_result) { | if (!attribute_result) { | ||||
| return; | return; | ||||
| } | } | ||||
| GVArray_Typed<float> attribute_in = component.attribute_get_for_read<float>( | GVArray_Typed<float> attribute_in = component.attribute_get_for_read<float>( | ||||
| input_name, result_domain, 0.0f); | input_name, result_domain, 0.0f); | ||||
| MutableSpan<Color4f> results = attribute_result.as_span(); | MutableSpan<ColorGeometry4f> results = attribute_result.as_span(); | ||||
| ColorBand *color_ramp = &node_storage->color_ramp; | ColorBand *color_ramp = &node_storage->color_ramp; | ||||
| for (const int i : IndexRange(attribute_in.size())) { | for (const int i : IndexRange(attribute_in.size())) { | ||||
| BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]); | BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]); | ||||
| } | } | ||||
| attribute_result.save(); | attribute_result.save(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines | |||||