Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 02-10-2022, 03:04 PM   #1
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default Overlay: text with adjustable outline/shadow

Hi folks,



Thanks to eviluess in this thread, I took the challenge to make a better outline effect for fonts. In the process I found an opportunity with the same method to add a better shadow effect with adjustable angle. This version of the text overlay has the following main features:

- Text w/adjustable color/transparency, if transparency set to -0.1 use item fade
- background color/size/ with transparency relative to text transparency
- adjustable outline/shadow color/thickness with same transparency as text
- adjustable shadow angle

Code:
// Overlay: Text v2.2 w/ajustable outline/shadow
// by papagirafe
// Write your own text inside quotes, multiple lines allowed
// if empty, text = item/track name
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.1 1 0.5 0.1

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 64 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  img=gfx_img_alloc();           // first, image handle only
  gfx_img_resize(img,-1,-1);     // incantation to summon alpha plane
  gfx_img_resize(img,w,h);       // real size now
  gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
  gfx_fillrect(0,0,w,h);         
  img;
);

function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; bga*=fga; mode=0x10000;
input = 0;
project_wh_valid===0 ? input_info(input,project_w,project_h);
gfx_blit(input,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h-txth*(1+bgh*2))*ypos;

bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

olt>0?(
 shangl=shmode?shangl*oldiv/360:0; 
 gfx_set(olr,olg,olb,1,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

gfx_dest=-1; gfx_a=fga;
gfx_blit(img,1,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt); 

gfx_img_free(img);
papagirafe is offline   Reply With Quote
Old 02-10-2022, 05:00 PM   #2
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Great, now we can make animated memes.
vitalker is offline   Reply With Quote
Old 02-11-2022, 05:13 AM   #3
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

wow.thanks, very good


but why fga to -0.1 (text alpha)?

and (worst) why the green thing around my text ? (seems to show the outer extends of the text and has something to do with this magical function
gfx_img_alloc_transparent
which i have no clue what this does

i'm using your script as itemfx



click to enlarge
bobobo is offline   Reply With Quote
Old 02-11-2022, 08:06 AM   #4
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by bobobo View Post
wow.thanks, very good


but why fga to -0.1 (text alpha)?

and (worst) why the green thing around my text ? (seems to show the outer extends of the text and has something to do with this magical function
gfx_img_alloc_transparent
which i have no clue what this does

i'm using your script as itemfx



click to enlarge

1) fga = -0.1 means use item fade for alpha any value >= 0 is the normal behaviour

2) green is a condition I didn't think of in my tests. In its current form the preset assumes that you are writing the text on a item that contains a bitmap or a video. Normally green mean a missing bitmap or an empty midi item which seems to be the case here (hopefully). As a patch any transparent PNG file resized to project dimension (with preserve aspect=0) would do the trick until I can come up with a workaround.

Here is a 10x10 transparent png to help


p.s. the magical function is there to allow a consistent alpha (a.k.a transparency) behavior of the outlined text.
papagirafe is offline   Reply With Quote
Old 02-11-2022, 09:16 AM   #5
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

cool



click2view

Last edited by bobobo; 02-11-2022 at 09:43 AM.
bobobo is offline   Reply With Quote
Old 02-11-2022, 11:51 AM   #6
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by bobobo View Post
cool



click2view
Super! :-) BTW I was able to recreate the problem and I am not sure yet how to avoid it so the workaround will stay for now. This "workaround" is useful to separate all your texts items on a separate track (with higher priority) and the font size will always be consistent.
papagirafe is offline   Reply With Quote
Old 02-12-2022, 05:27 AM   #7
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

hi
i played around with it and made a variation with a switch to use in solo or contextual use
technically a switch dealing with the A in the gfx_set in your magical function

Code:
// Overlay: Text v2.2 w/ajustable outline/shadow
// by papagirafe
// Write your own text inside quotes, multiple lines allowed
// if empty, text = item/track name
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   
//@param mm 'solo or context'  0 0 1 0.5 1
//@param3:size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param7:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.1 1 0.5 0.1

//@param12:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param18:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 64 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h,mm) 
(
  img=gfx_img_alloc();           // first, image handle only
  gfx_img_resize(img,-1,-1);     // incantation to summon alpha plane
  gfx_img_resize(img,w,h);       // real size now
  gfx_set(0,0,0,mm,0x10000,img);  // 100% transparent "black"
  gfx_fillrect(0,0,w,h);         
  img;
);

function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; bga*=fga; mode=0x10000;
input = 0;
project_wh_valid===0 ? input_info(input,project_w,project_h);
gfx_blit(input,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h-txth*(1+bgh*2))*ypos;

bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt,mm);

