From Shadertoy to Quartzcomposer: Help!

RQDC's picture

Hi Guys,

I'm trying to use some shader from Shadertoy. For example: https://www.shadertoy.com/view/4dBBWR When I copy the shader to quartz composer appear a message " 'iChannel0' syntax error.

Here the shader:

uniform vec3 iResolution; // viewport resolution (in pixels) uniform float iTime; // shader playback time (in seconds) uniform float iTimeDelta; // render time (in seconds) uniform int iFrame; // shader playback frame uniform float iChannelTime[4]; // channel playback time (in seconds) uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube uniform vec4 iDate; // (year, month, day, time in seconds) uniform float iSampleRate; // sound sample rate (i.e., 44100)

void mainImage(out vec4 c, vec2 u) { vec2 d = iResolution.xy;

c = (u/d/2.).xxyy*sin(iTime/3.);

S S S S S

c = mix(T(u+c.zy), fract(c/5.).argb, .01); }

Anyone knows what does that mean?

I attached the composition, if somebody can help I'll really appreciate it!

PreviewAttachmentSize
SH17A.qtz4.35 KB

Achim Breidenbach's picture
Re: From Shadertoy to Quartzcomposer: Help!

This error means that the QuartzComposer shader don't know about "samplerXX":

uniform samplerXX iChannel0..3;

The proper definition of a sampler in QC is:

uniform sampler2DRect texture;

Corresponding reading a pixel form this texture

texture2DRect(texture, gl_TexCoord[0].xy);

I am not familiar with shadertoy but I guess the line

uniform samplerXX iChannel0..3;

combines multiple lines of defining 4 samplers for the input images:

uniform sampler2DRect iChannel0; uniform sampler2DRect iChannel1; uniform sampler2DRect iChannel2; uniform sampler2DRect iChannel3;

which will give you 4 image inputs at the GLS Shader Macro once you use them in your shader code (e.g. reading pixels from it).

Unfortunately the mentioned shader toy sample won't run (gives me an syntax error for the shader) so I can't suggest a solution in QC.