Jump to content

How to know the correct attribute name to use in expressions?


magneto

Recommended Posts

I see a lot of attribute names, but they seem a little intuitive to use because when I middle click a POP, it shows that I have attributes like:

v accel life pstate id parent rot w torque Cd

The details view show them as

accel[x] accel[y] accel[z] life[0] life[1] w[x] w[y] w[z] Cd[0] Cd[1] Cd[2]

I know some of them are vectors/compound values like accel, Cd, etc, but is the convention based on index operator [] that supports integers and strings, or is it just a case of showing the properties like x, y, z and vector elements via integers?

Not sure if what I am asking makes sense, but basically wondering about 3 additional points, in case the above questions are too technical.

1. Are all attributes accessed using uppercase letters regardless of their uppercase/lowercase state?

2. How can I know if the attributes should be accessed like CR for the first component of a color attribute, vs VX for the first component of a (Velocity) vector? Can I do V[0] or V.X, etc?

3. How come everywhere shows that I have an attribute called accel, yet it's not accessed using ACCELX, or ACCELY, but AX, AY?

A lot of times I am asking myself how to access attributes and what they would be called other than the ones I have already used like CR, CD, etc, but even then any pointers would be very useful.

Thanks all :)

Edited by magneto
  • Like 2
Link to comment
Share on other sites

1. Are all attributes accessed using uppercase letters regardless of their uppercase/lowercase state?

2. How can I know if the attributes should be accessed like CR for the first component of a color attribute, vs VX for the first component of a (Velocity) vector? Can I do V[0] or V.X, etc?

AFAIK Its always uppercase.

Check the details view for type.

For example take velocity , its shown as v[x],v[y],v[z] and can be accessed using whats inside the [ ], in this case X,Y,Z

hence $VX,$VY,$VZ

For 2, 3 or more Floats numbering starts at 1,like Cd it shows Cd[1], Cd[2], Cd[3]

you can access it using $CD1,$CD2,$CD3 or $CR,$CG,$CB for convenience.

if accessing attributes using functions like point, regular indexing will follow. x= [0],y = [1], z = [2]....

3. How come everywhere shows that I have an attribute called accel, yet it's not accessed using ACCELX, or ACCELY, but AX, AY?

Its because variable mapping is lost for some / custom attributes which come out of pops.

Just put down a attrib create name it accel, type vector, values $ACCELX $ACCELY $ACCELZ

and they are ready to be accessed.

Not sure about what you mean here by AX,AY.

Cheers!!

Edited by vectorblur
  • Like 1
Link to comment
Share on other sites

Houdini's default convention is all cap, but it doesn't has to be all cap. However, following Houdini's convention will make it easier for other people who may be debugging your file tho.

Those variables are simply attribute variable mappings. It simply makes it easier for you to access an attribute else where down the node chain. Another type of variable are the global variable, as can be done in Edit -> Variables and Aliases menu (ie. $PI). These are also accessible in similar convention as attribute variables, except these variables cannot vary on per-point/prim/vertex basis.

Without these variable mappings, you'd have to use functions such as point(), prim(), vertex() to access an attribute information. As you can see, your parameter gets longer and harder to read. And to an except, may be a little slower too.

As for some of those default operator related variable mappings such as $CR, $VX, $ACCELX, etc, you'll have to look at the help card for these. Once you've used them long enough, they'll come almost naturally to you..

You can also RMB on a node and select "Extended Information". In there, you will be able to find information wrt whether an attribute data type is 3-float or vector type, etc.

POPs don't behave quite like SOPs. In a way, you almost want to think of POPnet as single SOP node, in which you are defining the rules of particle behaviour inside a SOP node. If this makes any sense.

HTH

-A.

  • Like 1
Link to comment
Share on other sites

Thanks guys for your replies.

@vectorblur: Are you sure I can do $CD1, $V1, etc? I tried them but they don't seem to work (turns to error state).

Also when you said "if accessing attributes using functions like point, regular indexing will follow. x= [0],y = [1], z = [2]....", I am not sure what you mean. Can you please give more detail? I haven't used that function, but if you can maybe post a small expression, I would understand it better.

AX, AY are what ACCELX and ACCELY is AFAIK. Might be wrong.

@Alex, same thing for point, prim, vertex functions. I haven't seen them before. Are they used in expressions?

Your POPnet analogy is useful, thanks.

Link to comment
Share on other sites

Magneto,

Some sops don't allow you to use point variables for various reasons, therefore you need to use a point() expression.

$CD1 does work in point sop.

I don't completely understand why variables need special mappings but if you lay down an attribute create sop, you have 2 fields, one is Name and the other is Local Mappings. So if you put test in the name field (all lower) and say var (again all lower) in local mappings, your details will show you the name of the variable is test, but lay down a point sop and neither $TEST nor $test will work. but $var will (all lower), change the local variable mapping to VAR and you still have the name test but accessed via $VAR, leave it blank and it defaults to all caps of the name, $TEST.

