Fix #69898: Animated EXR have wrong node outputs #122894

Closed
Omar Emara wants to merge 1 commits from OmarEmaraDev/blender:fix-69898 into blender-v4.2-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

When using animated multi-layer EXR images in the compositor, the node
outputs are wrong and not up to date. That's because of two things:

  1. Outputs are always generated based on the first image in the
    sequence. So if the structure of the image was different across
    frames, the outputs will be wrong for all but the first frame.
  2. No proper updates to the node are done as frames changes, so even
    if correct outputs could be computed, the outputs are often not up
    to date unless the user forces an update somehow.

To fix this, for frame changes, we update the frames of image users and
update the nodes of those images users.

When using animated multi-layer EXR images in the compositor, the node outputs are wrong and not up to date. That's because of two things: 1. Outputs are always generated based on the first image in the sequence. So if the structure of the image was different across frames, the outputs will be wrong for all but the first frame. 2. No proper updates to the node are done as frames changes, so even if correct outputs could be computed, the outputs are often not up to date unless the user forces an update somehow. To fix this, for frame changes, we update the frames of image users and update the nodes of those images users.
Omar Emara added the
Module
VFX & Video
Interest
Compositing
labels 2024-06-07 17:29:23 +02:00
Omar Emara added 1 commit 2024-06-07 17:29:33 +02:00
When using animated multi-layer EXR images in the compositor, the node
outputs are wrong and not up to date. That's because of two things:

  1. Outputs are always generated based on the first image in the
     sequence. So if the structure of the image was different across
     frames, the outputs will be wrong for all but the first frame.
  2. No proper updates to the node are done as frames changes, so even
     if correct outputs could be computed, the outputs are often not up
     to date unless the user forces an update somehow.

To fix this, for frame changes, we update the frames of image users and
update the nodes of those images users.
Omar Emara changed target branch from main to blender-v4.2-release 2024-06-07 17:29:47 +02:00
Author
Member

For reference, the issue was introduced in 68d8c6ad3d, in an attempt to fix #34779. This patch fixes the latter by ensuring updates, which makes the former unnecessary.

For reference, the issue was introduced in 68d8c6ad3d, in an attempt to fix #34779. This patch fixes the latter by ensuring updates, which makes the former unnecessary.
Omar Emara requested review from Sergey Sharybin 2024-06-07 17:31:38 +02:00
Sergey Sharybin requested changes 2024-06-10 12:38:53 +02:00
Sergey Sharybin left a comment
Owner

I think this issue goes deeper than forcing an update of sockets on frame change. The reason for this is while you can see this working fine when an unused render layer is appearing/disappearing during playback, it is quite tricky to make things work when passes appear and disappear.

Appearing/disappearing passes will potentially lead to changes in the graph topology, by hiding links which were connected to passes which are no longer available.

There is also this issue with possibly linked node groups, for which it might not be enough to ensure layers/sockets on frame change.

I would strongly advice against following an approach which leads to topology changes throughout animation, and make the sockets update an explicit operation based on user input.

There is a chance we can do some fixes in cases when an unused render layer disappears in the image sequence. I can imagine that there is a chance of us not updating some index properly. That we can look into.

I think this issue goes deeper than forcing an update of sockets on frame change. The reason for this is while you can see this working fine when an unused render layer is appearing/disappearing during playback, it is quite tricky to make things work when passes appear and disappear. Appearing/disappearing passes will potentially lead to changes in the graph topology, by hiding links which were connected to passes which are no longer available. There is also this issue with possibly linked node groups, for which it might not be enough to ensure layers/sockets on frame change. I would strongly advice against following an approach which leads to topology changes throughout animation, and make the sockets update an explicit operation based on user input. There is a chance we can do some fixes in cases when an unused render layer disappears in the image sequence. I can imagine that there is a chance of us not updating some index properly. That we can look into.
@ -148,4 +138,1 @@
load_iuser.framenr = offset;
/* make sure ima->type is correct */
ibuf = BKE_image_acquire_ibuf(ima, &load_iuser, nullptr);

When adding a new image the BKE_update_compositor_images_for_frame() will not be run, so the "wrong" image user's frame number will be used here?

When adding a new image the `BKE_update_compositor_images_for_frame()` will not be run, so the "wrong" image user's frame number will be used here?
Author
Member

@Sergey I am not entirely sure what should be done then. I thought that the changes of the node tree topology is the lesser evil, because otherwise, you get a node state that might have nothing to do with the actual image, like the report shows.

