Differential D10978 Diff 36325 source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
| Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | static void execute_on_component(GeometryComponent &component, const GeoNodeExecParams ¶ms) | ||||
| const std::string mapping_name = params.get_input<std::string>("Mapping"); | const std::string mapping_name = params.get_input<std::string>("Mapping"); | ||||
| if (!component.attribute_exists(mapping_name)) { | if (!component.attribute_exists(mapping_name)) { | ||||
| return; | return; | ||||
| } | } | ||||
| const AttributeDomain result_domain = get_result_domain( | const AttributeDomain result_domain = get_result_domain( | ||||
| component, result_attribute_name, mapping_name); | component, result_attribute_name, mapping_name); | ||||
| OutputAttribute_Typed<Color4f> attribute_out = | OutputAttribute_Typed<ColorGeometry4f> attribute_out = | ||||
| component.attribute_try_get_for_output_only<Color4f>(result_attribute_name, result_domain); | component.attribute_try_get_for_output_only<ColorGeometry4f>(result_attribute_name, | ||||
| result_domain); | |||||
| if (!attribute_out) { | if (!attribute_out) { | ||||
| return; | return; | ||||
| } | } | ||||
| GVArray_Typed<float3> mapping_attribute = component.attribute_get_for_read<float3>( | GVArray_Typed<float3> mapping_attribute = component.attribute_get_for_read<float3>( | ||||
| mapping_name, result_domain, {0, 0, 0}); | mapping_name, result_domain, {0, 0, 0}); | ||||
| MutableSpan<Color4f> colors = attribute_out.as_span(); | MutableSpan<ColorGeometry4f> colors = attribute_out.as_span(); | ||||
| for (const int i : IndexRange(mapping_attribute.size())) { | for (const int i : IndexRange(mapping_attribute.size())) { | ||||
| TexResult texture_result = {0}; | TexResult texture_result = {0}; | ||||
| const float3 position = mapping_attribute[i]; | const float3 position = mapping_attribute[i]; | ||||
| /* For legacy reasons we have to map [0, 1] to [-1, 1] to support uv mappings. */ | /* For legacy reasons we have to map [0, 1] to [-1, 1] to support uv mappings. */ | ||||
| const float3 remapped_position = position * 2.0f - float3(1.0f); | const float3 remapped_position = position * 2.0f - float3(1.0f); | ||||
| BKE_texture_get_value(nullptr, texture, remapped_position, &texture_result, false); | BKE_texture_get_value(nullptr, texture, remapped_position, &texture_result, false); | ||||
| colors[i] = {texture_result.tr, texture_result.tg, texture_result.tb, texture_result.ta}; | colors[i] = {texture_result.tr, texture_result.tg, texture_result.tb, texture_result.ta}; | ||||
| } | } | ||||
| Show All 37 Lines | |||||