olt>0?(
 shangl=shmode?shangl*oldiv/360:0; 
 gfx_set(olr,olg,olb,1,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

gfx_dest=-1; gfx_a=fga;
gfx_blit(img,1,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt); 

gfx_img_free(img);
greetings

Last edited by bobobo; 02-12-2022 at 05:32 AM.
bobobo is offline   Reply With Quote
Old 02-14-2022, 05:15 AM   #8
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Hi bobobo!

The solution was indeed fixing the "magic" function. I reorganized a few things in the code and transferred the test for "missing" media file inside that function. Here is the fixed version of the preset taking this condition into account.
Beware that putting an envelope on font size will provoque strange graphical artifacts that I cannot yet explain: it is a recurrent problem I experienced with "resizing" gfx_blits in other presets. Food for thought...

Code:
// Overlay: Text v2.21 w/ajustable outline/shadow
// by papagirafe
// Write your own text inside quotes, multiple lines allowed
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.1 1 0.5 0.1

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 32 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  input_info(0,iw,ih); 
  iw>0&&ih>0?(  //media file exists?
    img=gfx_img_alloc();           // first, image handle only
    gfx_img_resize(img,-1,-1);     // summon alpha plane
    gfx_img_resize(img,w,h);       // real size now
    gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
    gfx_fillrect(0,0,w,h);         
  ):(
    img=gfx_img_alloc(w,h,1);      // std cleared image
  );
  img;
);

function set_project_wh_safe(w*,h*)
(
  project_wh_valid===0 ? ( 
    input_info(0,w,h);  // no pw,ph get from current item
    w==0||h==0?(w=480; h=270;); // worst case scenario? 1/4 HD
  );
);
function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; 
bga*=fga; //bg alpha dependent upon fg alpha
mode=0x10000; //use alpha
set_project_wh_safe(project_w, project_h);

gfx_blit(0,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h-txth*(1+bgh*2))*ypos;

// background if applicable
bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

//temporary image using alpha 1 for consistent drawing
img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

// outline/shadow of applicable
olt>0?(
 shangl=shmode?shangl*oldiv/360:0; 
 gfx_set(olr,olg,olb,1,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
// text
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

// copy tmp img to frame buffer with desired alpha value
gfx_dest=-1; gfx_a=fga;
gfx_blit(img,1,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt); 
gfx_img_free(img);

Last edited by papagirafe; 02-14-2022 at 06:41 AM. Reason: typos
papagirafe is offline   Reply With Quote
Old 02-14-2022, 10:44 AM   #9
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

yes ..

i think i can see a background in textcolor when fga on 1 bga on 0

but hey ..
bobobo is offline   Reply With Quote
Old 02-14-2022, 11:55 AM   #10
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by bobobo View Post
yes ..

i think i can see a background in textcolor when fga on 1 bga on 0

but hey ..
Yes there is a rounding bug of some kind with the gfx_blit() function that creates visible lines. Never figured out where that is coming from even in my other homemade presets. The patch is to ajust the font size slightly by 0.001 until the lines disappear. Hope I (or someone) finds a solution soon! :-)

Last edited by papagirafe; 02-14-2022 at 11:56 AM. Reason: typos
papagirafe is offline   Reply With Quote
Old 02-15-2022, 01:08 AM   #11
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

i got somehow a better result (though not perfect) when setting the preserve aspect to 0 in both gfx_blit 's

less computing results in a more fluent ouput i guess.

also i put a little tweak in the last gfx_blit that fiddles with the xpos and the width (subtracting and adding 1)
this seems to cure the artzifacts

greetz

Code:
// Overlay: Text v2.21 w/ajustable outline/shadow
// by papagirafe , slightly edited by bobobo
// Write your own text inside quotes, multiple lines allowed
#text="test"; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='B';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.1 1 0.5 0.1

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 32 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  input_info(0,iw,ih); 
  iw>0&&ih>0?(  //media file exists?
    img=gfx_img_alloc();           // first, image handle only
    gfx_img_resize(img,-1,-1);     // summon alpha plane
    gfx_img_resize(img,w,h);       // real size now
    gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
    gfx_fillrect(0,0,w,h);         
  ):(
    img=gfx_img_alloc(w,h,1);      // std cleared image
  );
  img;
);

function set_project_wh_safe(w*,h*)
(
  project_wh_valid===0 ? ( 
    input_info(0,w,h);  // no pw,ph get from current item
    w==0||h==0?(w=480; h=270;); // worst case scenario? 1/4 HD
  );
);
function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; 
bga*=fga; //bg alpha dependent upon fg alpha
mode=0x10000; //use alpha
set_project_wh_safe(project_w, project_h);

gfx_blit(0,0);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h-txth*(1+bgh*2))*ypos;

