summaryrefslogtreecommitdiffstats
path: root/src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-06-03 14:00:07 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-06-03 14:01:18 +0300
commit01cfc8025119609803b3fc00b1e8ca5bc56e84d0 (patch)
treec41480bbb06377f3a79d13c465a53435cccb9de4 /src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib
parentc36739204786bd90df6e2ef5a8be78c980240bdd (diff)
parent089d283afb8cde5024e60c29eeeeefc5c3c80543 (diff)
Merge branch '2.4'
Diffstat (limited to 'src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib')
-rw-r--r--src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib b/src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib
new file mode 100644
index 00000000..e07fe613
--- /dev/null
+++ b/src/Runtime/ogl-runtime/res/effectlib/blendColorLayers.glsllib
@@ -0,0 +1,45 @@
+#ifndef BLEND_COLOR_LAYERS_GLSLLIB
+#define BLEND_COLOR_LAYERS_GLSLLIB
+
+float maxValue( in vec3 t )
+{
+ return max( max( t.x, t.y ), t.z );
+}
+
+vec3 blendColor( in vec3 t, in vec3 b, in float weight, in int blendMode)
+{
+ vec3 blendResult = t;
+ switch( blendMode )
+ {
+ case color_layer_add :
+ blendResult += b;
+ break;
+ case color_layer_multiply :
+ blendResult *= b;
+ break;
+ case color_layer_screen :
+ blendResult += t - t * b;
+ break;
+ case color_layer_overlay:
+ blendResult = (maxValue(t) >= 0.5) ? 2.0 * (t+b - t*b - 0.5) : 2.0 * t*b;
+ break;
+ case color_layer_blend:
+ default:
+ // nothing to be done
+ break;
+ }
+
+ return mix( b, blendResult, weight );
+}
+
+texture_return blendColorLayers( in color_layer colorLayer[1], in vec3 base, in int monoSource )
+{
+ vec3 result = blendColor( colorLayer[0].layer_color, base, colorLayer[0].weight, colorLayer[0].mode );
+
+ texture_return tr;
+ tr.tint = result;
+ tr.mono = monoChannel( vec4( result, 1.0 ), monoSource );
+ return( tr );
+}
+
+#endif