GLSL sampler inputs

Hey guys and girls,

i tried to port a shader from shadertoy to touchdesigner but touchdesigner doesn’t want to accept my variables i am using:

this is the shader i want to import:
shadertoy.com/view/MlG3WG

this is what i found so far for porting shaders from shadertoy to touchdesigner:
nvoid.gitbooks.io/introduction- … ertoy.html

saying

“Samplers
Shadertoy has named their sampler inputs iChannels.These samplers can be images, videos, noise patterns, cube mabs, etc. The ‘GLSL’ TOP has a similar variable called sTD2DInputs. The Shadertoy samplers are individual numbered samplers, such as iChannel0 and iChannel1. In TouchDesigner, sTD2DInputs is an array, so you can access an elements with a numeric index.
Now, search through the code and wherever there is the a reference to iChannel0, replace that with sTD2DInputs[0]. Where there is a reference to iChannel1, replace that with sTD2DInputs[1].”

i’m stuck at the sampler inputs. i tried to change channel0 to sTD2DInput[0] but the info window connected to the glsl gives me an error: undefined variable “sTD2DInputs”

Anyone knows why touchdesigner doesn’t accept the variable sTD2DInput[0] as channel0 in this code?

i know, i know, there is a edge top in TD doing similar but i want to understand the way porting shaders from shadertoy to TD :slight_smile:

thanks,
SCatur

Hi there Stan,

The correct name is ‘sTD2DInputs’ (with an ‘s’). This variable is set when the glsl TOP has
input tops flowing in. When there are no inputs, it indeed gives an undefined variable error.

However the shader you are trying to convert has 2 buffers (see above the code ‘buffer A’ and
‘Image’). This means you need to make 2 glsl TOPs, 1 with the code of ‘buffer A’ and send the output to the first input of the ‘Image’ shader (which will be sTD2DInputs[0]).

It looks like ‘Buffer A’ also needs its own output as second input. This can be done using a feedback TOP.

Hope this helps.
cheers,
tim

Got it!
Thanks for the help.

CStan