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:
@@ -95,6 +95,7 @@ void DRW_draw_render_loop_offscreen(
|
|||||||
struct Depsgraph *graph,
|
struct Depsgraph *graph,
|
||||||
struct RenderEngineType *engine_type,
|
struct RenderEngineType *engine_type,
|
||||||
struct ARegion *ar, struct View3D *v3d,
|
struct ARegion *ar, struct View3D *v3d,
|
||||||
|
const bool draw_background,
|
||||||
struct GPUOffScreen *ofs);
|
struct GPUOffScreen *ofs);
|
||||||
void DRW_draw_select_loop(
|
void DRW_draw_select_loop(
|
||||||
struct Depsgraph *graph,
|
struct Depsgraph *graph,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ static void eevee_engine_init(void *ved)
|
|||||||
/* Alloc transient pointers */
|
/* Alloc transient pointers */
|
||||||
stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
|
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);
|
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};
|
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_init,
|
||||||
&eevee_cache_populate,
|
&eevee_cache_populate,
|
||||||
&eevee_cache_finish,
|
&eevee_cache_finish,
|
||||||
|
NULL,
|
||||||
&eevee_draw_scene,
|
&eevee_draw_scene,
|
||||||
NULL, //&EEVEE_draw_scene
|
|
||||||
&eevee_view_update,
|
&eevee_view_update,
|
||||||
&eevee_id_update,
|
&eevee_id_update,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -431,6 +431,7 @@ bool DRW_state_is_image_render(void);
|
|||||||
bool DRW_state_is_scene_render(void);
|
bool DRW_state_is_scene_render(void);
|
||||||
bool DRW_state_show_text(void);
|
bool DRW_state_show_text(void);
|
||||||
bool DRW_state_draw_support(void);
|
bool DRW_state_draw_support(void);
|
||||||
|
bool DRW_state_draw_background(void);
|
||||||
|
|
||||||
struct DRWTextStore *DRW_state_text_cache_get(void);
|
struct DRWTextStore *DRW_state_text_cache_get(void);
|
||||||
|
|
||||||
|
|||||||
@@ -354,6 +354,7 @@ static struct DRWGlobalState {
|
|||||||
unsigned int is_depth : 1;
|
unsigned int is_depth : 1;
|
||||||
unsigned int is_image_render : 1;
|
unsigned int is_image_render : 1;
|
||||||
unsigned int is_scene_render : 1;
|
unsigned int is_scene_render : 1;
|
||||||
|
unsigned int draw_background : 1;
|
||||||
} options;
|
} options;
|
||||||
|
|
||||||
/* Current rendering context */
|
/* Current rendering context */
|
||||||
@@ -3416,7 +3417,10 @@ void DRW_draw_render_loop_ex(
|
|||||||
|
|
||||||
/* Start Drawing */
|
/* Start Drawing */
|
||||||
DRW_state_reset();
|
DRW_state_reset();
|
||||||
|
|
||||||
|
if (DRW_state_draw_background()) {
|
||||||
drw_engines_draw_background();
|
drw_engines_draw_background();
|
||||||
|
}
|
||||||
|
|
||||||
/* WIP, single image drawn over the camera view (replace) */
|
/* WIP, single image drawn over the camera view (replace) */
|
||||||
bool do_bg_image = false;
|
bool do_bg_image = false;
|
||||||
@@ -3503,7 +3507,7 @@ void DRW_draw_render_loop(
|
|||||||
|
|
||||||
void DRW_draw_render_loop_offscreen(
|
void DRW_draw_render_loop_offscreen(
|
||||||
struct Depsgraph *graph, RenderEngineType *engine_type,
|
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;
|
RegionView3D *rv3d = ar->regiondata;
|
||||||
|
|
||||||
@@ -3517,6 +3521,7 @@ void DRW_draw_render_loop_offscreen(
|
|||||||
/* Reset before using it. */
|
/* Reset before using it. */
|
||||||
memset(&DST, 0x0, sizeof(DST));
|
memset(&DST, 0x0, sizeof(DST));
|
||||||
DST.options.is_image_render = true;
|
DST.options.is_image_render = true;
|
||||||
|
DST.options.draw_background = draw_background;
|
||||||
DRW_draw_render_loop_ex(graph, engine_type, ar, v3d, NULL);
|
DRW_draw_render_loop_ex(graph, engine_type, ar, v3d, NULL);
|
||||||
|
|
||||||
/* restore */
|
/* restore */
|
||||||
@@ -3817,6 +3822,17 @@ bool DRW_state_draw_support(void)
|
|||||||
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0);
|
((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;
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2060,7 +2060,7 @@ void ED_view3d_draw_offscreen(
|
|||||||
/* XXX, should take depsgraph as arg */
|
/* XXX, should take depsgraph as arg */
|
||||||
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
|
Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
|
||||||
BLI_assert(depsgraph != NULL);
|
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 */
|
/* restore size */
|
||||||
|
|||||||
Reference in New Issue
Block a user