From 525da1f872a79a212e56f0692472d7831ddaf442 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 18 Feb 2013 17:39:44 +0000 Subject: [PATCH] Fix wrong alpha channel for OpenGL render results with transparent textures or materials, the typical glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); blend function does not give correct destination alpha. --- source/blender/gpu/intern/gpu_draw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 80f35d531cd..c631f7efbe9 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -395,7 +395,12 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) } else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* for OpenGL render we use the alpha channel, this makes alpha blend correct */ + if (GLEW_VERSION_1_4) + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + else + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* if U.glalphaclip == 1.0, some cards go bonkers... * turn off alpha test in this case */