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

gpu_shader_multiply_and_blend_preprocessing.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88d84aeaef60b3d42ab251b3a02e71345021dddd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
uniform float opacity;

in vec4 finalColor;
out vec4 fragColor;

/* Blend Mode goal:
 *     First multiply the foreground and background and then mix the result
 *     of that with the background based on a opacity value.
 *
 *     result = background * foreground * opacity + background * (1 - opacity)
 *            = background * (foreground * opacity + (1 - opacity))
 *                           <------------------------------------>
 *                                 computed in this shader
 *
 * Afterwards the background and the new foreground only have to be multiplied.
 */

void main()
{
	fragColor = finalColor * opacity + (1 - opacity);
	fragColor.a = finalColor.a;
}