Accessing attributes of a specific point index

Wondering if there’s a POP way to access a specific index from the array of available points when performing an arbitrary operation. Example: I want to create a new attribute in the MathMix POP for a current point that depends on information on some other point. Something like

newAttribute = someAttribute[currentIndex] + someAttribute[previousIndex] 

For a sum I could use an accumulate POP, but is it possible in a more general way (if needing operations other than addition), or coding it is the only way to go? And if have to code it, how would I make such a reference in a GLSL POP?

Not sure how general or useful this feature would be, and therefore if it justifies a RFE… but tinkering around with an idea I suddenly find myself needing this feature :sweat_smile: I don’t mind writing it in GLSL of course, but I thought asking it in case that a) it is already possible or b) you may find it useful to implement in the future.

Best,
Darien

1 Like

Hi Darien,

With the GLSL POP it would be as simple as

	if(id > 0)
		Res[id] = iP[id].y + iP[id - 1].y;
	else
		Res[id] = 0;

Otherwise you could use an attribute lookup to lookup the attribute with an offset of 1, and combine that in the math mix, or merge (append) a point at the beginning to create this offset.

The GLSL way is a bit more efficient since you don’t have to create a copy of the attribute though. See toe, let me know if it makes sense. Otherwise it does seem a bit specific to turn that into an RFE for now :smiley:

AttributeIndexSum.toe (4.5 KB)

Hi Vincent,

Fantastic, thanks! It all makes sense :smiley:

Vincent alluded to this: The Lookup Attribute POP lets you get at attributes of other points via their index.

1 Like

There are some examples of Lookup Attribute in Examples/Overview.toe /InterFamilyPOPs

1 Like

Awesome, thanks Greg!