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

Closed
opened 9 years ago by elmo · 16 comments
elmo commented 9 years ago

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.
elmo commented 9 years ago
Poster

Changed status to: 'Open'

Changed status to: 'Open'
elmo commented 9 years ago
Poster

Added subscriber: @elmo

Added subscriber: @elmo
Collaborator

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
JoshuaLeung closed this issue 9 years ago
JoshuaLeung self-assigned this 9 years ago
Collaborator

Context is NOT available during render.

Context is NOT available during render.
elmo commented 9 years ago
Poster

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'
elmo reopened this issue 9 years ago
elmo commented 9 years ago
Poster

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`.
elmo commented 9 years ago
Poster

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.
elmo commented 9 years ago
Poster

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.
mont29 commented 9 years ago
Owner

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
elmo commented 9 years ago
Poster

@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.
elmo commented 9 years ago
Poster

@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.
Collaborator

Changed status from 'Open' to: 'Duplicate'

Changed status from 'Open' to: 'Duplicate'
JoshuaLeung closed this issue 9 years ago
Collaborator

✘ Merged into blender/blender#39820.

✘ Merged into blender/blender#39820.
Sign in to join this conversation.
No Label
good first issue
legacy module/Animation & Rigging
legacy module/Core
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/User Interface
legacy module/VFX & Video
legacy project/2.81
legacy project/2.82
legacy project/2.83
legacy project/2.90
legacy project/2.92
legacy project/2.93
legacy project/3.0
legacy project/3.1
legacy project/3.2
legacy project/3.4
legacy project/Add-ons (BF-Blender)
legacy project/Add-ons (Community)
legacy project/Alembic
legacy project/Animation & Rigging
legacy project/Asset Browser
legacy project/Automated Testing
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Blender Cloud
legacy project/Code Quest
legacy project/Collada
legacy project/Compositing
legacy project/Core
legacy project/Cycles
legacy project/Datablocks and Libraries
legacy project/Dependency Graph
legacy project/Documentation
legacy project/EEVEE & Viewport
legacy project/Freestyle
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Physics
legacy project/Game Python
legacy project/Game UI
legacy project/Geometry Nodes
legacy project/Good First Issue
legacy project/Grease Pencil
legacy project/Images & Movies
legacy project/Import/Export
legacy project/Infrastructure: Blender Buildbot
legacy project/Infrastructure: Blender Web Assets
legacy project/Infrastructure: Websites
legacy project/Modeling
legacy project/Modifiers
legacy project/Motion Tracking
legacy project/Nodes
legacy project/Nodes & Physics
legacy project/OpenGL Error
legacy project/Overrides
legacy project/Papercut
legacy project/Physics
legacy project/Pillar
legacy project/Pipeline, Assets & I/O
legacy project/Platform: Linux
legacy project/Platform: macOS
legacy project/Platforms, Builds, Tests & Devices
legacy project/Platform: Windows
legacy project/Python API
legacy project/Render & Cycles
legacy project/Render Pipeline
legacy project/Sculpt, Paint & Texture
legacy project/Straightforward Issue
legacy project/Text Editor
legacy project/Tracker Curfew
legacy project/Translations
legacy project/USD
legacy project/User Interface
legacy project/UV Editing
legacy project/VFX & Video
legacy project/Video Sequencer
legacy project/Virtual Reality
papercut
Priority › High
Priority › Low
Priority › Normal
Priority › Unbreak Now!
Status › Archived
Status › Confirmed
Status › Duplicate
Status › Needs Information from Developers
Status › Needs Information from User
Status › Needs Triage
Status › Resolved
straightforward issue
Type › Bug
Type › Design
Type › Known Issue
Type › Patch
Type › Report
Type › To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#39697
Loading…
There is no content yet.