Maniphest T39697

Driver's scripted expression does not work for animation render.
Closed, Duplicate

Assigned To
Joshua Leung (aligorith)
Authored By
Krzysztof Trzciński (elmo)
Apr 13 2014, 11:42 AM
Tags
  • BF Blender
  • Video Sequencer
  • Add-ons (BF-Blender)
Subscribers
Bastien Montagne (mont29)
Joshua Leung (aligorith)
Krzysztof Trzciński (elmo)
Willi (willi)

Description

System Information
I don't think relevant. Windows 8.1. nVidia GeFroce GT 730M.

Blender Version
Broken: 2.70a

Short description of error
If I add a driver to one of sequence properties in sequencer it works like a charm for preview and image render. However if I do animation render driver values seem to be stuck on the value for currently selected frame, not the one being rendered.

Exact steps for others to reproduce the error

  • Open Blender.
  • Change layout to Video Editing
  • Add -> Effect -> Color Strip and make it i.e. white
  • Add -> Effect -> Color Strip and make it i.e. red (make sure red is over white)
  • Got to white strip's Opacity property and add a driver
  • In driver properties select Scripted Expression and enter expression bpy.context.scene.frame_current / 26
  • Enjoy for a brief moment how pretty the red strip is when it slowly appears on the course of 26 frames
  • Get all your dreams shattered when you try to render animation

Final result can be seen here

.
Hit ctrl-a to see expected result, hit ctrl-f12 to see broken behaviour.

Event Timeline

Krzysztof Trzciński (elmo) created this task.Apr 13 2014, 11:42 AM
Krzysztof Trzciński (elmo) raised the priority of this task from to 90.
Krzysztof Trzciński (elmo) updated the task description.
Krzysztof Trzciński (elmo) added projects: BF Blender, Add-ons (BF-Blender), Video Sequencer.
Krzysztof Trzciński (elmo) edited a custom field.
Krzysztof Trzciński (elmo) added a subscriber: Krzysztof Trzciński (elmo).
Joshua Leung (aligorith) changed the task status from Unknown Status to Archived.Apr 13 2014, 1:37 PM
Joshua Leung (aligorith) claimed this task.

Context is NOT available during render.

Krzysztof Trzciński (elmo) changed the task status from Archived to Unknown Status.EditedApr 13 2014, 1:47 PM

Different approach same issue. Steps as described above, but change steps from setting Scripted Expression:

  • set Scripted Expression to frame / 26
  • add new variable named frame which is of type Transform Channel, for object Cube, set Type to X Location and Space to World Space
  • set frame to 0 and set Cube's X to 0, add key frame on that property
  • set frame to 26 and set Cube's X to 26, add key frame on that property

Issue still persists even though I don't refer anywhere to context.

Krzysztof Trzciński (elmo) added a comment.Apr 13 2014, 1:49 PM

I forgot to attach

in previous post.

Krzysztof Trzciński (elmo) added a comment.EditedApr 13 2014, 2:11 PM

Also reading through documentation I see in Drivers section:

frame is the same as bpy.context.scene.frame_current.

which strongly suggests that I can use either (and seems I didn't have to introduce my own variable in second example I attached).
In addition I don't see any mention that there will be anything odd going on during animation render with scripted expressions.

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Apr 13 2014, 2:40 PM
Bastien Montagne (mont29) added a subscriber: Bastien Montagne (mont29).
Willi (willi) added a subscriber: Willi (willi).Apr 13 2014, 2:51 PM

Already closed meanwhile, though...: the point is not only that context is not available. In fact, the current frame does not change during animation rendering. Consequently, frame_current does not change either, and you are referring to the wrong value. However, we obviously do not have access to the frame number used for rendering one frame of the animation. During animation rendering, the indicator in the timeline does not reflect the scene's current frame but the frame currently being rendered.

Workaround:

  1. Add a custom property to the scene; set it's max value to very high (eg 1 million)
  2. Go to frame 0, set the property value to 0 and key frame it
  3. Go to frame 1, set the property value to 1 and key frame it
  4. set the curve extrapolation to linear
  5. In your driver, refer to that property now returning the "real" frame number
Krzysztof Trzciński (elmo) added a comment.Apr 13 2014, 3:06 PM

@Willi (willi) that's what I've basically done in the second example (or not?). Just to be sure I also just tried with variable name f instead of frame (in case there is any clash), but the problem still persists.

It would be nice to see a working .blend file.

Willi (willi) added a comment.EditedApr 13 2014, 3:51 PM

@Krzysztof Trzciński (elmo), no you're referring to frame again. I don't:

However, there seems to be a problem that is not related to "frame" or "frame_current" that makes the value not being updated.

This indeeds seems to require a fix.

EDIT: You've named the variable "frame", too, which was a bit confusing. We're now actually talking about the same problem now.

Krzysztof Trzciński (elmo) added a comment.Apr 13 2014, 7:25 PM

@Willi (willi) Yeah, when I created my second example I didn't know that frame is reserved. Hence my comment about trying it out with f.

FWIW my actual usage contains a call to my custom function in expression and one of arguments was current frame number (with offset applied). After adding print() in it I didn't see any output during render, which would suggest that issue is not with referring to other properties/stale values being substituted, but with scripted expressions not being evaluated at all.

For now I think my workaround will be generation of FCurve points instead of using driver (which means I will have to rerun my generation each time input changes, but in my current case that is not a big problem). However it does seem like a fix is required.

Joshua Leung (aligorith) changed the task status from Unknown Status to Duplicate.Apr 28 2014, 7:31 AM

✘ Merged into T39820.