From 278011e44d433dc202b2ab8e7907e323fb23c82d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 24 Nov 2020 13:18:57 +0100 Subject: Fix T80748: Render Emissive Colors in Compositor Backdrop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change will use the image engine to draw the backdrop of the compositor. With this patch the alpha blending will be done in Linear Scene Reference space and shows pure emissive colors. See differential for an example image. **Technical changes** As only the backdrop drawing is done using the draw manager there are some technical changes. 1. The overlay buffer is partly drawn outside the draw manager. When drawing the backdrop image the overlay buffer needs to be masked to simulate premultiplied alpha under. 2. The backdrop of the node editor is done in region pixel space. A `DRWView` is constructed with this space. 3. UDIM textures uses world position to generate the UV coordinates. This has been implemented more strict by the `IMAGE_DRAW_FLAG_USE_WORLD_POS`. When the flag isn't used the local coordinates are used to generate the UV coordinates what is image space. 4. The draw manager now checks the actual `eSpaceType` of the space data to use different code paths. In the future the movie clip editor will be added. NOTE: The preview images in nodes are drawn in display space and cannot show pure emissive colors. As preview images are used on more locations it is best to fix this in a separate patch. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D9451 --- source/blender/draw/engines/overlay/overlay_background.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/draw/engines/overlay/overlay_background.c') diff --git a/source/blender/draw/engines/overlay/overlay_background.c b/source/blender/draw/engines/overlay/overlay_background.c index 01bdbf73a66..843051c646c 100644 --- a/source/blender/draw/engines/overlay/overlay_background.c +++ b/source/blender/draw/engines/overlay/overlay_background.c @@ -32,6 +32,7 @@ #define BG_CHECKER 2 #define BG_RADIAL 3 #define BG_SOLID_CHECKER 4 +#define BG_MASK 5 void OVERLAY_background_cache_init(OVERLAY_Data *vedata) { @@ -46,6 +47,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) bool draw_clipping_bounds = (pd->clipping_state != 0); { + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f}; int background_type; @@ -53,9 +55,13 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) background_type = BG_SOLID; color_override[3] = 1.0f; } - else if (pd->is_image_editor) { + else if (pd->space_type == SPACE_IMAGE) { background_type = BG_SOLID_CHECKER; } + else if (pd->space_type == SPACE_NODE) { + background_type = BG_MASK; + state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_MUL; + } else if (!DRW_state_draw_background()) { background_type = BG_CHECKER; } @@ -87,7 +93,6 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) } } - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; DRW_PASS_CREATE(psl->background_ps, state); GPUShader *sh = OVERLAY_shader_background(); -- cgit v1.2.3