attribute wrangling

   1939   6   2
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Hi,

quick question. Let's say, I have 2 geometry nodes, put them into the first 2 inputs of a Attribute Wrangle node and then I want to extract an attribute from the 2nd Geo and use it in VEX.
I use `point(1, “P”, @ptnum)` to get the position vector of a point, but is it possible to get just a single float attribute, without having to write the whole 3float vector?
What I do now, is declaring a temporary variable and extracting the value from there:

vector temp = point(1, "P", @ptnum);
f@myattrib = temp.y;

basically, is there a way to copy the ‘y’ coordinate directly to ‘myattrib’ from the points in input 1, without initializing the temporary variable? (I am just guessing, but initializing the temp variable seems like an unnecessary operation, that could potentially cause performance issues if used too often in complex geometries)
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
With this function (point) it doesn't allow you to selectively return one element of the vector.

Or at least the many different ways I have tried.

But at the same time I've never experienced any performance issues when using it often in many different aspects of my scene either.

You could always turn on performance monitor to compare how much relative to other parts of your scene that there is/isn't an issue.

Also, for your own research you could set up two different approaches that give the same result with one using the example like above and another directly accessing one of the attributes vector values like,

f@myattrib = @P.y;

Then just keep pumping up the complexity until you see noticable differences.
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
I had the same question a while ago. The answer was to cast the vector:
f@myattrib = vector( point(1, "P", @ptnum) ).y;
Edited by Konstantin Magnus - Oct. 21, 2017 16:39:47
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Ay…the one way I didn't try.

Tried…(point(1,“P”, @ptnum).y
…float((point(1,“P”, @ptnum)).y

But a vector caste…interesting, since it returns a vector to begin with.

So I'm wondering if casting as a vector is actually doing the same thing interally as creating a temporary variable?

Or maybe this method is doing something like an internal pointer, with the vector caste letting the compiler know to look at the return value as a vector?..or something like that.

Either way, it helps keep the written code shorter to look at.

And now I know there's lots of other vex functions I can take this approach too.

Thanks for showing this Konstantin.
Edited by BabaJ - Oct. 21, 2017 18:06:33
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Thanks! this is really cool.
User Avatar
Member
8598 posts
Joined: July 2007
Offline
BabaJ
…So I'm wondering if casting as a vector is actually doing the same thing interally as creating a temporary variable?

Or maybe this method is doing something like an internal pointer, with the vector caste letting the compiler know to look at the return value as a vector?..or something like that…

it essentially gets the full vector value from the attribute exactly like having a variable, I suppose performance wise it'll be the same too
it's not casting the result of the function to different type, you are simply providing hint to Houdini which function representation to use
so vector(point()), will say that you want to get vector value from an attribute
the sme way using vector x = point(); will load attribute as vector
however doing just this point().y will not provide enough information, therefore vector(point()).y is necessary
on the other hand float(point()) would force it return just first component of the attribute value
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Thanks Tomas for the input…gives more clarity on the matter.
  • Quick Links