[Cin] I tried to add new blend mode but it does not work?

Andrew Randrianasulu randrianasulu at gmail.com
Sat Jun 26 18:17:05 CEST 2021


oops, I think there was error in this patch, yet even after fixing it I
can't see obvious result? (some other  modes also show only one obvious
colored track, not overlays.. so I think different, more complex test
project is needed)



On Saturday, June 26, 2021, Andrew Randrianasulu <randrianasulu at gmail.com>
wrote:

> see  attached patch (it copypastes badly)
>
> it compiles but I tried solid-color track over fading png text (as in
> black_flash.xml) and I can't see it working?
>
> I just hope it can serve as guide what to modify for adding new modes..
>
> I tried to write down math from this page:
> https://natron.readthedocs.io/en/rb-2.3/plugins/net.sf.
> openfx.MergePlugin.html
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20210626/f65b5edc/attachment.htm>
-------------- next part --------------
diff --git a/cinelerra-5.1/cinelerra/overlayframe.C b/cinelerra-5.1/cinelerra/overlayframe.C
index 270755cc..801ae9d3 100644
--- a/cinelerra-5.1/cinelerra/overlayframe.C
+++ b/cinelerra-5.1/cinelerra/overlayframe.C
@@ -351,5 +351,3 @@ int OverlayFrame::overlay(VFrame *output, VFrame *input,
 	}
 	return 0;
 }
-
-
diff --git a/cinelerra-5.1/cinelerra/overlayframe.h b/cinelerra-5.1/cinelerra/overlayframe.h
index 13c2e4bd..b6ebec35 100644
--- a/cinelerra-5.1/cinelerra/overlayframe.h
+++ b/cinelerra-5.1/cinelerra/overlayframe.h
@@ -45,6 +45,9 @@
 #define ONE 1
 #define TWO 2
 
+// Sa = source alpha, Sc = source color
+// Da = dst alpha, Dc = dst color
+
 // NORMAL	[Sa + Da * (1 - Sa), Sc * Sa + Dc * (1 - Sa)])
 #define ALPHA_NORMAL(mx, Sa, Da) (Sa + (Da * (mx - Sa)) / mx)
 #define COLOR_NORMAL(mx, Sc, Sa, Dc, Da) ((Sc * Sa + Dc * (mx - Sa)) / mx)
@@ -220,6 +223,12 @@
   (mabs(Sc * Da - Dc * Sa) / mx))
 #define CHROMA_DIFFERENCE COLOR_DIFFERENCE
 
+// REFLECT [Sa * Sa / (1 - Da]
+#define ALPHA_REFLECT (mx, Sa, Da) (Sa * Sa  * (mx - Da) / mx)
+#define COLOR_REFLECT (mx, Sc, Da, Dc, Da) (Sc * Sc * (mx - Dc) / mx)
+#define CHROMA_REFLECT COLOR_REFLECT
+
+
 static inline int   mabs(int32_t v) { return abs(v); }
 static inline int   mabs(int64_t v) { return llabs(v); }
 static inline float mabs(float v)   { return fabsf(v); }
diff --git a/cinelerra-5.1/cinelerra/overlayframe.inc b/cinelerra-5.1/cinelerra/overlayframe.inc
index 5f84036d..91e39fc9 100644
--- a/cinelerra-5.1/cinelerra/overlayframe.inc
+++ b/cinelerra-5.1/cinelerra/overlayframe.inc
@@ -24,7 +24,7 @@
 
 // Modes
 
-#define TRANSFER_TYPES 30
+#define TRANSFER_TYPES 31
 
 #define TRANSFER_NORMAL		0
 #define TRANSFER_ADDITION	1
@@ -56,6 +56,7 @@
 #define TRANSFER_HARDLIGHT	27
 #define TRANSFER_SOFTLIGHT	28
 #define TRANSFER_DIFFERENCE	29
+#define TRANSFER_REFLECT	30
 
 
 // Interpolation types
diff --git a/cinelerra-5.1/cinelerra/patchbay.C b/cinelerra-5.1/cinelerra/patchbay.C
index c2ae534d..fd17df1a 100644
--- a/cinelerra-5.1/cinelerra/patchbay.C
+++ b/cinelerra-5.1/cinelerra/patchbay.C
@@ -218,6 +218,7 @@ void PatchBay::create_objects()
 		"mode_hardlight",
 		"mode_softlight",
 		"mode_difference",
+		"mode_reflect",
 	};
 	for( int mode=0; mode<TRANSFER_TYPES; ++mode ) {
 		mode_icons[mode] = new BC_Pixmap(this,
diff --git a/cinelerra-5.1/cinelerra/vpatchgui.C b/cinelerra-5.1/cinelerra/vpatchgui.C
index 53ec27fb..a8ade2c4 100644
--- a/cinelerra-5.1/cinelerra/vpatchgui.C
+++ b/cinelerra-5.1/cinelerra/vpatchgui.C
@@ -354,6 +354,7 @@ void VModePatch::create_objects()
 	submenu->add_submenuitem(new VModeSubMenuItem(submenu, mode_to_text(TRANSFER_DIVIDE),   TRANSFER_DIVIDE));
 	submenu->add_submenuitem(new VModeSubMenuItem(submenu, mode_to_text(TRANSFER_MULTIPLY), TRANSFER_MULTIPLY));
 	submenu->add_submenuitem(new VModeSubMenuItem(submenu, mode_to_text(TRANSFER_REPLACE),  TRANSFER_REPLACE));
+	submenu->add_submenuitem(new VModeSubMenuItem(submenu, mode_to_text(TRANSFER_REFLECT),  TRANSFER_REFLECT));
 	add_item(mode_item = new VModePatchItem(this, _("PorterDuff..."), -1));
 	mode_item->add_submenu(submenu = new VModePatchSubMenu(mode_item));
 	submenu->add_submenuitem(new VModeSubMenuItem(submenu, mode_to_text(TRANSFER_DST),	TRANSFER_DST));
@@ -436,6 +437,7 @@ const char* VModePatch::mode_to_text(int mode)
 	case TRANSFER_HARDLIGHT:	return _("Hardlight");
 	case TRANSFER_SOFTLIGHT:	return _("Softlight");
 	case TRANSFER_DIFFERENCE:	return _("Difference");
+	case TRANSFER_REFLECT:		return _("Reflect");
 	}
 	return _("Normal");
 }


More information about the Cin mailing list