There is a chance we can do some fixes in cases when an unused render layer disappears in the image sequence. I can imagine that there is a chance of us not updating some index properly. That we can look into.

I don't think the issue in the report is what you describe here. The main issue is that the node always generates its outputs at the first frame, not at the current frame, and the currently selected layer might not exist at the first frame, so you basically do not get any output in that case, just the default image and alpha outputs.

So it is the other way around. The layer is valid, but the node outputs are either empty or corrupt because the current frame is ignored.


Is your suggestion to just add an operator to update the node state? Would that be drawn in the node interface directly?

@Sergey I am not entirely sure what should be done then. I thought that the changes of the node tree topology is the lesser evil, because otherwise, you get a node state that might have nothing to do with the actual image, like the report shows. > There is a chance we can do some fixes in cases when an unused render layer disappears in the image sequence. I can imagine that there is a chance of us not updating some index properly. That we can look into. I don't think the issue in the report is what you describe here. The main issue is that the node always generates its outputs at the first frame, not at the current frame, and the currently selected layer might not exist at the first frame, so you basically do not get any output in that case, just the default image and alpha outputs. So it is the other way around. The layer is valid, but the node outputs are either empty or corrupt because the current frame is ignored. --- Is your suggestion to just add an operator to update the node state? Would that be drawn in the node interface directly?

One potential solution would be to change the render animation code to put placeholders for layers and passes in the EXR files, so that they exist in all frames. Maybe using zero size channels (if that is possible) or with metadata.

I'm not sure if there is a standard way of handling this that e.g. Nuke supports, that we could be compatible with. I would not imagine compositing apps to load all EXRs in advance either, so I wonder how they solve this, or if they solve it at all.

One potential solution would be to change the render animation code to put placeholders for layers and passes in the EXR files, so that they exist in all frames. Maybe using zero size channels (if that is possible) or with metadata. I'm not sure if there is a standard way of handling this that e.g. Nuke supports, that we could be compatible with. I would not imagine compositing apps to load all EXRs in advance either, so I wonder how they solve this, or if they solve it at all.
Author
Member

@brecht Took a quick look at Natron. It seems Natron only supports the layers that existed at the first frame in the sequence. Even when I "hack" it by reading a single frame and selecting a layer that doesn't exist at the first frame, then change the Read node into a sequence, it reverts to one of the layers that exist at the first frame.

@brecht Took a quick look at Natron. It seems Natron only supports the layers that existed at the first frame in the sequence. Even when I "hack" it by reading a single frame and selecting a layer that doesn't exist at the first frame, then change the Read node into a sequence, it reverts to one of the layers that exist at the first frame.

Ok. Maybe we should write layers and passes that are all zero. With any compression the resulting EXR file size should not be affected much.

The way the render API works it's not trivial to create these empty passes though. It's up to the render engine to interpret the properties and create corresponding passes. So each engine would need to implement this logic to check if a pass property is animated. And then somehow animated layers would need to be handled as well.

Ok. Maybe we should write layers and passes that are all zero. With any compression the resulting EXR file size should not be affected much. The way the render API works it's not trivial to create these empty passes though. It's up to the render engine to interpret the properties and create corresponding passes. So each engine would need to implement this logic to check if a pass property is animated. And then somehow animated layers would need to be handled as well.

There is another complication: detecting when to add empty passes/layers. If some layer/pass "disappears" during rendering then it is easy: you can somehow store "this layer/pass existed, so if it disappears then write empty pixels for them". However, what if layer/pass "appears"? How to detect this ahead of time? How bad would it be to ensure passes/layers with drivers are always written, so that we don't need to evaluate the entire frame range to see what actually needs to be written?

There is another complication: detecting when to add empty passes/layers. If some layer/pass "disappears" during rendering then it is easy: you can somehow store "this layer/pass existed, so if it disappears then write empty pixels for them". However, what if layer/pass "appears"? How to detect this ahead of time? How bad would it be to ensure passes/layers with drivers are always written, so that we don't need to evaluate the entire frame range to see what actually needs to be written?

Yes, that was my idea, to always write animated and driven passes and layers.

Yes, that was my idea, to always write animated and driven passes and layers.
Author
Member

As discussed, this will be solved differently at the render level.

As discussed, this will be solved differently at the render level.
Omar Emara closed this pull request 2024-07-11 10:27:56 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 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#122894
No description provided.