// background if applicable
bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

//temporary image using alpha 1 for consistent drawing
img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

// outline/shadow of applicable
olt>0?(
 shangl=shmode?shangl*oldiv/360:0; 
 gfx_set(olr,olg,olb,1,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
// text
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

// copy tmp img to frame buffer with desired alpha value
gfx_dest=-1; gfx_a=fga;
gfx_blit(img,0,xpos*(project_w-txtw)-olt-1,yt+txth*bgh-olt,txtw+2*olt+1,txth+2*olt); 
// gfx_blit(img,0); 
gfx_img_free(img);

Last edited by bobobo; 02-15-2022 at 04:29 AM.
bobobo is offline   Reply With Quote
Old 02-15-2022, 01:32 PM   #12
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

I can't figure out how to make the green box surrounding the text go away. I can set BG A to zero and there's still a green box.

If I set BG A to >0 then I get a larger back box around that.

Basically I create a project and add one track with a video. On that video I add the overlay as a video FX.

Have also tried adding the overlay to an otherwise empty track above the video track with the same results.
fuzzball is offline   Reply With Quote
Old 02-15-2022, 02:28 PM   #13
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

put the transparent imgage mentioned above (posting 4) and lay this fx on it
bobobo is offline   Reply With Quote
Old 02-15-2022, 04:22 PM   #14
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by bobobo View Post
i got somehow a better result (though not perfect) when setting the preserve aspect to 0 in both gfx_blit 's

less computing results in a more fluent ouput i guess.

also i put a little tweak in the last gfx_blit that fiddles with the xpos and the width (subtracting and adding 1)
this seems to cure the artzifacts

greetz
Hi Bobobo and Fuzzball,

Here is a new and improved version of the preset! I fixed the green and also the last the extra unwanted lines on empty background so please take this last version of the preset (v2.23). I added a super cool feature: ajustable transparency of the outline/shadow. A alpha of 1 will duplicate the old behavior.



Code:
// Overlay: Text v2.23 w/ajustable outline/shadow
// by papagirafe
// Write your own text inside quotes, multiple lines allowed
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.01 1 0.5 0.01

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param ola 'outline a' 0.1 0.01 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 32 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  input_info(0,iw,ih); 
  iw>0&&ih>0?(  //media file exists?
    img=gfx_img_alloc();           // first, image handle only
    gfx_img_resize(img,-1,-1);     // summon alpha plane
    gfx_img_resize(img,w+1,h+1);       // real size now (w+1/h+1 = gfx_blit() bug patch)
    gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
    gfx_fillrect(0,0,w,h);         
  ):(
    img=gfx_img_alloc(w+1,h+1,1);      // std cleared image (w+1/h+1 = gfx_blit() bug patch)
  );
  img;
);

function set_project_wh_safe(w*,h*)
(
  project_wh_valid===0 ? ( 
    input_info(0,w,h);  // no pw,ph get from current item
    w==0||h==0?(w=480; h=270;); // worst case scenario? 1/4 HD
  );
);

function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; 
bga*=fga; //bg alpha dependent upon fg alpha
mode=0x10000; //use alpha
set_project_wh_safe(project_w, project_h);

gfx_blit(0,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt =(project_h-txth*(1+bgh*2))*ypos;

// background if applicable
bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

//temporary image using alpha 1 for consistent drawing
img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

// pourtour du texte si applicable
olt>0?(
  shmode?(ola=exp(ola*fga*3.5-4);shangl=shangl*oldiv/360):(ola=exp((oldiv/16)*ola*fga-4.61);shangl=0;); 
  gfx_set(olr,olg,olb,ola*fga,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
// text
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

// copy tmp img to frame buffer with desired alpha value
gfx_dest=-1; gfx_a=fga;
gfx_blit(img,0,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt,0,0,txtw+2*olt,txth+2*olt); 
gfx_img_free(img);
papagirafe is offline   Reply With Quote
Old 02-15-2022, 10:35 PM   #15
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

smooth , well done


Last edited by bobobo; 02-15-2022 at 10:51 PM.
bobobo is offline   Reply With Quote
Old 02-16-2022, 03:49 AM   #16
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by bobobo View Post
smooth , well done
I had excellent and pertinent feedback! thanks!
papagirafe is offline   Reply With Quote
Old 02-16-2022, 11:01 AM   #17
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

Quote:
Originally Posted by bobobo View Post
put the transparent imgage mentioned above (posting 4) and lay this fx on it
I guess I'm dense, or perhaps my underlying Reaper settings don't agree with this FX, but I'm also not really sure what the above somewhat ambiguous suggestion means.

I downloaded the 10x10 image and put it on a blank timeline on an empty project, and stretched it out to cover some time. I added this FX to the track.

If this is the only track on the project I get a fuzzy blob using the default settings for the FX. Playing with the dials still shows no text. Just fuzzy blobs.

Putting a video on a second track shows no video unless I put it in front, and then I see no text.

If I put the FX directly on a video then I see the text, but the text is surrounded by a green rectangle. You cannot see the video through the text.

Can someone strip away the ambiguity and say what is the simplest possible project that can display a video with this text over it. One video, no other FX?
fuzzball is offline   Reply With Quote
Old 02-16-2022, 12:02 PM   #18
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

to make it short
i made a demo project

that creates this video

i hope this helps

greetz
bobobo is offline   Reply With Quote
Old 02-16-2022, 02:47 PM   #19
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

Thanks for the help. Your RPP file has three tracks. And they display text on a black screen when I play it like that.

Now try this. Take a MP4 video and drop it in as the 4th track and see what happens when you play it.

You may need to insert the video as track 1 depending on [File>Project Settings>Video Tab>Video item visibility]. Mine is set to "Lower replaces higher".

You still see the text, but it is now superimposed over a green rectangle that blocks the underlying video. Is there any way that green rectangle can be made transparent so that the video can be seen behind the text? Or is this something that needs to be combined with a Chroma-key plugin?
fuzzball is offline   Reply With Quote
Old 02-16-2022, 03:20 PM   #20
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by fuzzball View Post
I guess I'm dense, or perhaps my underlying Reaper settings don't agree with this FX, but I'm also not really sure what the above somewhat ambiguous suggestion means.

I downloaded the 10x10 image and put it on a blank timeline on an empty project, and stretched it out to cover some time. I added this FX to the track.

If this is the only track on the project I get a fuzzy blob using the default settings for the FX. Playing with the dials still shows no text. Just fuzzy blobs.

Putting a video on a second track shows no video unless I put it in front, and then I see no text.

If I put the FX directly on a video then I see the text, but the text is surrounded by a green rectangle. You cannot see the video through the text.

Can someone strip away the ambiguity and say what is the simplest possible project that can display a video with this text over it. One video, no other FX?
Sorry for the confusion Fuzzball. Along the discussions I suggested the 10x10 png patch for a early version of the preset and multiple tracks are not a necessity. To my knowledge all of the suggested patches are note required anymore.

So in short:
The preset is meant to be added at the item level (shift-e in windoze). The item media may be either a video, an image or even an empty midi item. The v2.23 will work in all those cases.

examples:
1) one track, empty midi item + preset = text on black background
2) one track image/video item + preset = text that appears on top of the image/video
3) 2 tracks, lower video priority track item: video item,
higher video priority track item: empty midi item + preset
= text on top of lower video priority item

with more tracks, the preset should be placed on the item with the most video priority.

Edit: It does works by itself at the track level even without any item at all!

Last edited by papagirafe; 02-16-2022 at 05:51 PM.
papagirafe is offline   Reply With Quote
Old 02-16-2022, 07:06 PM   #21
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

I just want a video to display with this text showing over the video, without the green rectangle that hides the video. AFAIK this can't do it alone.
fuzzball is offline   Reply With Quote
Old 02-16-2022, 07:53 PM   #22
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

papagirafe made the preset to overlay text with optional moving and kind of blurred shadow,

maybe a stripped down version is enough for your needs

i found this somewhere in the forum and hacked it a little bit to fit my needs
i tested it with a video (no green box here) but only hardcoded dark shadow color
Code:
// text overlay bobobo v2
// bobobo - standing on giants' shoulders
input_get_name(-1, text);
font="FUTURA";

//@param1:size 'text size' 0.05 0.01 1 0.1 0.001
//@param2:ypos 'y position' 0.5 -0.2 1.2 0.5 0.01
//@param3:xpos 'x position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text R' 255 0 255 128 1
//@param6:fgg 'text G' 255 0 255 128 1
//@param7:fgb 'text B' 255 0 255 128 1
//@param8:fga 'text A' 1 0 1 0.5 0.005

//@param10:shr 'shadow R' 255 0 255 128 1
//@param shg 'shadow G' 255 0 255 128 1
//@param shb 'shadow B' 255 0 255 128 1
//@param sha 'shadow alpha' 0.3 0 1 0.5 0.001
//@param shx 'shadow x' 0.5 -1 1 0.5 0.01
//@param shy 'shadow y' 0.5 -1 1 0.5 0.01
//@param shs 'shadow spread' 5 0 10 5 0.05
//@param shi 'shadow iterations' 5 1 20 5 1


gfx_blit(0,1);
gfx_setfont(size*project_h,font);
gfx_str_measure(text,txtw,txth);
yt = (project_h - txth)*ypos;

x = xpos * (project_w-txtw);
i = 0;

gfx_set(shr/255,shg/255,shb/255,sha);
loop(shi,

  gfx_str_draw(text,x + (100 * shx*size) + (i * shs * size),yt + (100 * shy * size) + (i * shs * size));
  gfx_str_draw(text,x + (100 * shy*size) - (i * shs * size),yt + (100 * shy * size) - (i * shs * size));
  gfx_str_draw(text,x + (100 * shx*size) + (i * shs * size),yt + (100 * shy * size) - (i * shs * size));
  gfx_str_draw(text,x + (100 * shx*size) - (i * shs * size),yt + (100 * shy * size) + (i * shs * size));
  
  i += 1;
);

gfx_set(fgr/255,fgg/255,fgb/255,fga);
gfx_str_draw(text,x,yt);

Last edited by bobobo; 02-17-2022 at 03:46 AM.
bobobo is offline   Reply With Quote
Old 02-24-2022, 06:32 AM   #23
eviluess
Human being with feelings
 
eviluess's Avatar
 
Join Date: Dec 2015
Location: Guangzhou, China
Posts: 176
Default

Quote:
Originally Posted by papagirafe View Post
Hi folks,



Thanks to eviluess in this thread, I took the challenge to make a better outline effect for fonts. In the process I found an opportunity with the same method to add a better shadow effect with adjustable angle. This version of the text overlay has the following main features:

- Text w/adjustable color/transparency, if transparency set to -0.1 use item fade
- background color/size/ with transparency relative to text transparency
- adjustable outline/shadow color/thickness with same transparency as text
- adjustable shadow angle

Code:
// Overlay: Text v2.2 w/ajustable outline/shadow
// by papagirafe
// Write your own text inside quotes, multiple lines allowed
// if empty, text = item/track name
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.1 1 0.5 0.1

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 64 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  img=gfx_img_alloc();           // first, image handle only
  gfx_img_resize(img,-1,-1);     // incantation to summon alpha plane
  gfx_img_resize(img,w,h);       // real size now
  gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
  gfx_fillrect(0,0,w,h);         
  img;
);