MMB on a node and see under variable mappings what is mapped to what. Vops also doesn't add mappings, so often you need to map non standard attributes via the attribute create node; just uncheck 'write values' and this simply creates a mapping.

clear as mud? :blink:

Link to comment
Share on other sites

to clarify i believe vector attr like acc and vel are accessed by vx vy etc and arrays of floats like cd are accessed as cd0 cd1 etc. Hope this helps.

Actually spev cd is accessed CD1 CD2 CD3.

Both vectors and 3 floats are arrays, so index 0 is always first, whether it's 0 or 1 or x. I myself have expressed confusion over this before. so when we see [] this means array, and the number inside is the index of the array... so in a 3 float array, while it's name is var[0] it's mapping is $VAR1, whereas a vector is var[x] and it's mapping is $VARX. but in a point expression...

point("../node",$PT,"var",0), 0 will always access the the first index of the attribute...

Link to comment
Share on other sites

Man how much do I owe Peter... =] Thanks for the link!

Ok, that finally answered my question, why 3 floats vs Vector; what is the difference?

You answered it before Magneto, but I didn't quite follow, but as usual peter breaks it down.

'A vector attribute will be transformed into it's relevant coordinate system'

Now that is some valuable info... And that would explain why 3 floats will process slightly faster than a vector... it all makes perfect sense now...

Edited by 3dbeing
Link to comment
Share on other sites

1. Are all attributes accessed using uppercase letters regardless of their uppercase/lowercase state?

The point is, you are confusing attributes with local variables. It is easy to do, as they are 'almost' the same thing, and are not separated clearly as they could (by a single convention). Variables are most of the time shortcuts to attributes, but this isn't a rule. There isn't 'BB' attribute, which would be pointed by $BBY variable. Instead some nodes establish BB[XYZ] to simplify access to internal Houdini quality. Read this for decent explanation (specially tstex's one).

2. How can I know if the attributes should be accessed like CR for the first component of a color attribute, vs VX for the first component of a (Velocity) vector? Can I do V[0] or V.X, etc?

Variables components are named by a convention, albeit minor margin of developers' creativity has happened to take place here. I suppose for a legacy reasons. Help for a particular node list them correctly and is a last stand for us. Variables are either created by a node itself in C++ code, and its a matter of good programmers habit to name them coherently, or by variables' mapping as already explained. Take a look on the variables in DOPs, which are much newer than the rest of Houdini's code. It exposes nicely, how SESI has changed they thinking about variables.

3. How come everywhere shows that I have an attribute called accel, yet it's not accessed using ACCELX, or ACCELY, but AX, AY?

Every node provides variables on its own rules. Since many of nodes do similar things, they support the same variables, but it doesn't have to be the case. There is local variables $VX because many years ago (perhaps in times there was no generic machanism to create variables from attributes) it was a choice of programmers. It's a legacy. Attributes are consistent, since they are *the same* thing down the chain.

A lot of times I am asking myself how to access attributes and what they would be called other than the ones I have already used like CR, CD, etc, but even then any pointers would be very useful.

... how to access variables :). They are always listed in Help of a node. Attributes are accessible with expressions like point(), prim(), vertex(), detail().

cheers,

skk.

Edited by SYmek
  • Like 1
Link to comment
Share on other sites

Thanks guys, very useful replies.

The attributes still confuse me on some points like according to the docs $LIFE supposed to return a value between 0-1, but I am not getting that, but also getting a compound value in the Details View:

eyyjg.png

Any ideas for why this happens?

I have selected a Force POP that comes after a Source POP if that matters.

EDIT: @Symek, Just saw your reply. Will read it now ;)

Edited by magneto
Link to comment
Share on other sites

Yup, another one of those gotcha's. So there is life[0], name, life[1], name, and $LIFE, variable.

life[0] = Age (in seconds)

life[1] = Life Expectancy (in seconds)

$LIFE = normalized age or life[0]/life[1]

Thanks 3dbeing, you are the man :)

In that case, is there a way to display $LIFE in Details View?

Link to comment
Share on other sites

lol that's weird, but it will do :)

Now that I think about it, the best way is really to pipe $LIFE into a color channel, whatever you want 1 or all, but then you have the added benefit if visualizing $LIFE in the viewport, once you don't need it anymore just disable the node...

Link to comment
Share on other sites

Now that I think about it, the best way is really to pipe $LIFE into a color channel, whatever you want 1 or all, but then you have the added benefit if visualizing $LIFE in the viewport, once you don't need it anymore just disable the node...

That seems like a very useful way to see the life of particles. Thanks man :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...