# GLSL - void main(out vec4 O, vec2 U). Help?

Hi Guys,

I’m slowly learning GLSL, I read both The Book of Shaders and Introduction to Touchdesigner especially the shading part. I started to convert some simple shaders found online and most of them with success. I’ve been stuck for a few hours now on this shader [url]https://www.shadertoy.com/view/XdlyzS[/url]

``````float noise3( vec3 x , out vec2 g) {
vec3 p = floor(x),f = fract(x),
F = f*f*(3.-2.*f);
#define hash3(p)  fract(sin(1e3*dot(p,vec3(1,57,-13.7)))*4375.5453)

float v000 = hash3(p+vec3(0,0,0)), v100 = hash3(p+vec3(1,0,0)),
v010 = hash3(p+vec3(0,1,0)), v110 = hash3(p+vec3(1,1,0)),
v001 = hash3(p+vec3(0,0,1)), v101 = hash3(p+vec3(1,0,1)),
v011 = hash3(p+vec3(0,1,1)), v111 = hash3(p+vec3(1,1,1));

g.x = 6.*f.x*(1.-f.x)
* mix( mix( v100 - v000, v110 - v010, F.y),
mix( v101 - v001, v111 - v011, F.y), F.z);
g.y = 6.*f.y*(1.-f.y)
* mix( mix( v010 - v000, v110 - v100, F.x),
mix( v011 - v001, v111 - v101, F.x), F.z);

return mix( mix(mix( v000, v100, F.x),
mix( v010, v110, F.x),F.y),
mix(mix( v001, v101, F.x),
mix( v011, v111, F.x),F.y), F.z);
}

float noise(vec3 x, out vec2 g) {
vec2 g0,g1;
float n = (noise3(x,g0)+noise3(x+11.5,g1)) / 2.;
g = (g0+g1)/2.;
return n;
}

void mainImage( out vec4 O, vec2 U )
{
vec2 R = iResolution.xy;
U *= 8./R.y;
vec2 g;
float n = noise(vec3(U,.1*iTime), g),
v = sin(6.28*10.*n);
//g = vec2(dFdx(n),dFdy(n));
//O = vec4( sin(10.*atan(g.y,g.x)), v, 0,0); return;
g *= 6.28*10.*cos(6.28*10.*n) * 8./R.y;
//v = tanh(2.*abs(v) / (abs(g.x)+abs(g.y)));
v = tanh(min(2.*abs(v) / (abs(g.x)+abs(g.y)),10.));
n = floor(n*20.)/20.;
O = v * (.5+.5*cos(12.*n+vec4(0,2.1,-2.1,0)));
}``````

I think I’m doing something wrong converting this specific part

``void mainImage( out vec4 O, vec2 U ) ``

After modifying the above to void main() I tried to insert at the top this:

```layout (location=0) out vec4 O; out vec2 U;```

and also this

```layout (location=0) out vec4 O; layout (location=1)out vec2 U;```

In both cases, the shader is compiled successfully but I only get a yellow/green still image.

What am I doing wrong? Any suggestion?

This modification will help

```void main() // ------------ draw isovalues { vec2 R = iResolution.xy; vec2 U = gl_FragCoord.xy; // more code }```
You’ll also replace iTime with iGlobalTime
And the final line will be

``fragColor = v * (.5+.5*cos(12.*n+vec4(0,2.1,-2.1,0)));``