How to smooth the bound of the shape?
If you run the following script in blender,
you can see the Jagged Edge in that shape.
import bpy, gpu, bgl
from gpu_extras.batch import batch_for_shader
vertices = [[150, 41.52], [150, 71.52], [56, 234.39],
[30.0, 249.4], [270, 249.4], [244.02, 234.39]]
indices = ((0, 1, 2), (0, 2, 3), (2, 3, 4), (2, 4, 5), (0, 1, 4), (1, 5, 4))
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
def draw():
# bgl.glHint(bgl.GL_POLYGON_SMOOTH_HINT, bgl.GL_NICEST)
# bgl.glEnable(bgl.GL_BLEND)
# bgl.glEnable(bgl.GL_POLYGON_SMOOTH)
shader.bind()
shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
So, I try some code to smooth the bound.
bgl.glHint(bgl.GL_POLYGON_SMOOTH_HINT, bgl.GL_NICEST)
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_POLYGON_SMOOTH)
But it has some gap inside. I am no idea how to fix it.