[gtk+/wip/ebassi/gsk-renderer] gsk: Add more modes to the blend shader
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer] gsk: Add more modes to the blend shader
- Date: Sun, 3 Jul 2016 22:04:47 +0000 (UTC)
commit fc27c9d4f85f61b7bd101eb7d3431941e7f406ed
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jul 3 23:02:56 2016 +0100
gsk: Add more modes to the blend shader
Use the compositing CSS spec at:
https://www.w3.org/TR/compositing-1/#blending
For the implementation.
gsk/resources/glsl/blend.fs.glsl | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gsk/resources/glsl/blend.fs.glsl b/gsk/resources/glsl/blend.fs.glsl
index 5d2f873..ddc8d95 100644
--- a/gsk/resources/glsl/blend.fs.glsl
+++ b/gsk/resources/glsl/blend.fs.glsl
@@ -2,6 +2,17 @@ vec3 BlendMultiply(vec3 Csrc, vec3 Cdst) {
return Csrc * Cdst;
}
+vec3 BlendScreen(vec3 Csrc, vec3 Cdst) {
+ return Csrc + Cdst - (Csrc * Cdst);
+}
+
+vec3 BlendHardLight(vec3 Csrc, vec3 Cdst) {
+ vec3 m = BlendMultiply(Csrc, 2.0 * Cdst);
+ vec3 s = BlendScreen(Csrc, 2.0 * Cdst - 1.0);
+ vec3 e = vec3(0.5, 0.5, 0.5);
+ return mix(m, s, step(e, Cdst));
+}
+
void main() {
vec4 src = Texture(map, vUv);
vec4 mask = Texture(parentMap, vUv);
@@ -13,6 +24,12 @@ void main() {
else if (blendMode == 1) {
res = BlendMultiply(src.xyz, mask.xyz);
}
+ else if (blendMode == 2) {
+ res = BlendScreen(src.xyz, mask.xyz);
+ }
+ else if (blendMode == 8) {
+ res = BlendHardLight(src.xyz, mask.xyz);
+ }
else {
// Use red for debugging missing blend modes
res = vec3(1.0, 0.0, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]