function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

fga<0?fga=param_wet; bga*=fga; mode=0x10000;
input = 0;
project_wh_valid===0 ? input_info(input,project_w,project_h);
gfx_blit(input,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h-txth*(1+bgh*2))*ypos;

bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

olt>0?(
 shangl=shmode?shangl*oldiv/360:0; 
 gfx_set(olr,olg,olb,1,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

gfx_dest=-1; gfx_a=fga;
gfx_blit(img,1,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt); 

gfx_img_free(img);
Thanks for everything you did for me~
eviluess is offline   Reply With Quote
Old 02-24-2022, 03:54 PM   #24
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by eviluess View Post
Thanks for everything you did for me~
I enjoyed your challenge! The builtin outline and shadow were bugging me for a long time too (we were not alone!). Your questions and the explanations of your attempts were very clear and pertinent and they lead me to a solution more flexible than I expected.
papagirafe is offline   Reply With Quote
Old 02-27-2022, 05:44 PM   #25
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by fuzzball View Post
I just want a video to display with this text showing over the video, without the green rectangle that hides the video. AFAIK this can't do it alone.
Fuzzball, I was able to reproduce the exact annoying "green" condition while testing an other preset. This happens if one or more underlying video layer is not using alpha mode. The trick is to use a preset that enables that mode before the text/shadow preset. For example: Track opacity/zoom/pan with parameter "clear background" set to 0.

Last edited by papagirafe; 02-27-2022 at 05:56 PM.
papagirafe is offline   Reply With Quote
Old 03-02-2022, 12:56 PM   #26
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

Still haven't been able to get it working without a big green rectangle blocking the view of video behind letters.

Let me remove all ambiguity....

1) new project, drop one MP4 video onto Track1. The one and only track on the project.

2) To the track FX add Track opacity/zoom/pan and change Clear BG to 0.

