[sharing] New Distortions

Mar 30, 2009 at 6:49pm

[sharing] New Distortions

Hello Folks,
I would like to share with you a couple of little things I’ve been keeping under my hat until I had time to make them presentable and readable for others. Originally, I had intended to write up a recipe or article about this stuff, but due to my current to-do list I wouldn’t get around to it for several months. So I’m just going to put it out there.

Attached is a collection of shaders and Max patches that implement an optical-flow driven distortion. This allows you to do things like fake compression-artifact effects as well as some really swirly feedback stuff. It’s all based around an aproximate implementation of Horn-Shuncke optical flow within a shader (good enough for experimental video) and a special “repos” shader that is optimized for the ab.hsflow output. The idea for these arose from research I was doing for a current video project, and was encouraged by the recent explosion of interest in these sorts of video effects. Please take a moment to play around with these, and be sure to post your own creations and alterations for everyone else.
Let me know what you think…

Andrew Benson

#43108
Mar 31, 2009 at 1:05am

Your the best andrew! Good work on these!

I just played around and its crazy, its exactly the same as the first cv.hsflow patch that I made! The only difference being that they are slabs instead of jit objects, and thus they run 640 at 60fps rather then 320 at 30fps.

Last night I ended up staying up and working on a different approach, I used the cv flow object at a low resolution to distort a mesh with a feedback texture on it, its working out great so far, it can go super high resolution and its very smooth and responsive, and runs at very high frame rate even full screen HD! The most fun aspect of it is that Ive gotten the distortion to be very accurate to the amount of motion, when your using it you really feel like your pushing the goo around with your movements.

Heres the first test video:
http://vimeo.com/3925277

I hope to add bubbles/metaballs and other fluid characteristics and get a nice abstract fluid simulation going.

Thanks again andrew!

#154501
Mar 31, 2009 at 7:03pm

All I can say is… <3 !!!

#154502
Mar 31, 2009 at 10:37pm

