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:
authorJacques Lucke <mail@jlucke.com>2018-09-24 18:10:29 +0300
committerJacques Lucke <mail@jlucke.com>2018-09-24 18:10:29 +0300
commit19f46c6ac071e32482969319f43d148ada97a63f (patch)
treef7a415bb592ebd2cf695c1526d75db2aeabd1b6e /source/blender/gpu/shaders
parent809be0099ea161eda0f149411651bd9fe84e1b6a (diff)
Weight Paint: Multiply overlay on the mesh
Use the multiply blending mode for the weight paint overlay. To support the opacity slider, we need a new shader. Otherwise this combination of multiplication and mixing does not seem to be supported by glBlendFunc. Reviewers: brecht Differential Revision: https://developer.blender.org/D3727
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_multiply_and_blend_preprocessing.glsl22
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;
+}