3) To the track FX add Overlay: Text v2.23.

4) Confirm that Track opacity FX is the first FX and Overlay: Text v2.23 is the 2nd FX.

Result: Big green rectangle blocking video.

Have also tried it with item FX with no change.
fuzzball is offline   Reply With Quote
Old 03-03-2022, 03:08 PM   #27
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by fuzzball View Post
Still haven't been able to get it working without a big green rectangle blocking the view of video behind letters.

Let me remove all ambiguity....
1) new project, drop one MP4 video onto Track1. The one and only track on the project.
2) To the track FX add Track opacity/zoom/pan and change Clear BG to 0.
3) To the track FX add Overlay: Text v2.23.
4) Confirm that Track opacity FX is the first FX and Overlay: Text v2.23 is the 2nd FX.
Result: Big green rectangle blocking video.
Have also tried it with item FX with no change.
Thanks for your patience! I carefully built your project and indeed I got the exact same problem! I discovered that all my previous tests where using a source media with 'RGBA' color space. The fix is to add "colorspace='RGBA';" at the start of main code. Here is the fixed version 2.23a (update: v2.23b restores original colorspace). Let me know if the fix creates other side-effects.

Code:
// Overlay: Text v2.23b w/ajustable outline/shadow
// by papagirafe
// v2.23a: fixed colorspace dependency
// v2.23b: restoring original colorsapce on exit

