possible bug? global variables and setEnv

   10181   13   3
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Hey guys
I have a problem with my global Variables not updating. I created a HDA that generates global variables based on other HDA parameters by running the setenv hscript command in an expressions. The Variables update the first 2 or 3 times if im lucky then stop completly. Has anyone else had this issue. I also tried using varchange to force the variables to update the nodes that use them but as the variable doesnt update that didnt make a diffrence.

has anyone got any examples of doing this another way. Im channel referencing a parameter inside the setenv command.

Cheers
Nick
User Avatar
Member
7730 posts
Joined: July 2005
Offline
If you want changed global hscript variables to update the node parameters that use them, you have to explicitly call varchange with the names of your variables. See the help.
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
From what i can see its not the nodes picking up the change in variable thats the problem. If i check the variables in the alias and variables window the actual variable hasnt updated.
Could this be down to the expression not cooking when i change the parameter its refrencing?

Cheers
Nick
User Avatar
Member
7730 posts
Joined: July 2005
Offline
It's hard to say since I don't know your exact setup.
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
I will post a simpler example of what im trying to achieve, later on today. Should be alot easier to see whats going on.
Thanks
Nick
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Heres an example hip file of what im trying todo.

Basically Im building a global variable based on the name of the first 2 nodes jim and bob, using $OS .

The fullName node takes the naming results of both nodes and puts them together. Then sets a global var based on the compiled names.

Keep an eye on the alaises and variables windows.

For quickness I added an anooying message pop up to another node based on the gloabl var, so when it cooks etc it displays the $WHOAREYOU variable.

Just play with changing the names of the nodes and it will start not updating the global variable at times, and eventualy stops working completely.

Basically you can see that the names change on the node causes the network to cook and display the message but it hasnt updated the varaible.

Im using windows xp 64 and houdini 9.1.145

Any help with whats going would be great. Im basically wanting to pass some compiled data to a mantra node using global vars and also for overall shader control. Without having to channel reference.
Thanks
Nick

Attachments:
globalVarCooking.hip (63.7 KB)

User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Really would be great to figure out how to set global variables with some stabilty. Im guessing my problem could be a depenedancy issue?
Anyone have any thoughts on how best todo what ive got in my example scene if this is the case?
Thanks
Nick
User Avatar
Member
832 posts
Joined: July 2005
Offline
i try to steer clear of global variables for just this reason - they cant be relied on if they change a lot. i now prefer to use a top level ‘control’ object that exists in every shot with a bunch of spare parameters.
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Yeah i wanted to avoid hardcoding full/relative paths into assets which is what we reverted to now :¬/ So this global var issue is normal?
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
Behaviour hasn't changed since PRISMS so yes, this is the way that variables have always behaved.

As Ed said above, if you change a variable, you have to issue a varchange command to force all updates.

Parameters on the other hand are meant to update their dependencies when changing so that is what you use.
There's at least one school like the old school!
User Avatar
Member
511 posts
Joined:
Offline
It's a shame because it works, just not reliably… the “first 2 or 3 times” the var is asked to be updated. Even using the varchange command.

Therefore it still smells like a bug in varchange since it doesn't really do what it says on the tin, regardless of whether its good practice to use it like that or not. Global Variables are after all supposed to be variable.

It would be so much nicer to just type or look at something like $OUTPUT/beauty_$F.exr anywhere and be done with it, much less scary for juniors.

so this (bug ?) been there since Prisms!?

cheers
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
Can you put together an example file showing the lack of updating variables?
There's at least one school like the old school!
User Avatar
Member
2199 posts
Joined: July 2005
Online
It seems to work fine, the problem is that the fullname node doesn't always cook so doesn't always update the global variables.
As long as you force a cook on that node before echoing the variable then it all behaves as expected. When it appears broken just select another object then reselect the fullname object and the variable updates.
The issue therefore is how to make sure the node is cooked before you use the variables. That's where channels would be better.
The trick is finding just the right hammer for every screw
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
I still think that there is a problem with the global var not updating, outwith the cooking issue that simon describes which i have found also. There is an underlying problem with the setup i have supplied due to how houdni works (discussed below) The problem isnt with the varchange command as it is the global var that doesnt update so varchange becomes useless, as in if the variable doesnt change it wont update anything anyway.

Bug or not.. from what ive been told from support about this method is it really shouldnt be used. This is due to how houdini evaluates the parms and how it cooks nodes.

This is good explaination of how houdini cooks and evaluates parameters that support gave me. Which kinda points to why a set up like this doesnt really “work”.
all cooking in Houdini is done on a “pull” basis. When a parameter is changed, it is propagated to all nodes and parameters which reference the changed parameter (either directly or indirectly), to only *mark* them as being “dirty”, or “out of date”.

When you have a Viewer pane open, the viewer notices that the nodes it cares about are “out of date”, which then asks for the displayed nodes to recook. Only at this point, do the parameters get evaluated. If there is a spare parameter that isn't used by any node for cooking purposes, it will only ever be evaluated by the Parameter (or some other) pane. For example, nodes do not cook when the .hip file is loaded in hbatch until a ROP is told to render. Also, nothing will cook if you only have a Network pane. You can confirm this yourself by observing the Performance Monitor when changing a parameter with only the Network pane open (ie. with no other panes in your desktop). In short, cooking is only done when *necessary*.

In your scene, the nodes are cooking because if the Parameter pane happens to evaluate the varchange expression/command, that will cause nodes to be marked as “out of date”. Then the Viewer notices that the nodes are out of date and will ask them to recook. If there's no parameter pane that evaluates your spare parameter, then nothing will recook because the varchange expression would not have been run.

Even if using global variables in this way worked the way you're thinking, my gut feeling is that it would make your .hip files harder to debug in the long run. It would become very hard to determine the interdependencies between the nodes since any expression can change the global variable. When channel references are used, these dependencies are explicit, then at least one has a chance to trace them. In programming, it is commonly accepted that using global variables leads to unmaintainable code. In Houdini, I'd imagine the same.

Cheers for the thoughts on this :¬)
Nick
  • Quick Links