10-06-2021, 06:14 PM | #1 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 690
|
FX: Random deformation grid
I came up with this idea of a cool deformation FX preset while coding another custom preset. Enjoy!
Code:
//FX: random deformations grid //by Papagirafe //@param1:divs 'divisions' 20 10 160 80 1 //@param2:ampl 'amplitude' 10 0 80 40 0.1 //@param3:freq 'frequency %' 20 0 100 50 0.1 //@param4:smooth 'smoothing' 1 0 1 0.5 1 function init_transform_table(t*,w,h) ( incrx=w/divs; incry=h/divs; tx=t;ty=tx+1;i=0;x=0; y=0; loop(divs, loop(divs, rx=(rand(2)-1)*ampl*w; ry=(rand(2)-1)*ampl*h; tx[i]=x+rx+1; ty[i]=y+ry+1; i+=2; x+=incrx; ); y+=incry; x=0; ); ); project_wh_valid===0 ? input_info(0,project_w,project_h); ampl/=1000; freq=freq/100*framerate; update==0?init_transform_table(t,project_w, project_h); freq?update=(update+1)%(framerate/freq):update=-1; gfx_set(0,0,0,1,smooth?0x100:0); gfx_fillrect(0,0,project_w,project_h); gfx_xformblit(0, 0,0,project_w,project_h, divs,divs, t, 0); Last edited by papagirafe; 10-07-2021 at 06:04 AM. Reason: minor code update |
10-13-2021, 06:50 AM | #2 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 690
|
There is a scaling bug (which I don't fully understand yet) with the preset I published, so here is an corrected version with some code cleanup.
Code:
//FX: random deformations grid //@param1:divs 'divisions' 40 10 160 80 1 //@param2:ampl 'amplitude' 10 0 80 40 0.1 //@param3:freq 'frequency %' 20 0 100 50 0.01 //@param4:smooth 'smoothing' 1 0 1 0.5 1 function init_transform_table(t*,w,h) ( incrx=w/divs*1.04; incry=h/divs*1.04; i=0;x=0; y=0; loop(divs, loop(divs, t[i]=x+(rand(2)-1)*ampl*w; t[i+1]=y+(rand(2)-1)*ampl*h; i+=2; x+=incrx; ); y+=incry; x=0; ); ); project_wh_valid===0 ? input_info(0,project_w,project_h); ampl/=1000; freq=freq/100*framerate; update==0?init_transform_table(t,project_w, project_h); freq?update=(update+1)%(framerate/freq):update=-1; gfx_set(0,0,0,1,smooth?0x100:0); gfx_fillrect(0,0,project_w,project_h); gfx_xformblit(0, 0,0,project_w,project_h, divs,divs, t, 0); Last edited by papagirafe; 10-13-2021 at 06:53 AM. Reason: typos |
03-03-2023, 07:59 AM | #3 |
Human being with feelings
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 979
|
Thank you so much for this effect! It looks wonderful and it doesn't tax the cpu as much as I expected.
Just as a side note, I always found that these video fx should come nicely commented so that others can learn from it.
__________________
http://estudi.canreco.com ProTools theme: http://forum.cockos.com/showthread.php?t=9422 Lighter theme: http://forum.cockos.com/showthread.p...653#post109653 |
03-03-2023, 10:03 AM | #4 | |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 690
|
Quote:
gfx_xformblit() always performs its magic very efficiently. You need to populate a transformation table by dividing your bitmap space into a mesh of x/y coordinates inside of it. Any deviation from the expected coordinate will induce a deformation. This is discussed in this thread: https://forum.cockos.com/showthread.php?t=257394 Also I made another preset that distords the 4 corner coordinates to fix/alter the geometry of a video source: https://forum.cockos.com/showthread.php?t=261577 |
|
Thread Tools | |
Display Modes | |
|
|