// Write your own text inside quotes, multiple lines allowed
#text=""; 
// default font = "Arial" in Windows
font="";   
/*
  font styles from following list - multiple choices allowed - uppercase mandatory 
  'B' - Bold,   'I' - Italics,  'R' - smooth edges,
  'V' - Invert bg/fg, 'U' - underlined 
  shadow and outline are handled with dedicated parameters
*/
style='R';   

//@param size 'text height' 0.05 0.01 1.0 0.5 0.001
//@param xpos 'x position' 0.5 0 1 0.5 0.01
//@param ypos 'y position' 0.5 0 1 0.5 0.01

//@param5:fgr 'text r' 1.0 0 1 0.5 0.01
//@param fgg 'text g' 1 0 1 0.5 0.01
//@param fgb 'text b' 1 0 1 0.5 0.01
//@param fga 'text a' 1 -0.01 1 0.5 0.01

//@param10:bgh 'bg h' 0 0 1 0.5 0.01
//@param bgw 'bg w' 0 0 600 0.5 1
//@param bgr 'bg r' 0 0 1 0.5 0.01
//@param bgg 'bg g' 0 0 1 0.5 0.01
//@param bgb 'bg b' 0 0 1 0.5 0.01
//@param bga 'bg a' 0.5 0 1 0.5 0.01

