problem with function in shader

Hi!

Why doesnt my function work in my shader? I keep getting:

out vec4 fragColor;
void main()
{

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

	vec4 color = vec4( rect(1.0, 1.0, 1.0, 1.0) );

	// vec4 color = vec4(1.0, 1.0, 1.0, 1.0);

    fragColor = TDOutputSwizzle(vec4(color) );
}

vec4 rect(float r, float g, float b, float a) {

	vec4 color = vec4(r, g, b, a);

	return color;
}

shader.toe (4.17 KB)

You need to put the vec4 rect() function (any functions you want to use) before, not after the void main() function (where the shader actually executes and draws fragments/pixels.)

Thanks!