← All ideas
  • Published 18 Jan 2023

Inverse index sampling

Hello,

originally from here (sorry): devtalk.blender.org/t/transfer-attribute-node-inverse-index-mapping/26181

I have a node network where I'm working with mesh islands and eventually need to associate various things with each other later in the graph which originally had the same captured mesh island index earlier in the graph.

To associate the properties with each other, I'm artificially making coordinates out of the old mesh island ids and using sample nearest to match up the data. The way my problem is set up, I need to work with the captured attribute and must do it this way.

When I was deeply into it, I realized that my case could be simplified a lot if there was a way to do index sampling on the destination instead of on the source.

The way I understand index sampling right now, it basically works like this:
for (i++) {DestinationGeometry[i] = SourceGeometry[IndexField[i]];}

I need the indirection through the index field on the other side:
for (i++) {DestinationGeometry[IndexField[i]] = SourceGeometry[i];}

I've thought about the issue for a long time and couldn't come up with any other way to do it than expressing this as coordinates and misusing sample nearest to solve it.

Given this mapping:
id_a → id_b data
0 → 0 q
1 → 2 w
2 → 3 e
3 → 1 r
4 → 4 t

If I wanted to map back a data sequence [q, r, w, e, t] from id_b to id_a, I’d need an index sequence of [0, 3, 1, 2, 4] on the right-hand side in the already supported normal index sampling mode. I can’t think of any other way to compute exactly this sequence.

If an inverse index mapping was supported, it’d be like this:
Dst[0] = q
Dst[2] = w
Dst[3] = e
Dst[1] = r
Dst[4] = t

I'm aware that if this was supported, there could be gaps that are not mapped to by any index -- these gaps could be filled with the neutral element for the target domain.

Hope this makes sense. :)

0%

Development Status: Open

Upvote 0 Downvote 0
Hai
18 Jan 2023

4 Comments

modormoder

Can you take a look at this and his video examples? developer.blender.org/D16928 This seems to be the solution to your problem...

1
Hai Author

Hm yes, it looks to me like it would solve my problem class!

modormoder

builder.blender.org/download/patch/archive/D16928/ I requested a build of this about a month ago, but it looks like you can still test it.