Pulse Multitouch (originally by Danguafer/Silexars, ported to work with Multitouch) (Composition by gtoledo3)

Author: gtoledo3
License:
Date: 2011.10.05
Compatibility: 10.5, 10.6, 10.7
Categories:
Required plugins:
kineme multitouch

This is Pulse by Danguafer/Silexars(2010) from the ShaderToy collection, changed to work with multitouch.

The original fragment code is below:

//Pulse by Danguafer/Silexars(2010)
uniform float time;
uniform vec2 resolution;
uniform vec4 mouse;
uniform sampler2D tex0;
 
void main(void)
{
    vec2 halfres = resolution.xy/2.0;
    vec2 cPos = gl_FragCoord.xy;
 
    cPos.x -= 0.5*halfres.x*sin(time/2.0)+0.3*halfres.x*cos(time)+halfres.x;
    cPos.y -= 0.4*halfres.y*sin(time/5.0)+0.3*halfres.y*cos(time)+halfres.y;
    float cLength = length(cPos);
 
    vec2 uv = (gl_FragCoord.xy/resolution.xy+(cPos/cLength)*sin(cLength/30.0-time*10.0)/25.0);
    vec3 col = texture2D(tex0,uv).xyz*50.0/cLength;
 
    gl_FragColor = vec4(col,1.0);
}

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cybero's picture
Re: Pulse (Composition by gtoledo3)

Coincidentally I've been completing the porting of many of the Shader Toy shader collection over to QC GLSL . I'm still figuring out GLSL but you're really taking it into new areas by incorporating Multitouch interfaces.

I find it quite amazing how often one can alter only the fragment shader in the default GLSL Shader to get truly amazing results.

Thanks for sharing.

I think, from your slide show posts on Facebook that you've gotten way more reliably ported over than I have . [Just twigged as I wrote that you have ported 38ish - that's a new number on me BTW :-)].

Getting a truly original shader hosted at Shader Toy is becoming an ambition. Some amazing work posted thereon.

gtoledo3's picture
Re: Pulse (Composition by gtoledo3)

[small]The only thing I've ever posted on my personal fb from shader toy stuff (in QC) would be some pics from Lunaquatic today. I've posted some pics of the mandlebulb and quaternion, but neither were from this collection (and are actually sorta improved from the shader toy versions, but more processing heavy - subblue has some great versions of those). The quaternion pics are from an apple dev example running in QC :-) iq's edges are a little rougher in the shader toy example, but I haven't looked at the code yet to see what the differences are.[/small]

I have some original shaders, but I'd never even been aware of Shader Toy until a couple of days ago... I hadn't given any though to submitting anything, that's for sure! There's some really awesome stuff there. There are some things that are pretty much really, really basic shaders, that have been around for a long time on there, but that well developed demoscene stuff just blows my mind. IQ is amazing (as I said in another post). Checkout his home page, it's worthwhile. He doesn't give many (or any?) complete code samples, but reasons through stuff quite a bit. The things that he's made with shaders are very inspiring.

With something like the metablob shader, or this shader, in the examples, there's a blobby center of interest (or multiple)... that's usually being animated with some kind of waves (sin/cos, etc.). By stripping that out and providing access to the raw x/y coords, declaring them as uniforms, you can get access to them as input ports. It's usually the math to add up the extra stuff (the finger blobs in this case), or map x/y to QC screenspace that takes the most time.

In this one, I did some stupid thing that messed up the ripples from emanating from each finger correctly, that hung me up for a few minutes, but I did it on total speed run, else wise... trial and error :-)

gtoledo3's picture
Re: Pulse (Composition by gtoledo3)

On the number count - there are two extra multitouch, and one extra tweak I've done of the menger sponge. Other than that, the count may be higher, because I also had some shaders from an old version of shader toy, so they're grouped in that same zip on the other thread.

cybero's picture
Re: Pulse (Composition by gtoledo3)

DNA Flow - really sweet - probably from the older version of Shader Toy. Definitely some outstanding work all around on iq's site :-) .

cybero's picture
Re: Pulse (Composition by gtoledo3)

Interesting approach - seems kind of like retro fitting from sinoidals to real , rather than computed variables input to faciltate the multitouch, Only just begun to get my head around the requisite alterations and additions you've made .

gtoledo3's picture
Re: Pulse (Composition by gtoledo3)

