Fix for T53599: OpenGL render with transparent background

I had to make Eevee draw its scene in the scene pass (before it was doing it
in the background pass). This is not ideal since reference images require
a separation between scene and background.

But it's the best way to solve it now. Clay is working fine.
This commit is contained in:
Dalai Felinto 2017-12-20 15:28:12 -02:00
parent 03a589125f
commit e3ef782af5
Notes: blender-bot 2023-02-14 07:40:56 +01:00
Referenced by commit 6b2989ae75, DRW: Fix small changes to transparent background.
5 changed files with 23 additions and 5 deletions

View File

@ -95,6 +95,7 @@ void DRW_draw_render_loop_offscreen(
struct Depsgraph *graph,
struct RenderEngineType *engine_type,
struct ARegion *ar, struct View3D *v3d,
const bool draw_background,
struct GPUOffScreen *ofs);
void DRW_draw_select_loop(
struct Depsgraph *graph,

View File

@ -56,7 +56,7 @@ static void eevee_engine_init(void *ved)
/* Alloc transient pointers */
stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
}
stl->g_data->background_alpha = 1.0f;
stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f;
stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
DRWFboTexture tex = {&txl->color, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
@ -414,8 +414,8 @@ DrawEngineType draw_engine_eevee_type = {
&eevee_cache_init,
&eevee_cache_populate,
&eevee_cache_finish,
NULL,
&eevee_draw_scene,
NULL, //&EEVEE_draw_scene
&eevee_view_update,
&eevee_id_update,
};

View File

@ -431,6 +431,7 @@ bool DRW_state_is_image_render(void);
bool DRW_state_is_scene_render(void);
bool DRW_state_show_text(void);
bool DRW_state_draw_support(void);
bool DRW_state_draw_background(void);
struct DRWTextStore *DRW_state_text_cache_get(void);

View File

@ -354,6 +354,7 @@ static struct DRWGlobalState {
unsigned int is_depth : 1;
unsigned int is_image_render : 1;
unsigned int is_scene_render : 1;
unsigned int draw_background : 1;
} options;
/* Current rendering context */
@ -3416,7 +3417,10 @@ void DRW_draw_render_loop_ex(
/* Start Drawing */
DRW_state_reset();
drw_engines_draw_background();
if (DRW_state_draw_background()) {
drw_engines_draw_background();
}
/* WIP, single image drawn over the camera view (replace) */
bool do_bg_image = false;
@ -3503,7 +3507,7 @@ void DRW_draw_render_loop(
void DRW_draw_render_loop_offscreen(
struct Depsgraph *graph, RenderEngineType *engine_type,
ARegion *ar, View3D *v3d, GPUOffScreen *ofs)
ARegion *ar, View3D *v3d, const bool draw_background, GPUOffScreen *ofs)
{
RegionView3D *rv3d = ar->regiondata;
@ -3517,6 +3521,7 @@ void DRW_draw_render_loop_offscreen(
/* Reset before using it. */
memset(&DST, 0x0, sizeof(DST));
DST.options.is_image_render = true;
DST.options.draw_background = draw_background;
DRW_draw_render_loop_ex(graph, engine_type, ar, v3d, NULL);
/* restore */
@ -3817,6 +3822,17 @@ bool DRW_state_draw_support(void)
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0);
}
/**
* Whether we should render the background
*/
bool DRW_state_draw_background(void)
{
if (DRW_state_is_image_render() == false) {
return true;
}
return DST.options.draw_background;
}
/** \} */

View File

@ -2060,7 +2060,7 @@ void ED_view3d_draw_offscreen(
/* XXX, should take depsgraph as arg */
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
BLI_assert(depsgraph != NULL);
DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine_type, ar, v3d, ofs);
DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine_type, ar, v3d, do_sky, ofs);
}
/* restore size */