Jump to content

Attributes And Variables


Recommended Posts

I have some doubts about attributes and local variables in houdini.

In POP context almost every attribute has his corresponding local variable, so you can access to the value of the attribute using the local variable instead the point () expression. This local variables are well documented.

In SOP, when i merge a particle system using POPMerge SOP, the particles attributes are inherited but the local variables aren't the same, for example for the life attribute, in POP it is a float, but in SOP is a float[2], but i can use the $LIFE local variable in some situations. For a normal expression the $LIFE variable in SOP returns zero, but for example if i create a new string attribute using the AttributeCreate SOP, in the value field i can use:

test.`padzero(4, $LIFE * 25)`.rat

And then the $LIFE variable returns a correct value, like the $LIFE variable in POP context.

Another example, in the doc seems like SOP doesn't have local variables by default like POP, only those variables added by some operators, when an operator add a new variable it's only accesible from this operator, or is accesible for the rest of the network? In SOP is supposed that for example the $PT variable is added by Point SOP, but i can access this variable from other SOP's, without having any Point SOP in the network.

So my question is what is the relationship between attributes and local variables?

For every attribute there is a local variable?

Thanks

Link to comment
Share on other sites

So my question is what is the relationship between attributes and local variables?

For every attribute there is a local variable?

Thanks

18325[/snapback]

It's something no one has every clarified for me either but my best guesstimate..

An attiribute is an abitrary named value attached to a primitive. In order to access those attributes in an expression you need to map them to a local variable, which I guess is something like a pointer. So, what I do, is like you said, add the attribute to get the local variable mapped so I can access the attributes.

Link to comment
Share on other sites

Basically, it's operators which loop through their geometry like Point, Primitive, AttribCreate which have local variables. AttribCreate allows you to create your own local variable to attribute mappings for use downstream. In POPs, it's all the operators which is why you get local variable automatically.

Link to comment
Share on other sites

Ok edward, so operators are the owners of the local variables not? they create them to give an easier wa yto access to attributes.

In POPs all the operators have local variables to access to their attributes.

In SOPs if i have an attribute and i want a local variable to be mapped to it, i have to use AttributeCreate to create the local variable, and this variable will be ready for the next nodes in the network.

But i'm no understand why the example that i have posted before about the string attribute works.

And if i use the AttributeCreateSop it will create a new attribute, but what if i only want to attach a local variable to a existing attribute, without creating a new one?

Thanks

Link to comment
Share on other sites

Ok edward, so operators are the owners of the local variables not? they create them to give an easier wa yto access to attributes.

You got it. :)

The AttribCreate SOP itself creates local variables for its own parameters which I'm guessing LIFE is one of them. This is the explanation I think for your string attribute case. Someone else noted that the backticks are not necessary and you can just as easily use LIFE in any attribute type.

As for creating convenience variables for attributes that already exist, just use the AttribCreate SOP with a matching attribute specification. You will need use $ATTRIB where ATTRIB is the name of your local variable again in the value parameter to avoid changing the values. So to create a LIFE variable mapping that can be more generally used, append an AttribCreate SOP with the Name set to "life" and the Size to "2". In the Value parameter, use $LIFE1 and $LIFE2.

Link to comment
Share on other sites

The AttribCreate SOP itself creates local variables for its own parameters which I'm guessing LIFE is one of them. This is the explanation I think for your string attribute case. Someone else noted that the backticks are not necessary and you can just as easily use LIFE in any attribute type.

In the docs says that the locals for AttribCreateSOP are the standard local variables, so i guees that the local variable that you can see in the Particles attributes and variables chapter are the standard local variables in Houdini because i have tried to use variables like $AGE, $CA or $DRAG from the AttribCreateSOP and all works fine, and if you see the Point SOP many of the variables are the same that the POP variables.

And yes, i haven't need to use backticks.

As for creating convenience variables for attributes that already exist, just use the AttribCreate SOP with a matching attribute specification. You will need use $ATTRIB where ATTRIB is the name of your local variable again in the value parameter to avoid changing the values. So to create a LIFE variable mapping that can be more generally used, append an AttribCreate SOP with the Name set to "life" and the Size to "2". In the Value parameter, use $LIFE1 and $LIFE2.

18379[/snapback]

I have tried to create another variable for life using your instructions but the process failed. I use "life" for the attribute name, point, float of two and for the the values $LIFE1 and $LIFE2, in the local variable name "TEST", but i get the next error:

Unable to evaluate expression (Undefined variable /obj/model/attribcreate1/value1))

So i think that $LIFE1 and $LIFE2 don't exists, only $LIFE that gets the value life[0] / life[1]

Thanks

Link to comment
Share on other sites

So i think that $LIFE1 and $LIFE2 don't exists, only $LIFE that gets the value life[0] / life[1]

LIFE presents some unfortunate inconsistencies in the way that Houdini has evolved to handle general attributes. I believe it is the only local variable left that presents this unique useage issue. This is a known issue.

To access life(0-1), you need to use the local variables $AGE and $LIFE. There is no other way right now. You can't use $LIFE0 or $LIFE1 to access "life" so this breaks the current model for attributes. Read below for the others!

life(0) = $AGE and represents the current age in seconds of the particle.

life(1) = $AGE/$LIFE but not valid for the very first time the particle is born as $AGE = 0.

$LIFE represents life(0)/life(1) or the current particle's age divided by the particles total lifespan. I use this alot and I have never had the need to know the actual total age in seconds in all my time using Houdini.

You can readily derrive the actual time in seconds that the particle will die, life(1), by simply using $AGE/$LIFE and that will properly reconstruct life(1) except for the instant the particle is born ($AGE = 0).

