diff --git a/io_mesh_uv_layout/__init__.py b/io_mesh_uv_layout/__init__.py index bb7e45849015f51f380b68cab0a47c7abec55055..7145384cc5270004775c77a4319f8815b5cff737 100644 --- a/io_mesh_uv_layout/__init__.py +++ b/io_mesh_uv_layout/__init__.py @@ -3,7 +3,7 @@ bl_info = { "name": "UV Layout", "author": "Campbell Barton, Matt Ebb", - "version": (1, 1, 4), + "version": (1, 1, 5), "blender": (3, 0, 0), "location": "UV Editor > UV > Export UV Layout", "description": "Export the UV layout as a 2D graphic", diff --git a/io_mesh_uv_layout/export_uv_png.py b/io_mesh_uv_layout/export_uv_png.py index 2c40abdfe6b1e48e73e9033e84aa98b16d19bbd2..ad1b2284fcd0a954c84d51169b59b8498058f850 100644 --- a/io_mesh_uv_layout/export_uv_png.py +++ b/io_mesh_uv_layout/export_uv_png.py @@ -2,7 +2,6 @@ import bpy import gpu -import bgl from mathutils import Vector, Matrix from mathutils.geometry import tessellate_polygon from gpu_extras.batch import batch_for_shader @@ -26,10 +25,7 @@ def export(filepath, face_data, colors, width, height, opacity): def draw_image(face_data, opacity): - bgl.glLineWidth(1) - bgl.glEnable(bgl.GL_BLEND) - bgl.glEnable(bgl.GL_LINE_SMOOTH) - bgl.glHint(bgl.GL_LINE_SMOOTH_HINT, bgl.GL_NICEST) + gpu.state.blend_set('ALPHA') with gpu.matrix.push_pop(): gpu.matrix.load_matrix(get_normalize_uvs_matrix()) @@ -38,8 +34,7 @@ def draw_image(face_data, opacity): draw_background_colors(face_data, opacity) draw_lines(face_data) - bgl.glDisable(bgl.GL_BLEND) - bgl.glDisable(bgl.GL_LINE_SMOOTH) + gpu.state.blend_set('NONE') def get_normalize_uvs_matrix(): @@ -85,11 +80,12 @@ def draw_lines(face_data): coords.append((start[0], start[1])) coords.append((end[0], end[1])) - shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') - shader.bind() - shader.uniform_float("color", (0, 0, 0, 1)) - batch = batch_for_shader(shader, 'LINES', {"pos": coords}) + shader = gpu.shader.from_builtin('POLYLINE_UNIFORM_COLOR') + shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:]) + shader.uniform_float("lineWidth", 1.0) + shader.uniform_float("color", (0.0, 0.0, 0.0, 1.0)) + batch = batch_for_shader(shader, 'LINES', {"pos": coords}) batch.draw(shader)