//@param17:olr 'outline r' 0 0 1 0.5 0.01
//@param olg 'outline g' 0 0 1 0.5 0.01
//@param olb 'outline b' 0 0 1 0.5 0.01
//@param ola 'outline a' 0.1 0.01 1 0.5 0.01
//@param olt 'outline thickness' 0 0 100 50 1
//@param oldiv 'outline divs' 32 8 128 64 4
//@param shmode 'shadow mode' 0 0 1 0.5 1
//@param shangl 'shadow angle' 45 0 359 180 1

function gfx_img_alloc_transparent(w,h) 
(
  input_info(0,iw,ih); 
  iw>0&&ih>0?(  //media file exists?
    img=gfx_img_alloc();           // first, image handle only
    gfx_img_resize(img,-1,-1);     // summon alpha plane
    gfx_img_resize(img,w+1,h+1);       // real size now (w+1/h+1 = gfx_blit() bug patch)
    gfx_set(0,0,0,0,0x10000,img);  // 100% transparent "black"
    gfx_fillrect(0,0,w,h);         
  ):(
    img=gfx_img_alloc(w+1,h+1,1);      // std cleared image (w+1/h+1 = gfx_blit() bug patch)
  );
  img;
);

function set_project_wh_safe(w*,h*)
(
  project_wh_valid===0 ? ( 
    input_info(0,w,h);  // no pw,ph get from current item
    w==0||h==0?(w=480; h=270;); // worst case scenario? 1/4 HD
  );
);

function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);

ocs=colorspace;
colorspace='RGBA';
fga<0?fga=param_wet; 
bga*=fga; //bg alpha dependent upon fg alpha
mode=0x10000; //use alpha
set_project_wh_safe(project_w, project_h);

gfx_blit(0,1);
gfx_setfont(size*project_h,font,style);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt =(project_h-txth*(1+bgh*2))*ypos;

// background if applicable
bga>0?(
  gfx_set(bgr,bgg,bgb,bga);
  gfx_fillrect(xpos*(project_w-txtw)-bgw-olt, yt-olt, txtw+bgw*2+2*olt, txth*(1+bgh*2)+2*olt);
);

//temporary image using alpha 1 for consistent drawing
img=gfx_img_alloc_transparent(txtw+2*olt,txth+2*olt);

