Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-07 18:49:58 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-07 21:51:40 +0300
commitfb03f50e069d66c99391e4796e1b9eaa2b4cc133 (patch)
tree10c761cf548c6d4aa9160eed7c2798a96b798ccb /source/blender/draw/modes/object_mode.c
parentd05f27c7b95371db9e7e4e34a919a3623682a114 (diff)
Fix T64625: Eevee image textures with alpha have dark edges
Now texture storage of images is defined by the alpha mode of the image. The downside of this is that there can be artifacts near alpha edges where pixels with zero alpha bleed in. It also adds more code complexity since image textures are no longer all stored the same way. This changes allows us to keep using sRGB texture formats, which have edge darkening when stored with premultiplied alpha. Game engines seems to generally do the same thing, and we want to be compatible with them.
Diffstat (limited to 'source/blender/draw/modes/object_mode.c')
-rw-r--r--source/blender/draw/modes/object_mode.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 8dae160682a..bbf364960c9 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -974,9 +974,10 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
const bool use_alpha_blend = (ob->empty_image_flag & OB_EMPTY_IMAGE_USE_ALPHA_BLEND) != 0;
GPUTexture *tex = NULL;
+ Image *ima = ob->data;
- if (ob->data != NULL) {
- tex = GPU_texture_from_blender(ob->data, ob->iuser, GL_TEXTURE_2D);
+ if (ima != NULL) {
+ tex = GPU_texture_from_blender(ima, ob->iuser, GL_TEXTURE_2D);
if (tex) {
size[0] = GPU_texture_width(tex);
size[1] = GPU_texture_height(tex);
@@ -1023,6 +1024,8 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1);
DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1);
DRW_shgroup_uniform_texture(grp, "image", tex);
+ DRW_shgroup_uniform_bool_copy(
+ grp, "imagePremultiplied", (ima->alpha_mode == IMA_ALPHA_PREMUL));
DRW_shgroup_uniform_vec4(grp, "objectColor", ob->color, 1);
DRW_shgroup_uniform_bool_copy(grp, "useAlphaTest", !use_alpha_blend);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {