Differential D10978 Diff 36166 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 88 Lines • ▼ Show 20 Lines | OutputAttributePtr attribute_out = component.attribute_try_get_for_output( | ||||
| result_attribute_name, result_domain, CD_PROP_COLOR); | result_attribute_name, result_domain, CD_PROP_COLOR); | ||||
| if (!attribute_out) { | if (!attribute_out) { | ||||
| return; | return; | ||||
| } | } | ||||
| Float3ReadAttribute mapping_attribute = component.attribute_get_for_read<float3>( | Float3ReadAttribute 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->get_span<Color4f>(); | MutableSpan<ColorGeometry> colors = attribute_out->get_span<ColorGeometry>(); | ||||
| 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 | |||||