Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2020-11-24 15:18:57 +0300
committerJeroen Bakker <jeroen@blender.org>2020-11-24 15:22:17 +0300
commit278011e44d433dc202b2ab8e7907e323fb23c82d (patch)
tree3e4a33ca5cbc30c032f367eff5176014fd1c42e0 /source/blender/draw/intern/draw_manager.c
parent82cc21d5e4b62aa191726c4d9d89d5f53a2197f7 (diff)
Fix T80748: Render Emissive Colors in Compositor Backdrop
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
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r--source/blender/draw/intern/draw_manager.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 5a25de1a3ca..c5edf9577a4 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -141,6 +141,10 @@ static bool drw_draw_show_annotation(void)
SpaceImage *sima = (SpaceImage *)DST.draw_ctx.space_data;
return (sima->flag & SI_SHOW_GPENCIL) != 0;
}
+ case SPACE_NODE:
+ /* Don't draw the annotation for the node editor. Annotations are handled by space_image as
+ * the draw manager is only used to draw the background. */
+ return false;
default:
BLI_assert("");
return false;
@@ -351,6 +355,14 @@ static void drw_viewport_colormanagement_set(void)
use_render_settings = true;
}
}
+ else if (DST.draw_ctx.space_data && DST.draw_ctx.space_data->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)DST.draw_ctx.space_data;
+ const eSpaceImage_Flag display_channels_mode = snode->flag;
+ const bool display_color_channel = (display_channels_mode & (SI_SHOW_ALPHA)) == 0;
+ if (display_color_channel) {
+ use_render_settings = true;
+ }
+ }
else {
use_render_settings = true;
use_view_transform = false;
@@ -1243,6 +1255,14 @@ static void drw_engines_enable_editors(void)
use_drw_engine(&draw_engine_image_type);
use_drw_engine(&draw_engine_overlay_type);
}
+ else if (space_data->spacetype == SPACE_NODE) {
+ /* Only enable when drawing the space image backdrop. */
+ SpaceNode *snode = (SpaceNode *)space_data;
+ if ((snode->flag & SNODE_BACKDRAW) != 0) {
+ use_drw_engine(&draw_engine_image_type);
+ use_drw_engine(&draw_engine_overlay_type);
+ }
+ }
}
static void drw_engines_enable(ViewLayer *UNUSED(view_layer),
@@ -1998,7 +2018,8 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type,
#endif
}
-/* Used when the render engine want to redo another cache populate inside the same render frame. */
+/* Used when the render engine want to redo another cache populate inside the same render frame.
+ */
void DRW_cache_restart(void)
{
/* Save viewport size. */
@@ -2050,8 +2071,10 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,
/* TODO(jbakker): Only populate when editor needs to draw object.
* for the image editor this is when showing UV's.*/
- const bool do_populate_loop = true;
+ const bool do_populate_loop = (DST.draw_ctx.space_data->spacetype == SPACE_IMAGE);
const bool do_annotations = drw_draw_show_annotation();
+ const bool do_region_callbacks = (DST.draw_ctx.space_data->spacetype != SPACE_IMAGE);
+ const bool do_draw_gizmos = (DST.draw_ctx.space_data->spacetype != SPACE_IMAGE);
/* Get list of enabled engines */
drw_engines_enable_editors();
@@ -2102,7 +2125,7 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,
/* Start Drawing */
DRW_state_reset();
- if (DST.draw_ctx.evil_C) {
+ if (do_region_callbacks && DST.draw_ctx.evil_C) {
ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_PRE_VIEW);
}
@@ -2124,8 +2147,10 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,
if (do_annotations) {
ED_annotation_draw_view2d(DST.draw_ctx.evil_C, true);
}
- GPU_depth_test(GPU_DEPTH_NONE);
- ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW);
+ if (do_region_callbacks) {
+ GPU_depth_test(GPU_DEPTH_NONE);
+ ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW);
+ }
GPU_matrix_pop_projection();
/* Callback can be nasty and do whatever they want with the state.
* Don't trust them! */
@@ -2143,7 +2168,7 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph,
DRW_draw_cursor_2d();
ED_region_pixelspace(DST.draw_ctx.region);
- {
+ if (do_draw_gizmos) {
GPU_depth_test(GPU_DEPTH_NONE);
DRW_draw_gizmo_2d();
}