Fix #101263: Vector pass wrongly saved in File Output #124522

Merged
Omar Emara merged 3 commits from OmarEmaraDev/blender:fix-101263-gpu into main 2024-07-11 16:08:36 +02:00
Member

The vector pass and potentially other vectors that store 4 values are
stored wrongly, in particular, the last channel is ignored. To fix this
we identify if a vector pass is 4D and store the information in the
result meta data, then use this information to either save a 3D or a 4D
pass in the File Output node.

This is a partial fix for the GPU compositor only. The complete fix for
the CPU compositor will be submitted separately as it is not
straightforward and will likely require a refactor.

The vector pass and potentially other vectors that store 4 values are stored wrongly, in particular, the last channel is ignored. To fix this we identify if a vector pass is 4D and store the information in the result meta data, then use this information to either save a 3D or a 4D pass in the File Output node. This is a partial fix for the GPU compositor only. The complete fix for the CPU compositor will be submitted separately as it is not straightforward and will likely require a refactor.
Omar Emara added the
Interest
Compositing
Module
VFX & Video
labels 2024-07-11 14:04:54 +02:00
Omar Emara added 1 commit 2024-07-11 14:05:03 +02:00
The vector pass and potentially other vectors that store 4 values are
stored wrongly, in particular, the last channel is ignored. To fix this
we identify if a vector pass is 4D and store the information in the
result meta data, then use this information to either save a 3D or a 4D
pass in the File Output node.

This is a partial fix for the GPU compositor only. The complete fix for
the CPU compositor will be submitted separately as it is not
straightforward and will likely require a refactor.
Omar Emara requested review from Sergey Sharybin 2024-07-11 14:05:18 +02:00
Sergey Sharybin approved these changes 2024-07-11 15:17:56 +02:00
Sergey Sharybin reviewed 2024-07-11 15:19:02 +02:00
@ -432,0 +442,4 @@
return;
}
if (StringRef(render_pass->chan_id, 4) == "XYZW") {

Better to avoid creating StringRef with potentially more characters than there is in the actual chan_id, as discussed in the chat.
But don't need to do extra review iteraiton.

Better to avoid creating StringRef with potentially more characters than there is in the actual chan_id, as discussed in the chat. But don't need to do extra review iteraiton.
OmarEmaraDev marked this conversation as resolved
Omar Emara added 2 commits 2024-07-11 16:07:37 +02:00
Omar Emara merged commit 57a6832b17 into main 2024-07-11 16:08:36 +02:00
Omar Emara deleted branch fix-101263-gpu 2024-07-11 16:08:39 +02:00
Bill-Spitzak reviewed 2024-07-11 22:15:51 +02:00
@ -429,6 +429,23 @@ class Context : public realtime_compositor::Context {
},
false);
RenderLayer *render_layer = RE_GetRenderLayer(render_result, view_layer->name);
Contributor

I think it would be better to write this like this:

if (RenderLayer *render_layer = RE_GetRenderLayer(...)) {
  if (RenderPass *render_pass = RE_pass_find_by_name(...)) {
    if (StringRef(render_pass->chan_id) == "XYZW") {
      meta_data.is_4d_vector = true;`
    }
  }
}
RE_Release(render);
I think it would be better to write this like this: ```Cpp if (RenderLayer *render_layer = RE_GetRenderLayer(...)) { if (RenderPass *render_pass = RE_pass_find_by_name(...)) { if (StringRef(render_pass->chan_id) == "XYZW") { meta_data.is_4d_vector = true;` } } } RE_Release(render); ```

This is anti patter in blender, see: https://devtalk.blender.org/t/some-anti-patterns/26490

This is anti patter in blender, see: https://devtalk.blender.org/t/some-anti-patterns/26490
Contributor

If in fact those tests are never supposed to return null then the original code and mine both conflict with that document. It should just be written to assume they are not null.

In any case I think the version that contains only a single RE_Release call is greatly clearer and safer.

If in fact those tests are never supposed to return null then the original code and mine both conflict with that document. It should just be written to assume they are not null. In any case I think the version that contains only a single `RE_Release` call is greatly clearer and safer.

This is not a referenced, so this always have to be checked. Idea to split if-statements is to make this more readable (avoid a lot of nestings) and make it more scalable because it's very common to add another one such check.

This is not a referenced, so this always have to be checked. Idea to split if-statements is to make this more readable (avoid a lot of nestings) and make it more scalable because it's very common to add another one such check.
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
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
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#124522
No description provided.