Is it possible to convert this shader to corona style?

https://www.shadertoy.com/view/4tjGRm

void mainImage( out vec4 o,vec2 n ) { float t = iDate.w,s = 8.+5.\*sin(t); vec2 m = iMouse.xy; if(length(n-(iResolution.xy-m))\>2.\*s && length(n-m)\>s) discard; o.xyz = clamp(abs(fract(t + vec3(1., .6, .3)) \* 6. - 3.) - 1., 0., 1.); }

Hi.

First off, for a lot of this (maybe all of it, if you don’t actually care about the glow), you should look at this: Paint Brushes, Trailing Objects, and More with the Snapshot Canvas In particular, see the note after the code sample.

That said, everything else does indeed look possible, yes.

All the things prefixed with “i” are some Shadertoy-specific input. 

I don’t know if the w component of iDate is measured in seconds, as  CoronaTotalTime is, but it ought to be just a matter of scaling to bring those into agreement.

While discard is available, I imagine the way it’s used in that example is just to prevent the pixel in question from being overwritten. With the snapshot machinery underneath you, you ought to be fine with just a return vec4(0.);

Taking a wild guess here, but iResolution and iMouse would probably be passed through the shader’s vertex userdata, say with x and y being the width and height of your box (probably the content dimensions?), then z and w being the last touch position (or some default, say an off-screen position, if no touches have happened yet).

The thing about Shadertoy (and this is also true about Corona’s shader playground) is that it’s self-contained, so a lot of those details have to be fed in or calculated on the fly. In a real-world fragment shader, on the other hand, you’ll pass them in from your app.

Hi.

First off, for a lot of this (maybe all of it, if you don’t actually care about the glow), you should look at this: Paint Brushes, Trailing Objects, and More with the Snapshot Canvas In particular, see the note after the code sample.

That said, everything else does indeed look possible, yes.

All the things prefixed with “i” are some Shadertoy-specific input. 

I don’t know if the w component of iDate is measured in seconds, as  CoronaTotalTime is, but it ought to be just a matter of scaling to bring those into agreement.

While discard is available, I imagine the way it’s used in that example is just to prevent the pixel in question from being overwritten. With the snapshot machinery underneath you, you ought to be fine with just a return vec4(0.);

Taking a wild guess here, but iResolution and iMouse would probably be passed through the shader’s vertex userdata, say with x and y being the width and height of your box (probably the content dimensions?), then z and w being the last touch position (or some default, say an off-screen position, if no touches have happened yet).

The thing about Shadertoy (and this is also true about Corona’s shader playground) is that it’s self-contained, so a lot of those details have to be fed in or calculated on the fly. In a real-world fragment shader, on the other hand, you’ll pass them in from your app.