PDA

View Full Version : Attributes with expressions not updating


jwvanderbeck
10-28-2011, 06:54 PM
So I am running into what is probably some fundamental issue in Maya, but it is driving me absolutely crazy.

I have a custom camera node with TONS of custom attributes. These custom attributes are mostly all linked to expressions that in many cases reference other of the custom attributes in a series of maths to produce our custom camera.

The problem I am having is that if you interactively adjust some of the base attributes upon which all of the expressions build from, those expressions don't visibly update in the attribute editor. I can tell that based on the display in the viewport the camera is in fact recalculating with the user's changes, it just doesn't update the attributes in the attribute panel. If you change tabs on the attribute panel and then back, the new values will be seen. Ok, so an annoying quirk but one that could be ignored. Or so I thought. Now doing some work on the custom UI panel that controls the camera, I am running into further issues caused by this.

If I put these attributes up into the panel with a attrControlGrp, the attributes again will not visibly update with changes. In addition if I attach a scriptJob to the attributes changing, that scriptJob never gets fired!

This is all driving me to drink I tell you.

Here is a very simplified example of what I am doing.

customCam node
Custom attributes on the node:

customCam.userValue is float adjustable by the user

customCam.distance = customCam.tz - customCamLocator.tz;
customCam.meaningOfLife = customCam.distance * 0.5;
customCam.calc = customCam.userValue * 42 + customCam.meaningOfLife;

In the above example, if the user scrubs the value of 'userValue', the value in the attribute 'calc' will not visually change in the attribute editor, but the visual display in the viewport that is based on that 'calc' WILL update. If you change tabs and back, you will see the new value of 'calc'. In addition, scrubbing 'userValue' will NOT fire off the scriptJob set for attribute changes on customCam.calc

However, if the user moves the locator 'customCamLocator', then all values will update and the scriptJob will fire.

This is in Maya 2010 on Windows. I hope I am making sense here.

gtbull80
11-12-2011, 07:05 PM
Not sure if you ever got this figured out. By custom node, do you mean you wrote a plugin? If so, if you have access to the source code, make sure that all attributes are properly set up to become "dirty" when they need to be updated.

I know that's vague, but I don't know exactly what I'm working with.

jwvanderbeck
01-11-2012, 01:51 PM
@gtbull Thanks for your reply. This got pushed into the background and i've been busy on other things, and just now coming back to this issue.

My choice of wording in my original post was very bad. There are no custom nodes. Everything is done by scripting existing Maya nodes. We are taking standard Maya Camera nodes and through the use of both Python scripts and MEL expressions we are driving those nodes attributes to create a custom stereo rig.

Unfortunately this is causing some very large problems with Maya apparently. As I originally stated the problem is that when some underlying attributes change, Maya is not properly recalculating everything causing the stereo rig to get out of sync.

Previously we thought it was just a strange UI issue, and told the artists that if things looked wrong, a simple scrub of one of the controls to a new value then back to the original value would fix it. And this works, forcing Maya to recalculate everything. So we moved on.

Now I am back on this issue because we have learned it is more than a display issue. When rendering through the standard Maya batch renderer, everything works, but when rendering through vray using our render manager, the output is incorrect and the problem leads right back to these attributes that are not updating properly.

Now since creating this system I have learned a LOT more about Maya and learned about writing custom nodes, so the plan is to eventually re-write the whole rig using custom nodes, and that will hopefully solve the problem. Unfortunately in the meantime we really need to find a way to get this to work properly.

In a nutshell what is happening is one main stereo camera node carries the bulk of the expressions, and that node's basic camera attributes are linked to the underlying original CG camera that was blocked out for the shot. Things like position, focal length, etc. In turn the main stereo node has additional expressions that take those values, combined with user input, and does the math to drive a second stereo camera. What is happening is that when the user scrubs along the timeline and values on the underlying camera like focal length change, the expressions on the main stereo node update, but the second stereo camera does not. Even though the second stereo camera has expressions that use the values on the main stereo node. So for example:

Stereo Cam A
Stereo Cam B

Stereo Cam B's position is let's say stereo_cam_a.stereoval + 10

If the stereoval changes on Stereo Cam A, even though it is used in the expression in Stereo Cam B, Stereo Cam B will not update.

Keilun
01-11-2012, 04:23 PM
There's a lot of info in your posts to digest, but it sounds like you have the following scenario:

origCGCam attributes --> main stereo cam attributes --> secondary stereo cam attributes

where --> are expressions. I feel like the double dependency might be the issue here. Can you confirm which expression evaluation scheme your using? (Always/On Demand). Always (default mode) executes on frame changes. On Demand evaluates when the source attribute changes.

I'm not 100% positive I know the evaluation order of expressions under "Always" in this case, but I feel like if you have one attribute on your main stereo cam being computed by an expression and have a secondary cam attribute dependent on that, I'm unsure of whether or not that will fire appropriately or in the correct order.

For sure, if you were to create your own node to compute these values and just connect the camera rig to those values, I'm sure it would work. Another possible workaround would be to use the utility nodes to compute this through the DG proper. I'm not sure if all of your expressions are basic operations, but I'd feel more confident about eval using the DG in this case rather than expressions given the interactivity that you're looking for, but that's just another idea.

jwvanderbeck
01-11-2012, 06:26 PM
There's a lot of info in your posts to digest, but it sounds like you have the following scenario:

origCGCam attributes --> main stereo cam attributes --> secondary stereo cam attributes

where --> are expressions. I feel like the double dependency might be the issue here. Can you confirm which expression evaluation scheme your using? (Always/On Demand). Always (default mode) executes on frame changes. On Demand evaluates when the source attribute changes.

I'm not 100% positive I know the evaluation order of expressions under "Always" in this case, but I feel like if you have one attribute on your main stereo cam being computed by an expression and have a secondary cam attribute dependent on that, I'm unsure of whether or not that will fire appropriately or in the correct order.

For sure, if you were to create your own node to compute these values and just connect the camera rig to those values, I'm sure it would work. Another possible workaround would be to use the utility nodes to compute this through the DG proper. I'm not sure if all of your expressions are basic operations, but I'd feel more confident about eval using the DG in this case rather than expressions given the interactivity that you're looking for, but that's just another idea.

I think you have summed it all up pretty well Keilun. I started this project not really knowing anything about programming inside Maya, so I just took the most obvious and direct approach. I am not sure exactly what you mean with using utility nodes to compute through the DG but I will look into it.

Azrail
01-11-2012, 07:38 PM
Just a little tip - AFAIK it's good practice to bake/cache everything and remove as many custom nodes/scripts/expressions etc. as possible before sending something to the render, especially when dealing with external ones such as VRay, because you never know which node won't be supported (like the vector product if I remember right) from the render. So if you have custom render manager, then you have also a custom exporter script. In that case you can force maya to at least bake the keys on basic camera attributes before exporting the scene, and then restore the connections to the expressions for example.

By utility nodes Keilun means to substitute expressions with direct connections trough nodes like the plusMinusAverage/multiplyDivide and so on.

Keilun
01-11-2012, 08:28 PM
By utility nodes Keilun means to substitute expressions with direct connections trough nodes like the plusMinusAverage/multiplyDivide and so on.

Yup, just wanted to confirm that's what I was getting at. Through that method, you would be guaranteed that the values on each camera node were up to date and evaluated in order.

CGTalk Moderation
01-11-2012, 08:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.