From 09ab371cfc808d087fc68b951177d012c892f9e9 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 19 Oct 2023 16:53:09 -0400 Subject: [PATCH 1/2] Blender Ktisu: Remove `bgl` from sqe>draw>draw_line() --- scripts-blender/addons/blender_kitsu/sqe/draw.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/sqe/draw.py b/scripts-blender/addons/blender_kitsu/sqe/draw.py index 7accc015..a3b75f51 100644 --- a/scripts-blender/addons/blender_kitsu/sqe/draw.py +++ b/scripts-blender/addons/blender_kitsu/sqe/draw.py @@ -23,7 +23,6 @@ import typing import bpy -import bgl import gpu from gpu_extras.batch import batch_for_shader @@ -54,7 +53,7 @@ Float4 = typing.Tuple[float, float, float, float] def draw_line(position: Float2, size: Float2, color: Float4): with gpu.matrix.push_pop(): - bgl.glEnable(bgl.GL_BLEND) + gpu.state.blend_set("ALPHA") gpu.matrix.translate(position) gpu.matrix.scale(size) @@ -64,7 +63,7 @@ def draw_line(position: Float2, size: Float2, color: Float4): ucolor_2d_shader.uniform_float("color", color) ucolor_2d_rect_batch.draw(ucolor_2d_shader) - bgl.glDisable(bgl.GL_BLEND) + gpu.state.blend_set("NONE") def get_strip_rectf(strip) -> Float4: -- 2.30.2 From ce2ba33ed5cb0c2e2039bbdb6cb2111a03696711 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 31 Oct 2023 07:04:37 -0400 Subject: [PATCH 2/2] Blender Kitsu: Fix Metastrip Sequence Drawing --- scripts-blender/addons/blender_kitsu/sqe/draw.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/sqe/draw.py b/scripts-blender/addons/blender_kitsu/sqe/draw.py index a3b75f51..237c6552 100644 --- a/scripts-blender/addons/blender_kitsu/sqe/draw.py +++ b/scripts-blender/addons/blender_kitsu/sqe/draw.py @@ -30,7 +30,7 @@ from gpu_extras.batch import batch_for_shader # Shaders and batches rect_coords = ((0, 0), (1, 0), (1, 1), (0, 1)) - +indices = ((0, 1, 2), (2, 3, 0)) # Setup shaders only if Blender runs in the foreground. # If running in the background, no handles are registered, as drawing extra UI # elements does not make sense. @@ -40,9 +40,9 @@ if bpy.app.version_string.split('.')[0] == '3': else: color_key = "UNIFORM_COLOR" if not bpy.app.background: - ucolor_2d_shader = gpu.shader.from_builtin(color_key) + ucolor_2d_shader = gpu.shader.from_builtin(color_key) ucolor_2d_rect_batch = batch_for_shader( - ucolor_2d_shader, "TRI_FAN", {"pos": rect_coords} + ucolor_2d_shader, "TRIS", {"pos": rect_coords}, indices=indices ) @@ -58,8 +58,6 @@ def draw_line(position: Float2, size: Float2, color: Float4): gpu.matrix.translate(position) gpu.matrix.scale(size) - # Render a colored rectangle - ucolor_2d_shader.bind() ucolor_2d_shader.uniform_float("color", color) ucolor_2d_rect_batch.draw(ucolor_2d_shader) -- 2.30.2