Camera background movieclips are not visible if "Viewport Shading" is set to "Rendered" #85750

Open
opened 2021-02-17 19:34:53 +01:00 by Sebastian · 14 comments

System Information
Operating system: Linux-5.4.0-65-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: Quadro RTX 6000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 450.102.04

Blender Version
Broken: version: 2.92.0 Beta, branch: master, commit date: 2021-02-15 19:10, hash: 3e55d7d605
Worked: 2.90.1
Caused by 3ffa0452af

Short description of error
While static background images of cameras are correctly visualized when "Viewport Shading" is set to "Rendered", background image sequences defined with the clip editor are only visible when "Viewport Shading" is set to "Material Preview", "Solid" or "Wireframe"

Exact steps for others to reproduce the error
In the following python script adjust the path such that it points to some valid input image.

background_image_test.py

Excecuting the script creates two cameras.

The first camera contains a static background image (see the code snippet below)

static_background_image = static_camera_data.background_images.new()
static_background_image.image = bpy.data.images.load(image_fp)

and is visible for all "Viewport Shading" types.
static_background_shading_rendered.png

The second camera contains a background image defined by a video clip (see the code snippet below),

dynamic_background_image = dynamic_camera_data.background_images.new()
dynamic_background_image.source = "MOVIE_CLIP"
dynamic_background_image.clip = bpy.data.movieclips[first_fn]

which is not visible when "Viewport Shading" is set to rendered.

