Driver's scripted expression does not work for animation render. #39697

Closed
opened 2014-04-13 11:42:28 +02:00 by Krzysztof Trzciński · 16 comments

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 animation_driver_bug.blend.
Hit ctrl-a to see expected result, hit ctrl-f12 to see broken behaviour.

**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 [animation_driver_bug.blend](https://archive.blender.org/developer/F84715/animation_driver_bug.blend). Hit `ctrl-a` to see expected result, hit `ctrl-f12` to see broken behaviour.

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @elmo

Added subscriber: @elmo
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Joshua Leung self-assigned this 2014-04-13 13:37:29 +02:00
Member

Context is NOT available during render.

Context is NOT available during render.

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'

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.

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`.

I forgot to attach animation_driver_bug.blend in previous post.

I forgot to attach [animation_driver_bug.blend](https://archive.blender.org/developer/F84726/animation_driver_bug.blend) in previous post.

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.

Also reading through documentation I see in [Drivers ](http://wiki.blender.org/index.php/Doc:2.6/Manual/Animation/Basics/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.

Added subscriber: @mont29

Added subscriber: @mont29

Added subscriber: @willi-2

Added subscriber: @willi-2

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:

  • Add a custom property to the scene; set it's max value to very high (eg 1 million)
  • Go to frame 0, set the property value to 0 and key frame it
  • Go to frame 1, set the property value to 1 and key frame it
  • set the curve extrapolation to linear
  • In your driver, refer to that property now returning the "real" frame number
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: - Add a custom property to the scene; set it's max value to very high (eg 1 million) - Go to frame 0, set the property value to 0 and key frame it - Go to frame 1, set the property value to 1 and key frame it - set the curve extrapolation to linear - In your driver, refer to that property now returning the "real" frame number

@willi-2 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-2 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.

@elmo, no you're referring to frame again. I don't:
#39697.blend

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.

@elmo, no you're referring to frame again. I don't: [#39697.blend](https://archive.blender.org/developer/F84739/T39697.blend) 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.

@willi-2 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.

@willi-2 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.
Member

Changed status from 'Open' to: 'Duplicate'

Changed status from 'Open' to: 'Duplicate'
Member

✘ Merged into blender/blender#39820.

✘ Merged into blender/blender#39820.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#39697
No description provided.