diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-03 20:03:29 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-07-03 20:03:29 +0300 |
commit | 749f346ce077f9616a47c03cac03f8537274efc4 (patch) | |
tree | 66ac85361c56bcd0deea3a5d61472222223e882c /source/blender/gpu/intern | |
parent | c503d1735351a74c43a3ae26c7ff774e940f2a26 (diff) |
BGE: Add alpha to coverage render mode.
This patch add a new option for transparency meshes : Alpha to coverage, in the game setting panel in material.
The alpha to coverage request a multisample, the best is 8x but 4x and 2x can also give nice render.
4x alpha clip : http://www.pasteall.org/pic/show.php?id=89464
4x alpha to coverage : http://www.pasteall.org/pic/show.php?id=89463
Reviewers: moguri, kupoman, campbellbarton, psy-fi
Reviewed By: psy-fi
Subscribers: lordloki, rdb
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1354
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a24067fc381..2186f20d173 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -409,15 +409,18 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) if (alphablend == GPU_BLEND_SOLID) { glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else if (alphablend == GPU_BLEND_ADD) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_ALPHA_TEST); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); } else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { glEnable(GL_BLEND); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); /* for OpenGL render we use the alpha channel, this makes alpha blend correct */ if (GLEW_VERSION_1_4) @@ -438,10 +441,16 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) } } else if (alphablend == GPU_BLEND_CLIP) { - glDisable(GL_BLEND); + glDisable(GL_BLEND); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); } + else if (alphablend == GPU_BLEND_ALPHA_TO_COVERAGE) { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, U.glalphaclip); + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } } static void gpu_verify_alpha_blend(int alphablend) |