I made a custom gizmo, but I can’t use translucency(alpha), how do I fix it?
As I understand the gizmo uses the gl(OpenGL), as I can use gizmo to bgl.glEnable(bgl.GL_LINE_SMOOTH)?
Also I would like to use a custom Shader for the gizmo, for example ‘3D_UNIFORM_COLOR’. How can I do that?
Gizmo doing the type of standard gizmo_custom_geometry.py
Aha! I have just been wrestling with this myself to draw lines, tris and points on the 3D view. I used this for the shader:
import gpu
import bgl
from gpu_extras.batch import batch_for_shader
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') if not bpy.app.background else None
Later on in my draw function
batch = batch_for_shader(shader, type, {"pos": coords})
bgl.glEnable(bgl.GL_BLEND)
shader.bind()
shader.uniform_float("color", rgba)
batch.draw(shader)
You can also use bgl.glEnable(bgl.GL_LINE_SMOOTH)
and then set the colour to this:
rgba = (1.0, 0.0, 0.0, 0.8)
The last number is the Alpha, or transparency, this worked for me.
Hope this helps you! Clock.
1 Like
incredibly, it worked for me. I didn’t think it was that easy. you my Savior). I understand enough to add to the function draw bgl.glEnable(bgl.GL_BLEND) and immediately apply the translucency to work. Thank you)
1 Like