cybero wrote:
DNA Flow - really sweet - probably from the older version of Shader Toy. Definitely some outstanding work all around on iq's site :-) .

Yeah, that's one of the older ones, for sure. I like that one a lot - it makes cool orbit traps with the texture. I like that it has a plasma/2D feel, but also feels very fractal like. That one can be interesting as a source for particle flows.

gtoledo3's picture
Re: Pulse (Composition by gtoledo3)

cybero wrote:
Interesting approach - seems kind of like retro fitting from sinoidals to real , rather than computed variables input to faciltate the multitouch, Only just begun to get my head around the requisite alterations and additions you've made .

In the original code, there are the lines:

 cPos.x -= 0.5*halfres.x*sin(time/2.0)+0.3*halfres.x*cos(time)+halfres.x;
 cPos.y -= 0.4*halfres.y*sin(time/5.0)+0.3*halfres.y*cos(time)+halfres.y;
  float cLength = length(cPos);

When you look at the original shader, there's a point of interest that the ripple originates from, and that's also fairly bright.

The sin and cos multiplied over time is what's making the movement of that, and the halfres.x and y stuff is what's setting it up so that it moves according to what one would expect over width and height. The float cLength is setting up the variable that allows the ripple to happen over x/y and for the color brightness thing that happens at each point.

So, when I setup:

uniform float x1;
uniform float y1;
uniform float s1;
uniform float x2;
uniform float y2;
uniform float s2;
 
and so on...

I'm setting up new variable names that can be accessed from input ports.

When I change out those lines above for:

vec2 cPos1 = gl_FragCoord.xy;
   cPos1.x -= x1;
   cPos1.y -= y1;
    float cLength1 = length(cPos1);
    vec2 cPos2 = gl_FragCoord.xy;
   cPos2.x -= x2;
   cPos2.y -= y2;
 
etc....

I'm stripping out that movement and replacing it with exposure for the multitouch to control the x/y coords manually.

In order to add new "blobs", I'm adding new coordinates for each one.

To make each new x/y make the ripple u/v's correctly I add in that to the part that controls uv's:

vec2 uv = (gl_FragCoord.xy/resolution.xy+((cPos1/cLength1)*sin(cLength1/30.0-time*10.0)/25.0))
    +(gl_FragCoord.xy/resolution.xy+((cPos2/cLength2)*sin(cLength2/30.0-time*10.0)/25.0));
    +(gl_FragCoord.xy/resolution.xy+((cPos3/cLength3)*sin(cLength3/30.0-time*10.0)/25.0));
    +(gl_FragCoord.xy/resolution.xy+((cPos4/cLength4)*sin(cLength4/30.0-time*10.0)/25.0));
 
etc...

The original has the line:

    vec3 col = texture2D(tex0,uv).xyz*50.0/cLength;

The 50.0 value is controlling the strength of the blob in relation to the x/y coords. So, by exposing that and calling it "s1" (like "size 1"), the size can be controlled my the size parameter of the multitouch with a little bit of multiplication to sweeten it up. In this case, adding all of the size/cLength's up results in an OK addition of the points, visually speaking.

danguafer's picture
Re: Pulse Multitouch (originally by Danguafer/Silexars, ...

Pulse was the first GLSL code I have ever made and I have to say that it looks pretty bad. haha :P I would like to see the multitouch version but I don't know which plataform I should use (iOS, maybe?). :)

gtoledo3's picture
Re: Pulse Multitouch (originally by Danguafer/Silexars, ...

It will require OS X, and installation of the kineme multitouch patch ( I think it's available in Downloads ), to run the "qtz" file.

I went ahead and compiled it as a self contained app, so that you don't need to install Developer Tools, etc., if you haven't already, or fuss with plugin install.

If you have some of the Lion OS X multitouch commands enabled, like "when there's four fingers down and swiping, make all windows do weird stuff", then they should probably be disabled for smooth use of the app, while one is using it.

It doesn't look bad! It's a pretty stock 2D deform/glsl shader (as you know), and it's as good as the context of use/source texture. One thing I'll say is that, when I see people rip it (or "use it") on the web, it's irritating to see the aspect ratio of the blobs not look right... that's when I go "ugh, that looks bad!". :-)

PreviewAttachmentSize
PulseMultitouch.zip337.89 KB