diff options
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_multiply_and_blend_preprocessing.glsl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_multiply_and_blend_preprocessing.glsl b/source/blender/gpu/shaders/gpu_shader_multiply_and_blend_preprocessing.glsl new file mode 100644 index 00000000000..88d84aeaef6 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_multiply_and_blend_preprocessing.glsl @@ -0,0 +1,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; +} |