In making a tutorial on how to use this in DNA (http://www.lividindustry.com/culture/?p=198), I had to convert the max5 patch to a max 4 patch. Might as well post it!
Of course, you’ll still need Andrew’s zip for the shaders.

#P window setfont Arial 9.;
#P window linecount 1;
#P newex 386 174 252 131137545 jit.gl.slab fa @type float32 @file ab.rgbluma.jxs;
#P comment 748 508 140 131137545 andrewb@cycling74.com;
#P comment 694 485 193 131137545 Higher quality texture displacement;
#P comment 530 484 130 131137545 GLSL H-S optical flow;
#P window setfont “Lucida Grande” 9.;
#P comment 516 453 371 67108873 ab.hsflow.jxs + ab.flowrepos.jxs;
#P window setfont Arial 9.;
#P comment 504 120 124 131137545 gradient sample offset;
#P comment 639 138 79 131137545 result scaling;
#P comment 835 230 103 131137545 motion-smoothing;
#P comment 339 279 99 131137545 color scaling;
#P comment 406 350 99 131137545 distortion amount;
#N vpreset 2;
#X append 1 2 39 247 899 flonum float 3.3 ; 2 61 83 flonum float 3.3 ; 12 204 661 flonum float 0. ; 17 158 655 flonum float 2. ; 27 140 565 flonum float 2.001 ; 26 140 514 flonum float;
#X append 1 2 2. ; 41 392 415 flonum float 13. ; 45 297 412 flonum float 1. ; 20 392 364 flonum float 13. ; 47 297 360 flonum float 1. ; 46 297 311 flonum float 1. ; 12 204 661;
#X append 1 2 flonum float 0.3 ; 24 373 153 flonum float 0.2 ; 29 373 66 flonum float 0.048 ;;
#X append 2 2 39 247 899 flonum float 12. ; 2 61 83 flonum float 12. ; 12 204 661 flonum float 0.17 ; 17 158 655 flonum float 12. ; 27 140 565 flonum float 3. ; 26 140 514 flonum float;
#X append 2 2 3. ; 41 392 415 flonum float 26. ; 45 297 412 flonum float 0.925 ; 20 392 364 flonum float 26. ; 47 297 360 flonum float 1.001 ; 46 297 311 flonum float 1. ; 12 204 661;
#X append 2 2 flonum float 0.3 ; 24 373 153 flonum float 0.13 ; 29 373 66 flonum float 0.213 ;;
#P preset 603 8 100 40;
#P newex 629 63 58 131137545 loadbang;
#N vpatcher 25 69 386 411;
#P window setfont Arial 12.;
#P window linecount 3;
#P comment 85 246 150 131137548 seems like breaking it up into 2 passes works better. Not sure why…;
#P window linecount 1;
#P newex 140 140 78 131137548 pak amt 0. 0.;
#P newex 140 163 89 131137548 prepend param;
#P newex 50 220 185 131137548 jit.gl.slab fa @file ab.flowrepos.jxs;
#P newex 50 163 89 131137548 prepend param;
#P newex 65 100 78 131137548 pak amt 0. 0.;
#P newex 50 192 185 131137548 jit.gl.slab fa @file ab.flowrepos.jxs;
#P inlet 4 73 25 0;
#P inlet 228 40 25 0;
#P inlet 146 40 25 0;
#P inlet 199 40 25 0;
#P inlet 277 130 25 0;
#P outlet 50 300 25 0;
#P connect 7 0 8 0;
#P connect 5 0 6 0;
#P connect 8 0 6 0;
#P connect 4 0 9 0;
#P connect 10 0 9 0;
#P connect 6 0 9 0;
#P connect 9 0 0 0;
#P connect 3 0 7 1;
#P connect 11 0 10 0;
#P connect 2 0 11 2;
#P connect 1 0 6 1;
#P connect 1 0 9 1;
#P pop;
#P newobj 326 417 193 131137545 p distortions;
#P flonum 534 98 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 360 297 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 311 297 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 412 297 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 629 87 135 131137545 sendoutput filter nearest;
#P flonum 415 368 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 367 139 143 131137545 jit.gl.slab fa @type float32;
#P flonum 415 392 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 869 200 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 899 247 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 899 273 85 131137545 slide_down $1;
#P newex 823 296 89 131137545 prepend param;
#P flonum 823 247 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 823 273 70 131137545 slide_up $1;
#P newex 736 355 69 131137545 jit.gl.slab fa;
#P newex 500 380 255 131137545 jit.gl.slab fa @file tp.slide.jxs @dimscale 10. 10.;
#P flonum 361 255 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 315 327 111 131137545 pak scale 1. 1. 1. 1.;
#P newex 315 349 89 131137545 prepend param;
#P flonum 66 373 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 66 396 85 131137545 param fade $1;
#P flonum 565 140 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 514 140 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 480 204 86 131137545 pak offset 0. 0.;
#P flonum 153 373 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 230 373 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 230 396 88 131137545 param luma $1;
#P message 153 396 75 131137545 param tol $1;
#P flonum 364 392 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 29 439 352 131137545 jit.gl.slab fa @file co.lumakey.jxs @param binary 1 @param tol 0.5;
#P user jit.fpsgui 39 191 80 131137545 0;
#P flonum 655 158 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 570 204 85 131137545 pak scale 0. 0.;
#P newex 500 284 267 131137545 jit.gl.slab fa @file ab.hsflow.jxs @dimscale 0.1 0.1;
#P newex 748 258 69 131137545 jit.gl.slab fa;
#P newex 468 229 51 131137545 t l l;
#P flonum 661 204 50 9 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 40 170 154 131137545 jit.window fa @size 640 480;
#P newex 29 464 209 131137545 jit.gl.videoplane fa @transform_reset 2;
#P newex 514 260 89 131137545 prepend param;
#P message 661 227 65 131137545 lambda $1;
#P message 485 54 38 131137545 close;
#P message 449 53 36 131137545 open;
#P newex 367 83 163 131137545 jit.qt.grab 640 480 @unique 1;
#P newex 40 146 81 131137545 jit.gl.render fa;
#P newex 40 108 65 131137545 t b b erase;
#P flonum 83 61 39 9 0.5 0 1 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 39 86 63 131137545 qmetro 33;
#P toggle 40 62 20 0;
#P connect 39 0 38 0;
#P connect 40 0 36 0;
#P connect 40 0 39 0;
#P connect 51 0 29 0;
#P lcolor 13;
#P connect 51 0 24 0;
#P lcolor 13;
#P connect 51 0 23 0;
#P lcolor 13;
#P connect 51 0 46 0;
#P lcolor 13;
#P connect 51 0 47 0;
#P lcolor 13;
#P connect 51 0 20 0;
#P lcolor 13;
#P connect 51 0 45 0;
#P lcolor 13;
#P connect 51 0 41 0;
#P lcolor 13;
#P connect 51 0 26 0;
#P lcolor 13;
#P connect 51 0 27 0;
#P lcolor 13;
#P connect 51 0 17 0;
#P lcolor 13;
#P connect 51 0 12 0;
#P lcolor 13;
#P connect 51 0 36 0;
#P lcolor 13;
#P connect 51 0 39 0;
#P lcolor 13;
#P connect 35 0 37 0;
#P connect 38 0 37 0;
#P connect 36 0 35 0;
#P connect 14 0 15 1;
#P fasten 13 0 14 0 478 254 758 254;
#P connect 34 0 33 1;
#P connect 33 0 49 4;
#P connect 33 0 34 0;
#P connect 12 0 8 0;
#P connect 17 0 16 1;
#P connect 17 0 16 2;
#P connect 50 0 44 0;
#P connect 48 0 26 0;
#P connect 48 0 27 0;
#P connect 27 0 25 2;
#P connect 26 0 25 1;
#P connect 8 0 9 0;
#P connect 16 0 9 0;
#P connect 25 0 9 0;
#P connect 15 0 33 0;
#P connect 37 0 33 0;
#P connect 9 0 15 0;
#P connect 13 1 15 0;
#P connect 44 0 15 0;
#P fasten 61 0 13 0 396 214 478 214;
#P connect 30 0 49 3;
#P connect 41 0 49 2;
#P fasten 43 0 20 0 425 390 374 390;
#P connect 43 0 41 0;
#P connect 32 0 46 0;
#P connect 32 0 47 0;
#P connect 32 0 45 0;
#P connect 45 0 31 3;
#P fasten 42 0 19 0 377 242 39 242;
#P fasten 42 0 61 0 377 167 396 167;
#P connect 49 0 19 1;
#P connect 20 0 49 1;
#P connect 5 0 42 0;
#P fasten 6 0 5 0 459 79 377 79;
#P fasten 7 0 5 0 495 76 377 76;
#P fasten 3 1 5 0 73 131 377 131;
#P connect 47 0 31 2;
#P connect 46 0 31 1;
#P connect 19 0 10 0;
#P connect 19 0 49 0;
#P connect 31 0 30 0;
#P connect 23 0 22 0;
#P connect 24 0 21 0;
#P connect 2 0 1 1;
#P connect 29 0 28 0;
#P fasten 3 2 4 0 96 136 50 136;
#P connect 3 0 4 0;
#P connect 1 0 3 0;
#P connect 4 0 18 0;
#P connect 0 0 1 0;
#P connect 28 0 19 0;
#P connect 21 0 19 0;
#P connect 22 0 19 0;
#P window clipboard copycount 62;

#154503
Apr 1, 2009 at 1:43pm

please post max 4.6 version….

thanks!

#154504
Apr 1, 2009 at 4:32pm

isnt that it right above the message you just posted?

#154505
Apr 1, 2009 at 7:12pm

Any trick to getting this going? Should both of the presets in the patch give glitching straight from the start?

What I’m seeing is something like a posterize, as well as a bit of lower res (ie, squares) following motion. I’ve tried a ton of different settings, and even tried the same settings shown in the DNA how-to video and nothing gave me the imagery like I’m seeing in people’s videos. That said, what I’m seeing looks pretty nice, if quite a bit more normal.

#154506
Apr 1, 2009 at 9:09pm

upps… yes sorry.. to fast

would be nice to have a simple standalone max5 to 4.6 converter (drag&drop)

#154507
Apr 2, 2009 at 10:30pm

Andrew, would it be possible to create a motion blur by using your hsflow and a blur based on motion ammount + direction?

#154508
Apr 3, 2009 at 3:27am
Axiom-Crux wrote on Thu, 02 April 2009 16:30
Andrew, would it be possible to create a motion blur by using your hsflow and a blur based on motion ammount + direction?

Thats a great idea. Ill see what I can whip up Smile

edit:

rough draft of a blur: I played with this last night and while it works, its very picky. You need to do multi-pass to get it to show up, maybe 3 + passes. Keep feeding the same flow output to tex1, but chain tex0 from the output of one of these blurs to the next. It could use some work, it gets trippy fast, and is not *quite* what you would expect.

//setup for 2 texture
varying vec2 texcoord0;
varying vec2 texcoord1;

uniform float amt;
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;

void main()
{
vec4 blurVector = texture2DRect(tex1,texcoord1); //sample flow texture

vec2 blurAmount = vec2(blurVector.y-blurVector.x, blurVector.w-blurVector.z);

/* vec4 blur1 = texture2DRect(tex1, texcoord1 + blurAmount);
vec2 blurAmount1 = vec2(blur1.y-blur1.x, blur1.w-blur1.z);

vec4 blur2 = texture2DRect(tex1, texcoord1 + blurAmount * 2.0);
vec2 blurAmount2 = vec2(blur2.y-blur2.x, blur2.w-blur2.z);
*/
vec2 amount1 = blurAmount;// + blurAmount1 + blurAmount2;
amount1 *= amt;

vec2 amount2,amount3,amount4,amount5,amount6,amount7,amount8;

amount2 = amount1 *1.5;
amount3 = amount1 *3.0;
amount4 = amount1 *6.0;

amount5 = amount1 * 8.0;
amount6 = amount1 * 10.0;
amount7 = amount1 * 12.0;
amount8 = amount1 * 18.0;

// sample our textures
vec4 sample0 = texture2DRect(tex0, texcoord0);
vec4 sample1 = texture2DRect(tex0, texcoord0 + amount1);
vec4 sample2 = texture2DRect(tex0, texcoord0 + amount2);
vec4 sample3 = texture2DRect(tex0, texcoord0 + amount3);
vec4 sample4 = texture2DRect(tex0, texcoord0 + amount4);
vec4 sample5 = texture2DRect(tex0, texcoord0 + amount5);
vec4 sample6 = texture2DRect(tex0, texcoord0 + amount6);
vec4 sample7 = texture2DRect(tex0, texcoord0 + amount7);
vec4 sample8 = texture2DRect(tex0, texcoord0 + amount8);

gl_FragColor = (sample0 + sample1 + sample2 + sample3 + sample4 + sample5 + sample6 + sample7 + sample8) / 9.0;
}

#154509
Apr 3, 2009 at 5:34pm

Thanks to pnyboer for converting a. benson’s patch to 4.6. However when I turn it on I get the following errors with every bang: jit.gl.pbuffer: error binding texture: GL Error: Invalid operation and then error: jit.gl.texture: unable to create texture!

When I run a. benson’s patch in Max 5 runtime there are no errors and the patch seems to work just fine so it seems that my gpu should be able to handle this. Any idea what could be causing this? Any idea how I might be able to fix it?

I’m using a MacBookPro running 10.5.5 with 2.16 Intel Core Duo, 2 Gb ram, the gpu is RadeonX1600 with 256mb of vram.

Thanks,
S.

#154510
Apr 3, 2009 at 5:50pm

try switching the readback mechanism. paste this snippet into the patch:

#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P message 16 41 107 196617 ; jitter glreadback rtt;
#P message 16 74 107 196617 ; jitter glreadback fbo;
#P window clipboard copycount 2;

let us know if that works.

#154511
Apr 3, 2009 at 6:54pm

Thanks for sending that code. I pasted it into the patch and it seemed to take care of the problem. The strange thing is, just out of curiosity I tried the patch again without your code and didn’t get the gl errors this time. crazy! Wish I understood how all this worked better. Can you explain more about what the code that code is and/or maybe where I can find out more information about it someplace else? Thanks again.
S.

#154512
Apr 4, 2009 at 6:25pm

nice one vade, im about to test it out! Is there anything special I need other then the hsflow and your blur? Also, will this work in jitter without the jxs wrapper? (for some reason they dont show up for me in here, just the shader code, I think the forum eats javascript)

Andrew had recently posted a luma based blur in a post that I am working on a depth of field blur, and if you check out that one, it may be helpful to try and make something between what you have made and what he did in the luma based blur+ flow>repos shaders.

Im glad to see your back, even if it is just to scoop up some shaders to take over into QC

#154513
Apr 4, 2009 at 6:43pm

here is an early version by nesa.
i lost my ilok dongle (bahh) so i cant see the difference.

#154514
Apr 4, 2009 at 8:08pm

rob the rich:
does it have to be capitol FBO? I tried fbo and it seems to turn off the feedback, and when I do capitol FBO it works again… is there any info in the documentation about this setting?

#154515
Apr 4, 2009 at 9:59pm

actually, i believe the “fbo” is correct, but “RTT” should be “rtt”. however i think the default mode is “rtt” so when you give a bad argument (like FBO or RTT) it defaults to rtt.
my apologies for the misinformation.

these are undocumented messages for now.

#154516
Apr 5, 2009 at 1:16am

http://vimeo.com/4006177
http://vimeo.com/4004775
a couple more tests of my mesh distortion fluid feedback patch, doesn’t use the shaders that andrew made, just the cv.jit.hsflow
i put a small camera feed in the top right to show what im doing.

#154517
Apr 5, 2009 at 11:02am

damn vade, this motion blur is fckn trippy as hell! IM getting really wild results, its like the repos that andrew made but with crazy smeary spikes. Ill post a patch and jitterified shader in a bit.

#154518
Apr 5, 2009 at 12:03pm
Axiom-Crux wrote on Sat, 04 April 2009 19:16
http://vimeo.com/4006177
http://vimeo.com/4004775
a couple more tests of my mesh distortion fluid feedback patch, doesn’t use the shaders that andrew made, just the cv.jit.hsflow
i put a small camera feed in the top right to show what im doing.

Beautiful clip.
Very much interested into seeing this patch…

would be very kind Smile

#154519
Apr 6, 2009 at 2:14am

Axiom, glad you are enjoying it Smile

Its much more ‘smeary’ than ‘blurry’, I was trying to write a good motion blur shader based off of the code I wrote for QC, but I was not expecting this.

Another fun trick I found:

Readback the HSFlow output and Average it out. This gives you the average motion vector for the whole scene/frame. Apply that as a blur vector for a full frame blur.

Now you can control with one video the motion blur of another. Its kind of a one trick piny but fun to be able to blur using your hand gesture…

#154520
Apr 6, 2009 at 11:31pm

actually thats what I have heen doing, I love it! ahahah, you guys rock so much!

#154521
Apr 12, 2009 at 2:20am

Sounds awesome, but I can’t seem to get it working.

The output screen (‘fa’) fills with green, then Max becomes unresponsive, and I have to shut it down.

I’m on Windows, so I replaced jit.qt.grab with jit.dx.grab.

I’ve used the same camera with Max 5 before…

#154522
Apr 13, 2009 at 3:51am

Andrew:
Ive been making some great things with your shaders, I noticed that if you mix feedback the final output from the repos you can get much more interesting fluidy effects, and combining your repos and vades motion blur in various ways is making some great watercolor type effects. Ill post some vimeo clips soon.

I made a motion blur for full openGL scenes using frame differencing slab and your lumablur, as well as the depth of field I showed in the other thread (which I improved greatly with a multipass of your lumablur). I should technically be able to implement them both together in any patch without significantly more gpu resources by just doing a lightness composite of depth map and motion blur map and just one chain of multipass lumablur. Once I get some of the other shaders Im working on perfected and hopefully figure out shadows we should all finally be able to make jitter opengl look like what ive been seeing in current videogame quality. Ill post some of the things im working on soon as they are refined.

I cant thank you enough for all of these!

Vade:
Im curious about the QC port, I tried to install it on my 10.4.11 computer and it didn’t seem to work and then tried it on my gf 10.5 computer and it didnt’ work either, Im sure they are in the right spot and on 10.5 it seems to load the patches with no errors but just outputs black? strange.. I like QC, Its like super easyified jitter, with some interesting final application + screensaver possibilities, but I just wish you could do more indepth stuff like with jitter, as in manipulating geometry etc..

#154523
Apr 13, 2009 at 6:33pm

This is a bit OT, but QC plugins require 10.5, and ive gotten no reports of issues like that. Email me at vade at vade dot info and we can work it out Smile

Sorry for OT post.

#154524
Apr 14, 2009 at 7:11am

Hello Andrew,
I have been patching your flow distortions in with some video I have been working on and they are awesome. But I keep having this problem that is starting to drive me a little insane, recently whenever I run video through your flow distortion patch, the hs flow I get this black “swirl” that just turns the entire image to black and then there is nothing I can do to get it back I have to restart my computer and now I have restarted and I ‘m still having the problem! I’m pretty new to max so I am going to attach my dinky and unfinished patch to this post, but I seem to remember having this problem once or twice when I first opened your patch and was just experimenting with my mac’s camera.
Any help would be really awesome and thanks of these patches.
thanks
jjr

#154525
Apr 14, 2009 at 8:08pm

again, toggling the readback mechanism seemed to fix problems like this for me. not really sure why.

#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P message 16 41 107 196617 ; jitter glreadback rtt;
#P message 16 74 107 196617 ; jitter glreadback fbo;
#P window clipboard copycount 2;

#154526
Apr 14, 2009 at 10:13pm

would you suggest a loadbang on one of these so it bangs when I open the patch, do you think that that would help it usually happens right away when I get the black screen.
I’ve pasted them in
thanks
jjr

#154527
Apr 15, 2009 at 1:11am

oh yeah, jimmy, I like your version of the patch, its so nitty gritty. I keep pushing mine to these very smooth painterly filters but its cool to see the opposite. works fine on my comp. Try these buttons,

– Pasted Max Patch, click to expand. –

be gentle with them, one of those modes might be the one making your thing mess up so try one at a time

#154528
Apr 16, 2009 at 12:48am

Hello all,
thanks for everyones help, one more question. Where can I attach a jit.pwindow in this patch so that i can see what the effects are doing while I am performing if the projection is behind me?
basically how do I attach a pwindow in addition to the jit.window producing the floating “fa” 640 =480 images.
thanks
!

jjr

#154529
Apr 17, 2009 at 12:30am

I’ve attempted to recreate Andrew Benson’s ab.hasflow.jxs-help.maxpat in 4.6.3. and with a movie player rather than camera input. I keep getting errors on my messages into the hsflow shader. The errors I get are message doesn’t understand scale, lambda and offset. The flowrepos part of the patch seems to be working. Can anybody tell me what I’ve done wrong. I’m also not sure if I completely understand what the ab.rgbluma.jxs shader is doing. If I hook it up directly to my videoplane I get a white jit.window. I’m also interested in knowing where I might find more information on the lambda message. As always, assistance is most sincerely appreciated.

Thanks,
S.

max v2;
#N vpatcher 312 139 1384 748;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 710 320 70 196617 jit.gl.slab foo;
#P newex 463 358 258 196617 jit.gl.slab foo @file ab.hsflow.jxs @dimscale 0.25 0.25;
#P message 482 330 76 196617 prepend param;
#P message 624 272 67 196617 offset $1 $1;
#P message 558 273 56 196617 lambda $1;
#P flonum 624 244 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 558 245 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 507 246 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 483 301 75 196617 pak scale 0. 0.;
#P newex 446 252 27 196617 t l l;
#P newex 446 216 149 196617 jit.gl.slab @file ab.rgbluma.jxs;
#P newex 214 452 187 196617 jit.gl.videoplane foo @scale 1.333 1. 1.;
#P message 123 374 88 196617 param amt $1 $1;
#P flonum 123 346 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 214 416 259 196617 jit.gl.slab foo @file ab.flowrepos.jxs @param amt 5. 5.;
#P flonum 247 251 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 247 275 88 196617 param amount $1;
#P newex 214 304 161 196617 jit.gl.slab foo @file co.normal.jxs;
#P newex 24 472 146 196617 jit.window foo @size 640 480;
#P user jit.fpsgui 43 170 60 196617 0;
#P number 66 43 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 21 43 15 0;
#P newex 21 69 55 196617 qmetro 33;
#P newex 21 119 55 196617 t b b erase;
#P newex 21 322 82 196617 jit.gl.render foo;
#P newex 214 181 253 196617 jit.gl.slab foo @file cc.uyvy2rgba.jxs @dimscale 2. 1.;
#P message 376 118 91 196617 read dvducks.mov;
#P message 277 118 28 196617 read;
#P message 342 118 27 196617 stop;
#P message 308 118 31 196617 start;
#P toggle 214 99 15 0;
#P newex 214 118 51 196617 metro 33;
#P newex 214 150 190 196617 jit.qt.movie @adapt 1 @colormode uyvy;
#P comment 230 99 149 196617 • read a movie and start metro.;
#P window linecount 2;
#P comment 577 454 119 196617 by andrew benson andrewb@cyling74.com;
#P connect 13 0 12 0;
#P connect 12 0 11 0;
#P connect 11 0 10 0;
#P fasten 11 2 10 0 70 152 26 152;
#P connect 11 1 15 0;
#P connect 14 0 12 1;
#P connect 21 0 22 0;
#P connect 4 0 3 0;
#P fasten 3 0 2 0 219 144 219 144;
#P fasten 7 0 2 0 282 141 219 141;
#P fasten 6 0 2 0 347 141 219 141;
#P fasten 5 0 2 0 313 141 219 141;
#P fasten 8 0 2 0 381 141 219 141;
#P connect 2 0 9 0;
#P connect 9 0 17 0;
#P connect 18 0 17 0;
#P connect 17 0 20 0;
#P fasten 22 0 20 0 128 404 219 404;
#P connect 20 0 23 0;
#P connect 19 0 18 0;
#P connect 20 0 17 1;
#P fasten 9 0 24 0 219 205 451 205;
#P connect 24 0 25 0;
#P connect 25 1 33 0;
#P connect 32 0 33 0;
#P connect 33 0 20 1;
#P connect 26 0 32 0;
#P fasten 31 0 32 0 629 324 487 324;
#P fasten 30 0 32 0 563 322 487 322;
#P connect 27 0 26 1;
#P connect 27 0 26 2;
#P connect 28 0 30 0;
#P connect 29 0 31 0;
#P fasten 25 0 34 0 451 292 715 292;
#P connect 34 0 33 1;
#P pop;

#154530
Apr 17, 2009 at 12:55am

why dont you copy paste the one the other dude made? its in the same post near the top

#154531
Apr 17, 2009 at 1:09am

He converted the other help patch. I’m trying to convert the simpler one and for some reason I can’t get it to work. Thanks anyhow . . .

#154532
Apr 17, 2009 at 2:02am

the simpler one is similar with the lumakey, and slide taken out, I can post a screenshot if it helps

#154533
Apr 17, 2009 at 2:04am

#154534
Apr 17, 2009 at 2:17am

thanks, for the screen shot. I just figured out I made a typo and forgot to label the rgbluma slab properly. Left out my FOO and that is what caused all the problems. Should have known. Just dumb user error. Should have spent a little more time troubleshooting before I hit the post button. If you know what the Lambda argument does I’d be grateful. I’m really trying to understand this deeper and not just enough to cut and paste. Thanks for your help.
S.

#154535
Apr 17, 2009 at 2:29am

hello max lordsss
I tried to patch a jit.pwindow into hsflow following instructions I got from one of ab’s tutorials call “preview, which had me patching a second jit.gl.render in to the patch adding a “@shared contex” but all I’m getting is a white screen. I’ll attach the patch if someone wouldn’t mind taking a look.
thanks
jjr

#154536
Apr 17, 2009 at 2:53am

lambda does a sort of noise removal, just limits the ammount of detail and little interactions that the hsflow calculates, which will give a more accurate and simplified motion gradient.

#154537
Apr 17, 2009 at 5:16am
BaltimoreMAX wrote on Thu, 16 April 2009 20:29
hello max lordsss
I tried to patch a jit.pwindow into hsflow following instructions I got from one of ab’s tutorials call “preview, which had me patching a second jit.gl.render in to the patch adding a “@shared contex” but all I’m getting is a white screen. I’ll attach the patch if someone wouldn’t mind taking a look.
thanks
jjr

your patch has a typo. you name your texture “mytex” but you set your videoplane’s texture attribute to “mytext”

#154538
Apr 19, 2009 at 3:21pm

Thank you, Andrew, for your great work, I love your hsflow shaders!
I used it in my new MaxMSP/Jitter patch in combination with the jit.atari object and it works very well to me!

I’ve uploaded some examples from my last live-performance at the Philharmonie in Essen (Germany) on vimeo:

http://vimeo.com/4223874
http://vimeo.com/4224296

I’m using the one-turntable setup extended with KP-mini, Kaossilator and my MaxMSP/Jitter Patch. The visuals are controlled by audio input from turntable and kaossilator.

Thank you very much!
Damian

#154539
Apr 29, 2009 at 3:14pm

I’d love to port this to Processing – you’re all getting some gorgeous results, but I don’t have much experience with MAX and Jitter – can anyone point me in a good starting direction?

#154540
May 13, 2009 at 3:08am

it would be easy to port, just take the shaders and input them into whatever processing library takes GLSL shaders. Then from there if you want Im down to talk on or off list about how to get them working. I dont know much processing yet, but I was hoping to do the same. I just chilled with casey reas all of saturday after we both gave lectures at the museum of contemporary art, and he was very cool. (one of the two co-founders of processing), it was funny cause I actually started talking about GPU and glsl during the lecture and everyone in the audience was well… lets say it was over their heads, hehehe

but yeah, message me or keep posting on the thread and Ill see what I can do, and Im sure if I dont have an answer mr reas or his students/colleagues will.

Oh and just fyi the things Ive been posting dont use what andrew posted, they are just using a similar algorythm from the cv.jit.HSflow but andrews is way faster and better on a good card.

#154541
May 14, 2009 at 3:01pm

oh and I think there might even be a hsflow opencv library for processing, it wont be as nice as converting the one andrew made but it will be able to do a ton of cool stuff

#154542
Nov 29, 2009 at 2:59am

“But I keep having this problem that is starting to drive me a little insane, recently whenever I run video through your flow distortion patch, the hs flow I get this black “swirl” that just turns the entire image to black and then there is nothing I can do to get it back I have to restart my computer and now I have restarted and I ‘m still having the problem!”

I am having the same problem for some reason and toggling the readback mechanism doesn’t seem to fix the problem. Its really weird because it works fine on my macbookpro and my house mates mac pro but im setting up an installation using 3 imacs running 10.5.8, 2.16ghz and they dont seem to be able to load the shaders or something.

Im not getting any error msg’s in the max window either. Really desperate to get this working. Any ideas….

Sorry for dredging up an old post as well.

Thanks.

#154543
Nov 29, 2009 at 3:32am

also the graphics card on these computers are NVIDIA GeForce 7300 GT and the graphics card on my mac book pro is an NVIDIA GeForce 8600M GT.

Could it be that the graphics card isn’t reading these shaders properly. >?

#154544
Nov 29, 2009 at 11:50pm

@Buffer, I have seen this effect before too, and it usually arises when I am using a lot of floating point textures. Switching to @type char (even temporarily) seems to clear it up. It appears there is some sort of floating-point arithmetic error that gets propagated (and appears as black pixels) in the feedback. I don’t actually understand enough of the inner voodoo of fragment processing units to say exactly what the cause is.

#154545
Nov 30, 2009 at 1:16am

Thanks Andrew. Yeah it does seem like there is some serious inner voodoo going on under the hood of this patch.

I found a work around that refreshes the image if it all swirls to black by hitting escape if its set up to make the window full screen. seems to reset the image to be moshed again.

Thanks for reply.

#154546
Dec 1, 2009 at 5:39am

Here is a link for the missing attachment.

Andrew B.

#154547
Mar 18, 2011 at 2:08pm

Hi All.
I try to make the vade’s shader (modification from flowrepos),
but I have several errors message (unable to bind scale and bias)…
Any idea of the issue ?



high-quality relative distortion based on hsflow output position map






< ![CDATA[

// vade modification of ab.flowrepos-http://cycling74.com/forums/topic.php?id=19283#post-101733
// Copyright 2009

//setup for 2 texture
varying vec2 texcoord0;
varying vec2 texcoord1;
varying vec2 texdim0;
varying vec2 texdim1;
uniform vec2 amt;
uniform vec4 scale;
uniform vec4 bias;
uniform vec2 boundmode;
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;

void main()
{
vec4 blurVector = texture2DRect(tex1,texcoord1); //sample flow texture

vec2 blurAmount = vec2(blurVector.y-blurVector.x, blurVector.w-blurVector.z);

/* vec4 blur1 = texture2DRect(tex1, texcoord1 + blurAmount);
vec2 blurAmount1 = vec2(blur1.y-blur1.x, blur1.w-blur1.z);

vec4 blur2 = texture2DRect(tex1, texcoord1 + blurAmount * 2.0);
vec2 blurAmount2 = vec2(blur2.y-blur2.x, blur2.w-blur2.z);
*/
vec2 amount1 = blurAmount;// + blurAmount1 + blurAmount2;
amount1 *= amt;

vec2 amount2,amount3,amount4,amount5,amount6,amount7,amount8;

amount2 = amount1 *1.5;
amount3 = amount1 *3.0;
amount4 = amount1 *6.0;

amount5 = amount1 * 8.0;
amount6 = amount1 * 10.0;
amount7 = amount1 * 12.0;
amount8 = amount1 * 18.0;

// sample our textures
vec4 sample0 = texture2DRect(tex0, texcoord0);
vec4 sample1 = texture2DRect(tex0, texcoord0 + amount1);
vec4 sample2 = texture2DRect(tex0, texcoord0 + amount2);
vec4 sample3 = texture2DRect(tex0, texcoord0 + amount3);
vec4 sample4 = texture2DRect(tex0, texcoord0 + amount4);
vec4 sample5 = texture2DRect(tex0, texcoord0 + amount5);
vec4 sample6 = texture2DRect(tex0, texcoord0 + amount6);
vec4 sample7 = texture2DRect(tex0, texcoord0 + amount7);
vec4 sample8 = texture2DRect(tex0, texcoord0 + amount8);

gl_FragColor = (sample0 + sample1 + sample2 + sample3 + sample4 + sample5 + sample6 + sample7 + sample8) / 9.0;
}

]]>

Thx.
Ad

#154548
Mar 18, 2011 at 6:53pm

i think it’s because you’re not actually using those uniforms in the program code. for whatever reason glsl generates an error in this case. either incorporate the uniforms into the code, or get rid of them.

#154549
Mar 21, 2011 at 9:53am

thank you rob !
ad-

#154550
Apr 3, 2011 at 5:57pm

does anyone know where Andrew’s attachment has gone form this thread? For example, the optical flow shader. Its not attached to his initial message….

#154551
Apr 3, 2011 at 6:14pm

sorry, found it :->

#154552
May 4, 2011 at 8:12am

where is the attachment aaaaaa

#154553
May 4, 2011 at 8:49am

jk found it sorry

#154554
Sep 24, 2012 at 1:32pm

link no longer works. would love to give this a test!

#154555
Sep 25, 2012 at 9:48am

I’ve uploaded it there

Attachments:
  1. hsflowdistort.zip
#154556
Sep 25, 2012 at 6:54pm

Thanks, much appreciated!

#154557

You must be logged in to reply to this topic.