From 9418e3943d4ce2e12f24a7796bcc5472d2a2dffc Mon Sep 17 00:00:00 2001 From: Durman Date: Tue, 25 Jul 2023 11:26:20 +0400 Subject: [PATCH] closes #4915 fix according Blender API changes - https://projects.blender.org/blender/blender/commit/8cfca8e1bd85 --- .../bpy_stuff/bgl_3dview_drawing.py | 3 ++- nodes/solid/solid_viewer.py | 6 ++++-- nodes/viz/vd_matrix.py | 3 ++- nodes/viz/viewer_draw_curve.py | 10 ++++++---- nodes/viz/viewer_draw_mk4.py | 18 ++++++++++++------ nodes/viz/viewer_draw_surface.py | 10 ++++++---- old_nodes/vd_draw_experimental.py | 7 ++++--- utils/nodeview_time_graph_drawing.py | 3 ++- utils/sv_batch_primitives.py | 7 ++++--- utils/sv_idx_viewer28_draw.py | 3 ++- 10 files changed, 44 insertions(+), 26 deletions(-) diff --git a/node_scripts/SNLite_templates/bpy_stuff/bgl_3dview_drawing.py b/node_scripts/SNLite_templates/bpy_stuff/bgl_3dview_drawing.py index 47d999b6aa..99722e5220 100644 --- a/node_scripts/SNLite_templates/bpy_stuff/bgl_3dview_drawing.py +++ b/node_scripts/SNLite_templates/bpy_stuff/bgl_3dview_drawing.py @@ -20,7 +20,8 @@ def screen_v3dBGL(context, args): points = args[0] colors = args[1] # expects 4-tuple r g b a - shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + shader = gpu.shader.from_builtin(shader_name) batch = batch_for_shader(shader, 'POINTS', {"pos": points, "color": colors}) batch.draw(shader) diff --git a/nodes/solid/solid_viewer.py b/nodes/solid/solid_viewer.py index 91c0c2ae1b..dc3e207c77 100644 --- a/nodes/solid/solid_viewer.py +++ b/nodes/solid/solid_viewer.py @@ -103,7 +103,8 @@ def draw_uniform(GL_KIND, coords, indices, color, width=1, dashed_data=None): else: # print(GL_KIND,coords) - shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + shader = gpu.shader.from_builtin(shader_name) batch = batch_for_shader(shader, GL_KIND, {"pos" : coords}, **params) shader.bind() shader.uniform_float("color", color) @@ -117,7 +118,8 @@ def draw_uniform(GL_KIND, coords, indices, color, width=1, dashed_data=None): def draw_smooth(coords, vcols, indices=None): - shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + shader = gpu.shader.from_builtin(shader_name) params = dict(indices=indices) if indices else {} batch = batch_for_shader(shader, 'TRIS', {"pos" : coords, "color": vcols}, **params) batch.draw(shader) diff --git a/nodes/viz/vd_matrix.py b/nodes/viz/vd_matrix.py index 9b79d88fdf..6a3bb98651 100644 --- a/nodes/viz/vd_matrix.py +++ b/nodes/viz/vd_matrix.py @@ -31,7 +31,8 @@ from sverchok.node_tree import SverchCustomTreeNode if not bpy.app.background: - smooth_2d_shader = gpu.shader.from_builtin('2D_SMOOTH_COLOR') + shader_name = f'{"2D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + smooth_2d_shader = gpu.shader.from_builtin(shader_name) else: smooth_2d_shader = None diff --git a/nodes/viz/viewer_draw_curve.py b/nodes/viz/viewer_draw_curve.py index a5c4e6de97..2985672212 100644 --- a/nodes/viz/viewer_draw_curve.py +++ b/nodes/viz/viewer_draw_curve.py @@ -280,12 +280,14 @@ def sv_init(self, context): self.inputs.new('SvStringsSocket', 'Resolution').prop_name = 'resolution' def draw_all(self, draw_inputs): - - v_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + v_shader = gpu.shader.from_builtin(shader_name) if self.draw_curvature: - e_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + e_shader = gpu.shader.from_builtin(shader_name) else: - e_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + e_shader = gpu.shader.from_builtin(shader_name) draw_data = { 'tree_name': self.id_data.name[:], diff --git a/nodes/viz/viewer_draw_mk4.py b/nodes/viz/viewer_draw_mk4.py index 3d4c0eb9d3..c24f937ea7 100644 --- a/nodes/viz/viewer_draw_mk4.py +++ b/nodes/viz/viewer_draw_mk4.py @@ -455,28 +455,34 @@ def generate_mesh_geom(config, vecs_in): if config.draw_verts: if config.uniform_verts: - config.v_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + config.v_shader = gpu.shader.from_builtin(shader_name) else: - config.v_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + config.v_shader = gpu.shader.from_builtin(shader_name) geom.v_vertices, geom.points_color = v_vertices, points_color if config.draw_edges: if config.edges_use_vertex_color and e_vertices: e_vertex_colors = points_color if config.uniform_edges: - config.e_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + config.e_shader = gpu.shader.from_builtin(shader_name) else: - config.e_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + config.e_shader = gpu.shader.from_builtin(shader_name) geom.e_vertices, geom.e_vertex_colors, geom.e_indices = e_vertices, e_vertex_colors, e_indices if config.draw_polys and config.shade_mode != 'fragment': if config.uniform_pols: - config.p_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + config.p_shader = gpu.shader.from_builtin(shader_name) else: if config.polygon_use_vertex_color and config.shade_mode not in ['facet', 'smooth']: p_vertex_colors = points_color - config.p_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + config.p_shader = gpu.shader.from_builtin(shader_name) geom.p_vertices, geom.p_vertex_colors, geom.p_indices = p_vertices, p_vertex_colors, p_indices elif config.shade_mode == 'fragment' and config.draw_polys: diff --git a/nodes/viz/viewer_draw_surface.py b/nodes/viz/viewer_draw_surface.py index 456769ac32..4ee9f626cd 100644 --- a/nodes/viz/viewer_draw_surface.py +++ b/nodes/viz/viewer_draw_surface.py @@ -261,10 +261,12 @@ def draw_buttons_ext(self, context, layout): self.draw_buttons(context, layout) def draw_all(self, draw_inputs): - - v_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') - e_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') - p_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + v_shader = gpu.shader.from_builtin(shader_name) + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + e_shader = gpu.shader.from_builtin(shader_name) + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + p_shader = gpu.shader.from_builtin(shader_name) draw_data = { 'tree_name': self.id_data.name[:], diff --git a/old_nodes/vd_draw_experimental.py b/old_nodes/vd_draw_experimental.py index 17704437c9..5c5acef29a 100644 --- a/old_nodes/vd_draw_experimental.py +++ b/old_nodes/vd_draw_experimental.py @@ -155,8 +155,8 @@ def draw_uniform(GL_KIND, coords, indices, color, width=1, dashed_data=None): batch.draw(shader) else: - - shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + shader = gpu.shader.from_builtin(shader_name) batch = batch_for_shader(shader, GL_KIND, {"pos" : coords}, **params) shader.bind() shader.uniform_float("color", color) @@ -170,7 +170,8 @@ def draw_uniform(GL_KIND, coords, indices, color, width=1, dashed_data=None): def draw_smooth(coords, vcols, indices=None): - shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + shader = gpu.shader.from_builtin(shader_name) params = dict(indices=indices) if indices else {} batch = batch_for_shader(shader, 'TRIS', {"pos" : coords, "color": vcols}, **params) batch.draw(shader) diff --git a/utils/nodeview_time_graph_drawing.py b/utils/nodeview_time_graph_drawing.py index 67a0b8a7a1..ff8307e3c9 100644 --- a/utils/nodeview_time_graph_drawing.py +++ b/utils/nodeview_time_graph_drawing.py @@ -268,7 +268,8 @@ def start_time_graph(ng): ng.update_gl_scale_info(origin=f"configure_time_graph, tree: {ng.name}") named_tree = ng.name - shader = gpu.shader.from_builtin('2D_SMOOTH_COLOR') + shader_name = f'{"2D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + shader = gpu.shader.from_builtin(shader_name) data_overlay = (None, shader, named_tree) config_graph_overlay = { diff --git a/utils/sv_batch_primitives.py b/utils/sv_batch_primitives.py index 18de91d3f8..109523373d 100644 --- a/utils/sv_batch_primitives.py +++ b/utils/sv_batch_primitives.py @@ -19,9 +19,10 @@ def draw_matrix(self, *args, **kwargs): sv_logger.info("draw_matrix: do nothing in background mode") else: - - uniform_shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') - smooth_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}UNIFORM_COLOR' + uniform_shader = gpu.shader.from_builtin(shader_name) + shader_name = f'{"3D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + smooth_shader = gpu.shader.from_builtin(shader_name) class MatrixDraw28(object): diff --git a/utils/sv_idx_viewer28_draw.py b/utils/sv_idx_viewer28_draw.py index 12df2384c7..14266dee17 100644 --- a/utils/sv_idx_viewer28_draw.py +++ b/utils/sv_idx_viewer28_draw.py @@ -274,7 +274,8 @@ def draw_all_text_at_once(final_draw_data): add_vcol((col,) * 6) # draw background - shader = gpu.shader.from_builtin('2D_SMOOTH_COLOR') + shader_name = f'{"2D_" if bpy.app.version < (3, 4) else ""}SMOOTH_COLOR' + shader = gpu.shader.from_builtin(shader_name) batch = batch_for_shader(shader, 'TRIS', {"pos": full_bg_Verts, "color": full_bg_colors}) batch.draw(shader)