[Bf-blender-cvs] [396413dedf0] blender-v3.1-release: Partial Fix: Showing Compositor Backdrop in node editor.

Jeroen Bakker noreply at git.blender.org
Tue Feb 1 10:53:41 CET 2022


Commit: 396413dedf079478418771da159bb2c97bb0e4e9
Author: Jeroen Bakker
Date:   Tue Feb 1 10:49:28 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB396413dedf079478418771da159bb2c97bb0e4e9

Partial Fix: Showing Compositor Backdrop in node editor.

Since splitting the depth and the color shader in the image engine the
backdrop wasn't visible anymore. The reson is that the min max uv
coordinates were never working for the node editor backdrop that uses
its own coordinate space.

This partial fix will ignore the depth test when drawing the color part
of the backdrop. This will still have artifacts that are visible when
showing other options as RGBA.

Proper fix would be to calculate the the uv vbo in uv space and not in
image space.

===================================================================

M	source/blender/draw/engines/image/image_private.hh
M	source/blender/draw/engines/image/image_space_node.hh
M	source/blender/draw/engines/image/shaders/image_engine_color_frag.glsl

===================================================================

diff --git a/source/blender/draw/engines/image/image_private.hh b/source/blender/draw/engines/image/image_private.hh
index d8f8adb7e84..d586515c6be 100644
--- a/source/blender/draw/engines/image/image_private.hh
+++ b/source/blender/draw/engines/image/image_private.hh
@@ -54,6 +54,8 @@ struct IMAGE_Data {
 #define IMAGE_DRAW_FLAG_APPLY_ALPHA (1 << 1)
 #define IMAGE_DRAW_FLAG_SHUFFLING (1 << 2)
 #define IMAGE_DRAW_FLAG_DEPTH (1 << 3)
+/** Flag to disable depth testing (used for node editor back drop drawing).*/
+#define IMAGE_DRAW_FLAG_DEPTH_ALWAYS (1 << 4)
 
 /**
  * Abstract class for a drawing mode of the image engine.
diff --git a/source/blender/draw/engines/image/image_space_node.hh b/source/blender/draw/engines/image/image_space_node.hh
index 15eef8f6499..b0da3d1055b 100644
--- a/source/blender/draw/engines/image/image_space_node.hh
+++ b/source/blender/draw/engines/image/image_space_node.hh
@@ -56,6 +56,7 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
 
   void get_shader_parameters(ShaderParameters &r_shader_parameters, ImBuf *ibuf) override
   {
+    r_shader_parameters.flags |= IMAGE_DRAW_FLAG_DEPTH_ALWAYS;
     if ((snode->flag & SNODE_USE_ALPHA) != 0) {
       /* Show RGBA */
       r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHOW_ALPHA | IMAGE_DRAW_FLAG_APPLY_ALPHA;
diff --git a/source/blender/draw/engines/image/shaders/image_engine_color_frag.glsl b/source/blender/draw/engines/image/shaders/image_engine_color_frag.glsl
index 0edc18836f0..65fd4833b23 100644
--- a/source/blender/draw/engines/image/shaders/image_engine_color_frag.glsl
+++ b/source/blender/draw/engines/image/shaders/image_engine_color_frag.glsl
@@ -5,6 +5,7 @@
 #define IMAGE_DRAW_FLAG_APPLY_ALPHA (1 << 1)
 #define IMAGE_DRAW_FLAG_SHUFFLING (1 << 2)
 #define IMAGE_DRAW_FLAG_DEPTH (1 << 3)
+#define IMAGE_DRAW_FLAG_DEPTH_ALWAYS (1 << 4)
 
 #define FAR_DISTANCE farNearDistances.x
 #define NEAR_DISTANCE farNearDistances.y
@@ -12,9 +13,11 @@
 void main()
 {
   ivec2 uvs_clamped = ivec2(uv_screen);
-  float depth = texelFetch(depth_texture, uvs_clamped, 0).r;
-  if (depth == 1.0) {
-    discard;
+  if ((drawFlags & IMAGE_DRAW_FLAG_DEPTH_ALWAYS) == 0) {
+    float depth = texelFetch(depth_texture, uvs_clamped, 0).r;
+    if (depth == 1.0) {
+      discard;
+    }
   }
 
   vec4 tex_color = texelFetch(imageTexture, uvs_clamped, 0);



More information about the Bf-blender-cvs mailing list