DRW: Fix viewport render always rendering with transparent background
This commit is contained in:
parent
73e404697b
commit
180aff7b74
Notes:
blender-bot
2023-02-14 04:56:36 +01:00
Referenced by issue #73803, Viewport Render Background is always transparent
|
@ -46,7 +46,13 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata)
|
|||
{
|
||||
float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
int background_type;
|
||||
if (!DRW_state_draw_background()) {
|
||||
|
||||
if (DRW_state_is_opengl_render() && !DRW_state_draw_background()) {
|
||||
background_type = BG_SOLID;
|
||||
zero_v3(color_override);
|
||||
color_override[3] = 1.0f;
|
||||
}
|
||||
else if (!DRW_state_draw_background()) {
|
||||
background_type = BG_CHECKER;
|
||||
}
|
||||
else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD && scene->world) {
|
||||
|
|
|
@ -1595,8 +1595,27 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
|
|||
DST.options.draw_background = draw_background;
|
||||
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, render_viewport, NULL);
|
||||
|
||||
if (draw_background) {
|
||||
/* HACK(fclem): In this case we need to make sure the final alpha is 1.
|
||||
* We use the blend mode to ensure that. A better way to fix that would
|
||||
* be to do that in the colormanagmeent shader. */
|
||||
GPU_offscreen_bind(ofs, false);
|
||||
GPU_clear_color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
GPU_clear(GPU_COLOR_BIT);
|
||||
/* Premult Alpha over black background. */
|
||||
GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_blend(true);
|
||||
}
|
||||
|
||||
GPU_viewport_unbind_from_offscreen(render_viewport, ofs, do_color_management);
|
||||
|
||||
if (draw_background) {
|
||||
/* Reset default. */
|
||||
GPU_blend_set_func_separate(
|
||||
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_blend(false);
|
||||
}
|
||||
|
||||
/* Free temporary viewport. */
|
||||
if (viewport == NULL) {
|
||||
GPU_viewport_free(render_viewport);
|
||||
|
|
Loading…
Reference in New Issue