ATTRIBUTE EXCEPTIONS!!!!!!

All the "old-school" local attributes have variable names that are different from the actual name of the attribute bound to the geometry. This is pure legacy in it's finest form and carrys all the way back to PRISMS (pre-cursor 3D software to Houdini).

Exceptions to the general attribute rules:

- $TX $TY $TZ to access the three components of P position: P(0), P(1) and P(2) won't work.

- $CR $CG $CB represent the three components of Cd: Cd(0) Cd(1) and Cd(2) won't work.

- $CA represents alpha so alpha itself won't work.

- $AGE and $LIFE to access life so life(0) and life(1) won't work.

- $MAPU $MAPV and $MAPW represent the three components of uv: uv(0), uv(1) and uv(2) won't work.

Position, point color, point alpha, texture uv's and particle life attributes have been around for a very long time and were given more readable names in PRISMS for whatever reasons.

I am sure that it is by shear dumb luck that $NX $NY $NZ works for "n" normals and $VX $VY and $VZ works for "v" velocity.

For those of you reading the post and are familiar with VEX and VOPs, you will notice that the global variables VOP for the SOP context has "age" and "life" available so don't confuse "life" with life(0-1). You can't use an Import Attribute VOP either to pick up "life" directly. It will return zeros.

The "life" attribute really breaks all the attribute rules.

Link to comment
Share on other sites

Thanks old school very instructive explanation.

So the attributes that you have named are the only that have inconsistencies.

Can you clear me the doubt about SOP standard local variables, they are the same that the POP standard local variables?

For VOPs, the life and age output parameters in the GlobalVariables VOP stand for $LIFE and $AGE values?

Link to comment
Share on other sites

  • 1 month later...

I'm sorry for the really really amateur question. But...

Is there a list of attributes?

How do I know what attributes are there in a spline for example? :huh: Sounds realy dumb, but I ask my self every day -"who told these guys there is a width attribute in a spline?"

I could't find anything on the help or the odwiki.

Link to comment
Share on other sites

Hey Andz,

When you MMB on a SOP, you'll be presented with the opinfo popup. If there is an attribute, it will appear below the Size, Center & Bounds section. Put down a grid SOP, append a Point SOP, Add Normals then MMB on the Point SOP & you'll see

1 Point Attributes: N[3]

Hence, if there is a width attribute, you'll see

1 Point Attributes: width[1]

For a list of local Variables, click on the Help of the SOP & in the Helpcard, click on the Locals tab.

Cheers!

steven

Link to comment
Share on other sites

Hey Andz,

When you MMB on a SOP, you'll be presented with the opinfo popup. If there is an attribute, it will appear below the Size, Center & Bounds section.

19324[/snapback]

Thanks steven that worked but just made me realize that I still have a lot to learn about the new/different consepts Houdini has. I'm going back to documentations and tutorials, because I have no ideia how and why to work with point SOP, attributes, etc. I hope to clear all this out, and one day be able to contribute to the MigratingFromOtherSoftware in the Wiki.

Link to comment
Share on other sites

  • 4 weeks later...
Hey Andz,

When you MMB on a SOP, you'll be presented with the opinfo popup. If there is an attribute, it will appear below the Size, Center & Bounds section. Put down a grid SOP, append a Point SOP, Add Normals then MMB on the Point SOP & you'll see

1 Point Attributes: N[3]

Hence, if there is a width attribute, you'll see

1 Point Attributes: width[1]

For a list of local Variables, click on the Help of the SOP & in the Helpcard, click on the Locals tab.

Cheers!

steven

19324[/snapback]

am I wrong.. or this (local tab for variable) doenst work in Houdini 8 anymore?... i cant find the page where variable/attributes are... now the "webbrowser" style help popsup but doenst shows me such variables anymore... what i'm forgetting?

I can MMB on the icon and see details.. but i cant see the local variables in th property help page which was a popup window afaik.

cheers.

Link to comment
Share on other sites

  • 5 years later...

life(0) = $AGE and represents the current age in seconds of the particle.

life(1) = $AGE/$LIFE but not valid for the very first time the particle is born as $AGE = 0.

Resurrecting an old thread. I always understood life[1] was the maximum life of the particle in seconds? I do not see the life[1] value change over the particle's lifespan usually.

Also, is there a way to get life[1] directly in a vop pop? Durr, figured that out. Question above still stands.

Edited by GallenWolf
Link to comment
Share on other sites

You're looking at the details view or spreadsheet aren't you Alvin.

Welcome to old school Houdini.

POPs were introduced in to Houdini way back in version 2.0 where custom attributes were not well formed and every implementation seemed to be unique. You guys are spoiled what with creating all these custom attributes bloating memory and such. I remember when... Awww. I give up. :P

$AGE = current age of particles in seconds

$LIFE = Current percentage of life consumed

life[0] = current age of particles in seconds equal to $AGE

life[1] = total lifespan of particle, period. It's a constant value.

The life attribute in the details view is not what $AGE and $LIFE return as local variables as you noticed. You also can't inherit the default "life" attribute as is in to VOPs either. The VOP POP provides you age and life as globals that are equivalent to $AGE and $LIFE and not the actual life attribute.

If you want to replicate life[1] as it exists in the spreadsheet, just divide $AGE/$LIFE as I mentioned in that post you referenced. Again the only caveat is that on the particle birth frame, this will evaluate to 0 so you have to wait a timestep if you have some logic that needs to know the total lifespan of the particle in question.

Edited by old school
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...