**System Information** Operating system: Linux-5.4.0-65-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: Quadro RTX 6000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 450.102.04 **Blender Version** Broken: version: 2.92.0 Beta, branch: master, commit date: 2021-02-15 19:10, hash: `3e55d7d605` Worked: 2.90.1 Caused by 3ffa0452af **Short description of error** While static background images of cameras are correctly visualized when "Viewport Shading" is set to "Rendered", background image sequences defined with the clip editor are only visible when "Viewport Shading" is set to "Material Preview", "Solid" or "Wireframe" **Exact steps for others to reproduce the error** In the following python script adjust the path such that it points to some valid input image. [background_image_test.py](https://archive.blender.org/developer/F9812908/background_image_test.py) Excecuting the script creates two cameras. The first camera contains a static background image (see the code snippet below) ``` static_background_image = static_camera_data.background_images.new() static_background_image.image = bpy.data.images.load(image_fp) ``` and is visible for all "Viewport Shading" types. ![static_background_shading_rendered.png](https://archive.blender.org/developer/F9812938/static_background_shading_rendered.png) The second camera contains a background image defined by a video clip (see the code snippet below), ``` dynamic_background_image = dynamic_camera_data.background_images.new() dynamic_background_image.source = "MOVIE_CLIP" dynamic_background_image.clip = bpy.data.movieclips[first_fn] ``` which is not visible when "Viewport Shading" is set to rendered.
Author

Added subscriber: @sbcv

Added subscriber: @sbcv
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser self-assigned this 2021-02-18 10:39:50 +01:00
Member

Can confirm, will check.

Can confirm, will check.
Author

Nice, thank you!

Nice, thank you!
Member

note: actually works if Depth is set to Front

note: actually works if `Depth` is set to `Front`
Author

Can you elaborate this a little bit? (Where do I find this setting?)

Can you elaborate this a little bit? (Where do I find this setting?)
Member

In #85750#1114654, @sbcv wrote:
Can you elaborate this a little bit? (Where do I find this setting?)

image.png

Of course, Front is not always what you want (was more or less just a not to myself as I am looking at this soonish)

> In #85750#1114654, @sbcv wrote: > Can you elaborate this a little bit? (Where do I find this setting?) ![image.png](https://archive.blender.org/developer/F9814739/image.png) Of course, `Front` is not always what you want (was more or less just a not to myself as I am looking at this soonish)
Author

Thank you! This allows me to create a workaround (for previous Blender versions) when importing reconstructions with the photogrammetry addon.

Thank you! This allows me to create a workaround (for previous Blender versions) when importing reconstructions with the photogrammetry addon.
Member

Added subscribers: @fclem, @Jeroen-Bakker

Added subscribers: @fclem, @Jeroen-Bakker
Member

Caused by 3ffa0452af.

Been looking into it a bit, but not sure what is wrong with blending, shotgun debugging gives me this working solution (but I assume this is against the intentions of DRW_STATE_BLEND_ALPHA_UNDER_PREMUL):

P1969: T85750_snippet



diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c
index 844a0eb8351..666355b859b 100644
--- a/source/blender/draw/engines/overlay/overlay_image.c
+++ b/source/blender/draw/engines/overlay/overlay_image.c
@@ -57,7 +57,8 @@ void OVERLAY_image_cache_init(OVERLAY_Data *vedata)
 
   state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_GREATER | DRW_STATE_BLEND_ALPHA_PREMUL;
   DRW_PASS_CREATE(psl->image_background_ps, state);
-  state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL;
+  state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
+          DRW_STATE_BLEND_ALPHA_UNDER_PREMUL;
   DRW_PASS_CREATE(psl->image_background_scene_ps, state);
 
   state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc
index b837eae4871..7ffb037f55e 100644
--- a/source/blender/gpu/opengl/gl_state.cc
+++ b/source/blender/gpu/opengl/gl_state.cc
@@ -422,10 +422,10 @@ void GLStateManager::set_blend(const eGPUBlend value)
       break;
     }
     case GPU_BLEND_ALPHA_UNDER_PREMUL: {
-      src_rgb = GL_ONE_MINUS_DST_ALPHA;
-      dst_rgb = GL_ONE;
-      src_alpha = GL_ONE_MINUS_DST_ALPHA;
-      dst_alpha = GL_ONE;
+      src_rgb = GL_ONE;
+      dst_rgb = GL_ONE_MINUS_DST_ALPHA;
+      src_alpha = GL_ONE;
+      dst_alpha = GL_ONE_MINUS_DST_ALPHA;
       break;
     }
     case GPU_BLEND_CUSTOM: {

Will set this to High prio since it is a regression

CC @Jeroen-Bakker
CC @fclem

Caused by 3ffa0452af. Been looking into it a bit, but not sure what is wrong with blending, shotgun debugging gives me this working solution (but I assume this is against the intentions of `DRW_STATE_BLEND_ALPHA_UNDER_PREMUL`): [P1969: T85750_snippet](https://archive.blender.org/developer/P1969.txt) ``` diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index 844a0eb8351..666355b859b 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -57,7 +57,8 @@ void OVERLAY_image_cache_init(OVERLAY_Data *vedata) state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_GREATER | DRW_STATE_BLEND_ALPHA_PREMUL; DRW_PASS_CREATE(psl->image_background_ps, state); - state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL; + state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND_ALPHA_UNDER_PREMUL; DRW_PASS_CREATE(psl->image_background_scene_ps, state); state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index b837eae4871..7ffb037f55e 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -422,10 +422,10 @@ void GLStateManager::set_blend(const eGPUBlend value) break; } case GPU_BLEND_ALPHA_UNDER_PREMUL: { - src_rgb = GL_ONE_MINUS_DST_ALPHA; - dst_rgb = GL_ONE; - src_alpha = GL_ONE_MINUS_DST_ALPHA; - dst_alpha = GL_ONE; + src_rgb = GL_ONE; + dst_rgb = GL_ONE_MINUS_DST_ALPHA; + src_alpha = GL_ONE; + dst_alpha = GL_ONE_MINUS_DST_ALPHA; break; } case GPU_BLEND_CUSTOM: { ``` Will set this to High prio since it is a regression CC @Jeroen-Bakker CC @fclem
Philipp Oeser removed their assignment 2021-02-18 14:13:15 +01:00
Philipp Oeser changed title from Camera background images defined with bpy.data.movieclips() are not visible if "Viewport Shading" is set to "Rendered" to Camera background movieclips are not visible if "Viewport Shading" is set to "Rendered" 2021-02-19 09:15:19 +01:00
Member

This used to be a known issue. To show it the film transparency has to be turned on. The change above does seem to work for me and would introduce blending with other images.

This used to be a known issue. To show it the film transparency has to be turned on. The change above does seem to work for me and would introduce blending with other images.

Added subscriber: @2046411367

Added subscriber: @2046411367
Member

Lowering prio, as this one flew below the radar.

Lowering prio, as this one flew below the radar.
Jeroen Bakker self-assigned this 2021-06-01 17:05:23 +02:00
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:13:59 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#85750
No description provided.