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:
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_tex_image.c')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 786386bb63e..6f3614e357d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -180,16 +180,32 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
}
if (out[0].hasoutput) {
- /* When the alpha socket is used, unpremultiply alpha. This makes it so
- * that if we blend the color with a transparent shader using alpha as
- * a factor, we don't multiply alpha into the color twice. */
- if (out[1].hasoutput &&
- !(ELEM(ima->alpha_mode, IMA_ALPHA_IGNORE, IMA_ALPHA_CHANNEL_PACKED) ||
- IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name))) {
- GPU_link(mat, "tex_color_alpha_unpremultiply", out[0].link, &out[0].link);
+ if (ELEM(ima->alpha_mode, IMA_ALPHA_IGNORE, IMA_ALPHA_CHANNEL_PACKED) ||
+ IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) {
+ /* Don't let alpha affect color output in these cases. */
+ GPU_link(mat, "tex_color_alpha_clear", out[0].link, &out[0].link);
}
else {
- GPU_link(mat, "tex_color_alpha_clear", out[0].link, &out[0].link);
+ /* Output premultiplied alpha depending on alpha socket usage. This makes
+ * it so that if we blend the color with a transparent shader using alpha as
+ * a factor, we don't multiply alpha into the color twice. And if we do
+ * not, then there will be no artifacts from zero alpha areas. */
+ if (ima->alpha_mode == IMA_ALPHA_PREMUL) {
+ if (out[1].hasoutput) {
+ GPU_link(mat, "tex_color_alpha_unpremultiply", out[0].link, &out[0].link);
+ }
+ else {
+ GPU_link(mat, "tex_color_alpha_clear", out[0].link, &out[0].link);
+ }
+ }
+ else {
+ if (out[1].hasoutput) {
+ GPU_link(mat, "tex_color_alpha_clear", out[0].link, &out[0].link);
+ }
+ else {
+ GPU_link(mat, "tex_color_alpha_premultiply", out[0].link, &out[0].link);
+ }
+ }
}
}