Compositor backdrop handles alpha differently from image editor #80748

Closed
opened 2020-09-13 16:57:17 +02:00 by Georg K · 17 comments

System Information
Operating system: Linux-5.8.6-1-MANJARO-x86_64-with-glibc2.32 64 Bits
Graphics card: AMD VERDE (DRM 2.50.0, 5.8.6-1-MANJARO, LLVM 10.0.1) X.Org 4.5 (Core Profile) Mesa 20.1.7

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-13 09:15, hash: f5ccf8727f
Worked: 2.90

Short description of error
Keying node alpha channel is not taken into account 100% when rendering.

On attached file:
2.90: background keyed out (not perfect because I left everything else on defaults)
2.91 alpha: background looks desaturated semi-transparent

Exact steps for others to reproduce the error

**System Information** Operating system: Linux-5.8.6-1-MANJARO-x86_64-with-glibc2.32 64 Bits Graphics card: AMD VERDE (DRM 2.50.0, 5.8.6-1-MANJARO, LLVM 10.0.1) X.Org 4.5 (Core Profile) Mesa 20.1.7 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-13 09:15, hash: `f5ccf8727f` Worked: 2.90 **Short description of error** Keying node alpha channel is not taken into account 100% when rendering. On attached file: 2.90: background keyed out (not perfect because I left everything else on defaults) 2.91 alpha: background looks desaturated semi-transparent **Exact steps for others to reproduce the error** - Enter compositor - add greenscreen source (for example https://www.vegascreativesoftware.com/fileadmin/user_upload/seo/keyword/guide_to_chroma_key_and_green_screen/vegas-pro-separate-subject-int.jpg) - add keying node (select a key color, everything else at default), connect viewer node - activate backdrop or look at viewer node output in image editor - F12 render and compare result to backdrop or - Open attached file - F12 render [Keying node bug.blend](https://archive.blender.org/developer/F8872906/Keying_node_bug.blend)
Author

Added subscriber: @georgK

Added subscriber: @georgK

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscribers: @Jeroen-Bakker, @mano-wii

Added subscribers: @Jeroen-Bakker, @mano-wii

It is indeed a regression.
@Jeroen-Bakker, I wonder if it has anything to do with the recent changes in the image editor.

It is indeed a regression. @Jeroen-Bakker, I wonder if it has anything to do with the recent changes in the image editor.
Author

Backdrop rendering looks normal in version: 2.91.0 Alpha, branch: master, commit date: 2020-09-17 20:18, hash: 9ee588cd4a, but F12 rendering still has artifacts.

Backdrop rendering looks normal in version: 2.91.0 Alpha, branch: master, commit date: 2020-09-17 20:18, hash: `9ee588cd4a`, but F12 rendering still has artifacts.

Added subscribers: @brecht, @Sergey

Added subscribers: @brecht, @Sergey

Keying node violates pre-multiplication of the compositing buffer: it sets alpha without multiplying color channels. The original motivation behind this was to be able to chain multiple keying nodes. But now it seems that this decision causes more problems than solutions, so probably need to ensure pre-multiplication of result at where it is expected to be.

However, "fixing" this specific node does not fix the issue in general: there are many more ways to "ruin" pre-multiplication in compositor, and having difference between compositor backdrop and image editor is rather confusing.

@brecht, proposal: add "Convert Premul" checkbox enabled by default, but not do-versioned for existing files, so that compatibility is not ruined. That would at least cover common usecases of this specific node. The backdrop drawing is still needs to be corrected, but that's a different story where I can not help.

Keying node violates pre-multiplication of the compositing buffer: it sets alpha without multiplying color channels. The original motivation behind this was to be able to chain multiple keying nodes. But now it seems that this decision causes more problems than solutions, so probably need to ensure pre-multiplication of result at where it is expected to be. However, "fixing" this specific node does not fix the issue in general: there are many more ways to "ruin" pre-multiplication in compositor, and having difference between compositor backdrop and image editor is rather confusing. @brecht, proposal: add "Convert Premul" checkbox enabled by default, but not do-versioned for existing files, so that compatibility is not ruined. That would at least cover common usecases of this specific node. The backdrop drawing is still needs to be corrected, but that's a different story where I can not help.

I'm fine with a Convert Premul option on the keying node.

I'm fine with a Convert Premul option on the keying node.

Added D9211 which sanitizes the keying node alpha behaviour.

@Jeroen-Bakker, @brecht, I would like you to make the decision about alpha rendering difference between image editor and compositor backdrop. To me it seems confusing at a least :(

Added [D9211](https://archive.blender.org/developer/D9211) which sanitizes the keying node alpha behaviour. @Jeroen-Bakker, @brecht, I would like you to make the decision about alpha rendering difference between image editor and compositor backdrop. To me it seems confusing at a least :(

I guess it's just a bug to be fixed by @Jeroen-Bakker, to ensure the compositor backdrop draws the same way as the image editor?

Not sure there is any decision to take from my side.

I guess it's just a bug to be fixed by @Jeroen-Bakker, to ensure the compositor backdrop draws the same way as the image editor? Not sure there is any decision to take from my side.

The keying node now delivers properly premultiplied color. There is also Cryptomatte node which needs to be made to output proper color. There is #82154 about it.

I still believe root of this issue goes to the fact that image editor uses different drawing of alpha than the rest of related editor (compositor backdrop, movie clip editor).

@Jeroen-Bakker, is it something you think can be addressed for 2.92? Do you want to adjust projects tags?

The keying node now delivers properly premultiplied color. There is also Cryptomatte node which needs to be made to output proper color. There is #82154 about it. I still believe root of this issue goes to the fact that image editor uses different drawing of alpha than the rest of related editor (compositor backdrop, movie clip editor). @Jeroen-Bakker, is it something you think can be addressed for 2.92? Do you want to adjust projects tags?
Sergey Sharybin changed title from Keying node bug to Compositor backdrop handles alpha differently from image editor 2020-10-28 12:34:50 +01:00
Jeroen Bakker self-assigned this 2020-10-28 13:37:14 +01:00
Member

Yes, I am planning to work on it for 2.92. I will merge my todo into this task.

Yes, I am planning to work on it for 2.92. I will merge my todo into this task.
Member

Added subscriber: @fclem

Added subscriber: @fclem
Member

Technical challenge

The backdrop is rendered between parent node tree and the current active node tree.
Screenshot from 2020-10-28 14-40-41.png

#80748.blend

Current layering in the draw code is:

  1. parent of parent node tree
  2. green overlay
  3. parent node tree
  4. green overlay
  5. grid
  6. backdrop
  7. active node specific drawing
  8. node tree

Everything is currently done in display space to an offscreen image.

Solutions

  1. change the drawpix method to retrieve the backdrop in scene reference space using a custom shader to integrate the backdrop and transfer to display space. The complexity here is the transfer to display space as our OCIO wrapper doesn't support this. the alpha channel might be different when compared to the image editor.
  2. use a gpu viewport the background is rendered to the overlay buffer (1-5), the backdrop (6) is rendered to the color buffer. During drawing of the backdrop the overlay texture is changed to simulate an alpha under. The rest (7-8) will be rendered on the overlay buffer. When copying the viewport to the display the overlay and color buffers are merged and transform to the display space. This will lead to some artifacts when looking through a transparent canvas of the node, but can be considered as cosmetic.

Additional benefit of the GPUViewport solution is that stereoscoptic compositing will also give the same result as in the 3d viewport or image editor as they shade the same color pipeline.

@fclem do you have any suggestion?

## Technical challenge The backdrop is rendered between parent node tree and the current active node tree. ![Screenshot from 2020-10-28 14-40-41.png](https://archive.blender.org/developer/F9117691/Screenshot_from_2020-10-28_14-40-41.png) [#80748.blend](https://archive.blender.org/developer/F9117693/T80748.blend) Current layering in the draw code is: 1. parent of parent node tree 2. green overlay 3. parent node tree 4. green overlay 5. grid 6. backdrop 7. active node specific drawing 8. node tree Everything is currently done in display space to an offscreen image. ## Solutions 1. change the drawpix method to retrieve the backdrop in scene reference space using a custom shader to integrate the backdrop and transfer to display space. The complexity here is the transfer to display space as our OCIO wrapper doesn't support this. the alpha channel might be different when compared to the image editor. 2. use a gpu viewport the background is rendered to the overlay buffer (1-5), the backdrop (6) is rendered to the color buffer. During drawing of the backdrop the overlay texture is changed to simulate an alpha under. The rest (7-8) will be rendered on the overlay buffer. When copying the viewport to the display the overlay and color buffers are merged and transform to the display space. This will lead to some artifacts when looking through a transparent canvas of the node, but can be considered as cosmetic. Additional benefit of the GPUViewport solution is that stereoscoptic compositing will also give the same result as in the 3d viewport or image editor as they shade the same color pipeline. @fclem do you have any suggestion?

The ideal solution would be to do something like the 3D view: At 6, draw the backdrop only using a holdout for it's alpha channel. This would let the render pass through the overlays and display correctly.

So your idea is good and yes the GPUViepwort would handle stereo correctly.

The ideal solution would be to do something like the 3D view: At 6, draw the backdrop only using a holdout for it's alpha channel. This would let the render pass through the overlays and display correctly. So your idea is good and yes the GPUViepwort would handle stereo correctly.

This issue was referenced by 278011e44d

This issue was referenced by 278011e44d433dc202b2ab8e7907e323fb23c82d
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Thomas Dinges added this to the 2.92 milestone 2023-02-08 16:16:03 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
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
7 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#80748
No description provided.