Old 11-23-2020, 05:43 PM   #1
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 6,304
Default Slight better (??) blend modes

This will mix two video inputs together using one of 7 blend modes. It owes quite a lot to this thing from wwwmaze. Couple differences being:


--it explicitly overwrites the input to the track it's on with black so you don't accidentally get weird unintended bleedthrough. Put the things you want to mix on other tracks, and use the in1, in2 parameters to find them. Anything on the track with this plugin (or passed up from below) will be blacked out.
-----it allows you to choose from 64 different inputs rather than "only" 50.
--instead of referencing the blend modes as per the api, which includes like 13 that aren't really things, it only does the ones that actually do things.
-----it forces YUV mode so that modes 17-19 (5-7 here) actually work.
-----it rolls subtract right into the one mode control rather than a separate knob.
-----it includes "add inverse" which is significantly different from subtract. Could probably do the same thing by putting the "invert colors" preset on the in2 track and then just add, but...



Hope this helps somebody. It definitely helps me.


Code:
// ashcat_lt better blend modes
//@param1:blend 'blend' 0.5 0 1 0.5 0.01
//@param2:mode 'blend mode (normal, add, multiply, subtract, add inverse, average a, average b, difference' 0 0 7 0 1
//@param3:in1 'in 1 (-1=next video track)' -1 -1 50 0 1
//@param4:in2 'in 2 (-1=second next)' -1 -1 63 0 1

oldCS=colorspace;
colorspace='YV12';
gfx_set (0,0,0,1,0,-1);
gfx_fillrect (0,0,project_w,project_h);
gfx_blit(in1==-1 ? input_track(0) : in1);

temp = gfx_img_resize (temp,project_w,project_h);
gfx_dest = temp;

mode <= 1 ? //normal, add
 (gfx_blit (in2==-1 ? input_track(1) : in2);
  gfx_mode = mode;
  gfx_a = blend;);
mode == 2 ? //multiply
  (gfx_blit (in2==-1 ? input_track(1) : in2);
   gfx_mode = 3;
   gfx_a = blend;);
mode == 3 ? //subtract
  (gfx_blit (in2==-1 ? input_track(1) : in2);
   gfx_mode = 1;
   gfx_a = -1 * blend;);
mode == 4 ? //add inverse
 (gfx_mode = 0;
  gfx_set (1);  
  gfx_fillrect (0,0,project_w,project_h);
  gfx_mode = 1;
  gfx_a = -1;
  gfx_blit (in2==-1 ? input_track(1) : in2);
  gfx_a = blend;); 
mode == 5 ? //average a
 (gfx_blit (in2==-1 ? input_track(1) : in2);
  gfx_mode = 17;
  gfx_a = blend;);
mode == 6 ? //average b
 (gfx_blit (in2==-1 ? input_track(1) : in2);
  gfx_mode = 18;
  gfx_a = blend;);
mode == 7 ? //difference
 (gfx_blit (in2==-1 ? input_track(1) : in2);
  gfx_mode = 19;
  gfx_a = blend;);

gfx_dest = -1;
gfx_blit(temp);

colorspace=oldCS;
ashcat_lt is online now   Reply With Quote
Old 11-10-2021, 01:12 PM   #2
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 156
Default

Pretty cool. With blend=1 and blend mode=7 it creates some bizarre effects.
fuzzball is offline   Reply With Quote
Old 11-10-2021, 03:06 PM   #3
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 6,304
Default

Yeah difference mode is one of my secret weapons in visual work for like ever. Itís amazing having it available for video, and frankly the main reason I built this.
ashcat_lt is online now   Reply With Quote
Old 11-11-2021, 06:26 PM   #4
papagirafe
Human being with feelings
 
Join Date: Aug 2020
Posts: 107
Default

Thanks!

At last the various blend modes do make sense! My favorite is #7 for me too! That gave me an idea to try an undocumented feature suggested by some preset: negative alpha values. Here is a coll little experimental mod:

Code:
// ashcat_lt better blend modes
//@param blend 'blend' 0.5 0 1 0.5 0.01
//@param  mode 'blend mode (normal, add, multiply, subtract, add inverse, average a, average b, difference' 0 0 8 0 1
//@param in1 'in 1 (-1=next video track)' -1 -1 50 0 1
//@param in2 'in 2 (-1=second next)' -1 -1 63 0 1
//@param polarity 'blend polarity' 1 -1 1 0 2

blend*=polarity;
...(the rest is the same)
papagirafe is offline   Reply With Quote
Old 11-11-2021, 06:53 PM   #5
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 6,304
Default

Thatís a little redundant, I think. Mode 3 is already just mode 1 but with negative alpha. Mode 4 also uses negative alpha but in a slightly different way. I guess the other modes might do some things with negative alpha, but idk. Note that adding with negative alpha is not exactly the same thing as inverting and then adding, which is why I have the different modes.

Note also that the numbers I use in the parameter for mode do not actually correspond to the gfx_mode numbers used in the code itself. There are a number of unused and/or poorly documented gfx_modes, and I paired that all down to the few I found most useful and put them all on one knob without any blank spots.
ashcat_lt is online now   Reply With Quote
Old 11-12-2021, 05:33 AM   #6
papagirafe
Human being with feelings
 
Join Date: Aug 2020
Posts: 107
Default

Quote:
Originally Posted by ashcat_lt View Post
Thatís a little redundant, I think. Mode 3 is already just mode 1 but with negative alpha. Mode 4 also uses negative alpha but in a slightly different way. I guess the other modes might do some things with negative alpha, but idk. Note that adding with negative alpha is not exactly the same thing as inverting and then adding, which is why I have the different modes.

Note also that the numbers I use in the parameter for mode do not actually correspond to the gfx_mode numbers used in the code itself. There are a number of unused and/or poorly documented gfx_modes, and I paired that all down to the few I found most useful and put them all on one knob without any blank spots.
You're right! I was too eager to test new things after finishing an "intense" project and was just too just too tired to realize your preset was already doing that! I saw it in mode 3 this morning.
papagirafe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.