compiling multiple buffers in the glsl-top

hi there,

im trying to compile this shadertoy shader,
the problem is that i can’t figure out how the buffer channels in shadertoy can be recomiled to something that would work in a glsl top…

this is the shader
shadertoy.com/view/4dcGW2#

ive recompiled some shaders succesfully, and i use the shadertoybrowser tox for most of the recompiling… but i could use a litle help with this multiple buffer thing…

should i have a glsl top for every buffer?
or should al the code from the diferent buffers be in one glsl top? and if this is the case… how ?

:question: :open_mouth:

Yes, you’ll need a GLSL top for each buffer.

I actually got this shader working in TD a while back but I forgot to save before closing. :frowning:

Also unfortunately the shadertoyBrowser.tox needs to be redone now that they have buffer channels. Maybe I’ll work on that this week. :slight_smile:

Does anyone have a working example using any multi buffer shader? I want to do something similar with some other shadertoy shaders, only I’m stumped how to link the TOPs together?

This is the setup for it.

[code]layout (location = 0) out vec4 fragColor1;
layout (location = 1) out vec4 fragColor2;

out vec4 fragColor;
void main()
{
vec4 color1 = texture(sTD2DInputs[0], vUV.st);
vec4 color2 = texture(sTD2DInputs[1], vUV.st);

// do stuff

fragColor1 = color1;
fragColor2 = color2;

}
[/code]

Then use two Render Selects after the GLSL Top. Drag each render select onto the “Target TOP” of the feedback tops, and wire the feedback tops into the GLSL. You’ll also need to wire a different “reset” top for the feedback tops.

Thanks David. I’ve built the network you described and got the main GLSL buffer to compile after fixing a few syntax errors . I still don’t get where the code for the second and third buffers goes though. I’m guessing I need additional GLSL TOPs somewhere? I don’t think I can just merge the code into one as they all have a mainimage() function.

Sorry if these sound like dumb questions. I’m a relative noob at TD, and zero previous experience with GLSL. Simple, practically useful documentation not so easy to find on this.

These lines:

layout (location = 0) out vec4 fragColor1;
layout (location = 1) out vec4 fragColor2;

Declare your output variables, and where they go. fragColo1 will go to the first buffer (first location) while fragColor2 will go to the 2nd buffer (location = 1). When you write to these variables, that is what controls what goes to those buffers.
No you don’t need a 2nd GLSL TOP for this.

Hopefully that helps clear it up.

Well it helps…but I’m not quite getting it yet :confused:

In the OP’s original example there are several buffers each implementing a mainImage function. If I have a single GLSL top that I put all the code into I will have to rename these, won’t I? So how/from where will they be called?

If anyone has a basic example of this they could post, I’d be very grateful.

:smiley: :smiley:

great! thx guys!

im gonna give it a try to get this baby working today!!

i was thinking, would it be an idea to have a subdirectory in the tox. section for glsl filters?
i think it would be nice for beginners to have a wide range of filters and generators to get started learning TD. (when i started in TD i had to do crazy shit for a simple kaleideoscope wich ran on just 12 fps :slight_smile:

cheerz!!

Same problem here implement buffer A and B to the touch designer glsl convert tool.

I understand close to nothing of your explainations I’m afraid. (I need drawings or something)

very confusing this converter since you only have one shader instead of pixel and vertex, where do you connect these A&B buffers once you have announced them (where? in main code), no inputs appear when I do, then it all ends up in a glsl top instead of a normal glsl so cannot connect txt to that.

A mini example showing these buffers connected would really help. thx

Or a sort of GLSL snipet like someone suggested in facebook forum could really help making entire Touch designer learning experience a pleasure. Because this part of gathering info about glsl form various sources and versions, for people like me with no coding background. Kills it! (to the risk of sounding like an idiot,I’m just offering an honest opinion,I try brainwash with all glsl tutorials I can find at the moment and still unclear).

Unless you want to keep all this top secret :wink:

It is still not clear for me, and I am probably not the only one.
So multiple buffers GLSL only need one GLSL TOP?
My first idea would be to have as many GLSL top as the buffers.
How is it working for example for this shader shadertoy.com/view/4dcGW2?

Yes, you just need 1 GLSL TOP, and set the parameter to increase the number of buffers. You use a Render Select TOP to pull the result out for buffers above the first one. But all the code to write to all the buffers all goes inside one GLSL TOP.

Thank you Malcolm.
using several GLSL top is also possible, right? just it is not necessary/clean and optimize?

ok I will dig into that way with one GLSL top.

Maybe this other thread and example file can help.

[url]convert Shader yes, no, Maybe - Beginners - TouchDesigner forum

yes example always helps.
Thank you David!

So in your example you use multiple GLSL.
I seen that you use feedback even when a glsl is not connected to himself. isnt it possible to connect directly different glsl without feedback?

I seen that you change the line vec2 uc = …
I was missing that. what is vUV.st?

vUV.st is a uniform supplied by touch:

derivative.ca/wiki099/index … a_GLSL_TOP

This saves you the work of setting up a uv coord based on resolution and frag coord. vUV.st would be the equivalent of the following :

vec2 uv = gl_FragCoord.xy / uTD2DInfos[0].res.zw;

Here uTD2DInfos.res.zy are the input dimensions in pixels of the first 2D Input texture to the TOP

great, thank you raganmd, it’s more clear now