# Transparency in Blender 2.8 GPU Python Module

I've been messing around with the new GPU python module in Blender 2.8. But I cannot find a way to make my lines and triangles transparent. The alpha channel is completely ignored. I even tried it with a vert frag shader and even that doesn't work out.

import bpy
import gpu
import bgl

uniform mat4 viewProjectionMatrix;

in vec3 position;
out vec3 pos;

void main()
{
pos = position;
gl_Position = viewProjectionMatrix * vec4(position, 1.0f);
}
'''

uniform float brightness;

in vec3 pos;

void main()
{
gl_FragColor = vec4(vec3(1, 0, 0) * brightness, 1.0);
}
'''

vertices = [(1, 0, 1), (-1, 0, 1), (-1, -0, -1), (1, 0, -1)]
indices = [(3, 0, 1), (1, 2, 3)]

verticesOutline = [(1, 0, 1), (-1, 0, 1), (-1, -0, -1), (1, 0, -1)]
indicesOutline = [(3, 0), (0, 1), (1, 2), (2, 3)]

def draw():
matrix = bpy.context.region_data.perspective_matrix

def drawOutlines():



So I found the answer to this one with some help from the folks on Blender.chat (thanks Okuma_10!).

In your draw method before you draw put in: -

glEnable(GL_BLEND)


and after you're done drawing put in: -

glDisable(GL_BLEND)


also make sure you import all of BGL with: -

from bgl import *


Apparently there is no performance cost for doing so as the program naturally iterates through the entire library anyway. After that the alpha values should work.

• Thanks, man! I already labeled this as impossible and started to think about alternative methods, like rendering a bunch of small dots to get kind of fake transparency or just drawing a wireframe as a last resort and there you come with the proper solution :D – WalterTheModeler Dec 19 '19 at 7:59