Page MenuHome

Compositor backdrop handles alpha differently from image editor
Closed, ResolvedPublicBUG


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: rBf5ccf8727f30
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


  • Open attached file
  • F12 render

Event Timeline

Georg K (georg) updated the task description. (Show Details)
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Sep 15 2020, 7:45 PM
Germano Cavalcante (mano-wii) updated the task description. (Show Details)
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".Sep 15 2020, 7:47 PM

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

Georg K (georg) added a comment.EditedSep 17 2020, 10:38 PM

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

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 Van Lommel (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.

Added D9211 which sanitizes the keying node alpha behaviour.

@Jeroen Bakker (jbakker), @Brecht Van Lommel (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 (jbakker), 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 T82154 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 (jbakker), is it something you think can be addressed for 2.92? Do you want to adjust projects tags?

Sergey Sharybin (sergey) renamed this task from Keying node bug to Compositor backdrop handles alpha differently from image editor.Oct 28 2020, 12:34 PM
Jeroen Bakker (jbakker) edited projects, added BF Blender (2.92); removed BF Blender.

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

Technical challenge

The backdrop is rendered between parent node tree and the current active node tree.

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.


  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.

@Clément Foucault (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.