// pourtour du texte si applicable
olt>0?(
  shmode?(ola=exp(ola*fga*3.5-4);shangl=shangl*oldiv/360):(ola=exp((oldiv/16)*ola*fga-4.61);shangl=0;); 
  gfx_set(olr,olg,olb,ola*fga,mode,img);
  i=0; loop(shmode?oldiv/16:oldiv, 
    phi=2*(i+shangl)*$pi/oldiv;
    polar2xy(olt,phi,ox,oy);
    gfx_str_draw(#text,ox+olt,oy+olt,olr,olg,olb);
    i+=1;
  );
);
// text
gfx_set(fgr,fgg,fgb,1,mode,img);
gfx_str_draw(#text,olt,olt,olr,olg,olb);

// copy tmp img to frame buffer with desired alpha value
gfx_dest=-1; gfx_a=fga;
gfx_blit(img,0,xpos*(project_w-txtw)-olt,yt+txth*bgh-olt,txtw+2*olt,txth+2*olt,0,0,txtw+2*olt,txth+2*olt); 
gfx_img_free(img);
colorspace=ocs;

Last edited by papagirafe; 03-03-2022 at 05:48 PM. Reason: code update
papagirafe is offline   Reply With Quote
Old 03-03-2022, 04:15 PM   #28
fuzzball
Human being with feelings
 
fuzzball's Avatar
 
Join Date: Dec 2020
Posts: 214
Default

Quote:
Originally Posted by papagirafe View Post
Thanks for your patience! I carefully built your project and indeed I got the exact same problem! I discovered that all my previous tests where using a source media with 'RGBA' color space. The fix is to add "colorspace='RGBA';" at the start of main code. Here is the fixed version 2.23a. Let me know if the fix creates other side-effects.
That was it! Looks nice. I appreciate you going the extra mile for me!
fuzzball is offline   Reply With Quote
Old 03-03-2022, 05:04 PM   #29
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

There is a Project Setting to force it to use a specific colorspace, but. Of course, if your code depends on it being set to something specific, then it is best to set it in the code. I think that’s why inserting Track Opacity seemed to help in some cases - it was forcing that colorspace so you didn’t have to. It’s also a good idea, though, to set the colorspace back to where it was when your preset is done. So like save the colorspace to some variable before setting it to RGBA, and then at the end set colorspace back to equal that variable.
ashcat_lt is offline   Reply With Quote
Old 03-03-2022, 05:51 PM   #30
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by ashcat_lt View Post
There is a Project Setting to force it to use a specific colorspace, but. Of course, if your code depends on it being set to something specific, then it is best to set it in the code. I think that’s why inserting Track Opacity seemed to help in some cases - it was forcing that colorspace so you didn’t have to. It’s also a good idea, though, to set the colorspace back to where it was when your preset is done. So like save the colorspace to some variable before setting it to RGBA, and then at the end set colorspace back to equal that variable.
I am not sure that saving the original colorspace is really necessary but I updated the code to do so (v2.23b) in case it creates ripple effects.
papagirafe is offline   Reply With Quote
Old 03-03-2022, 05:58 PM   #31
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by fuzzball View Post
That was it! Looks nice. I appreciate you going the extra mile for me!
Super! Well I just happened to be meddling today with colorspace issues involving transparency in other presets...
papagirafe is offline   Reply With Quote
Old 03-03-2022, 06:02 PM   #32
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

Quote:
Originally Posted by papagirafe View Post
I am not sure that saving the original colorspace is really necessary…
Yeah I’m not sure how much that matters most of the time, but I feel like it’s the polite thing to do.
ashcat_lt is offline   Reply With Quote
Old 03-08-2022, 04:03 AM   #33
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by ashcat_lt View Post
Yeah I’m not sure how much that matters most of the time, but I feel like it’s the polite thing to do.
I wrote a preset to test whether this is necessary or not: the answer is no! :-)
Each instance of "video processor/preset" in the fx chain gets the original value no matter what the previous preset did (BTW this is the same for project_w/project_h). Just put 2 or more instances of this code to try:
Code:
//colorspace test
//@param ccs "current cs" -1 -1 3 2 1
//@param fcs "force next cs" 0 0 3 2 1
function update_param(p*,val)( on_parameter_change(p); p=val; on_parameter_change(p,1););
cs[0]=0;cs[1]='RGBA';cs[2]='YV12';cs[3]='YUY2';
i=0;while(i<4)(
  colorspace==a[i]?(ccs=i;i=4):(i+=1);
); 
update_param(ccs,ccs);
colorspace=cs[fcs];
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 01:45 AM.


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