Page MenuHome

Show Background Image Beneath Transparent Objects (Cycles only)
Needs ReviewPublic

Authored by Jeroen Bakker (jbakker) on Aug 8 2019, 12:53 PM.

Details

Summary

Camera background images were not shown beneath transparent objects.
This patch performs an alpha under for background images for cycles.

In order to see the difference the Film transparency needs to be turned on.

Note that workbench and EEVEE still needs to be adapted as they don't
write the alpha value in the viewport.

This image shows the old behavior (left) vs the new behavior (right)

Side note. This implementation is already an improvement of the current behavior, what users are requesting. (Show background images underneath cycles viewport rendering.) It is clear that this patch still needs to be extended to workbench and eevee. For now that should be marked as a known limitation.

Diff Detail

Repository
rB Blender
Branch
T65988 (branched from master)
Build Status
Buildable 4335
Build 4335: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 8 2019, 12:58 PM
Jeroen Bakker (jbakker) planned changes to this revision.Aug 8 2019, 1:38 PM
  • alpha channel of source image is ignored. Add a shader that does premultiply the colors with the alpha

Use Alpha premul for camera images

Jeroen Bakker (jbakker) retitled this revision from Show Background Image Beneath Transparent Objects to [WIP] Show Background Image Beneath Transparent Objects.Aug 8 2019, 2:05 PM
Jeroen Bakker (jbakker) planned changes to this revision.Aug 9 2019, 10:22 AM

Move the drawing of the checkerboard to object_mode.

Postpone rendering of checkerboard for better compositing

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 9 2019, 11:32 AM

Removed unused code

@Jeroen Bakker (jbakker) what is the current status of this patch? Trying to see if it may fit in 2.81 (it seems a bit late for that though to be honest).

Part of the issues has been resolved inside as in it works better than it currently does. It works with cycles, but only with a single background image. EEVEE and Workbench still needs to be adapted as they do not support alpha film in the viewport. Supporting multiple background is a OIT question. The non transparent part needs to be rendered front to back. and the transparent part needs to be rendered back to front for better result. The draw engines are a bit in between and can intervene.

IMO it is solvable to 95% of what we want.

Draw order for alpha under pass

Finalized for cycles

Jeroen Bakker (jbakker) retitled this revision from [WIP] Show Background Image Beneath Transparent Objects to Show Background Image Beneath Transparent Objects.Thu, Sep 19, 2:07 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) retitled this revision from Show Background Image Beneath Transparent Objects to Show Background Image Beneath Transparent Objects (Cycles only).
source/blender/draw/modes/object_mode.c
1341

Nitpicking, but this is float promotion, and some compilers will throw annoying warnings at us ;)

- depth = 0.000001;
+ depth = 0.000001f;
1347
- depth = 0.999999;
+ depth = 0.999999f;

Personally I would initialize float depth = 0.000001f, and here do depth = 1.0f - depth.