Return in fragment shader and linking multiple fragment shaders

I wrote this simple fragment shader to test the “return” command:

void main (void)
{
gl_FragColor = vec4 (1.0,0,0,0);
return;
gl_FragColor = vec4 (0,0,1.0,0);
}

However it seems not to return, since the final color I get is blue (0,0,1) and not red (1,0,0). What is the problem ?

Second question: how to “link” multiple fragment shaders, so that when the first fragment shader return, a second fragment shader do his job, based on results from the first fragment shader ?

I wrote this simple fragment shader to test the “return” command:

void main (void)
{
gl_FragColor = vec4 (1.0,0,0,0);
return;
gl_FragColor = vec4 (0,0,1.0,0);
}

However it seems not to return, since the final color I get is blue (0,0,1) and not red (1,0,0). What is the problem ?

Seems like a bug… Which gaphic card/driver do you use=

Second question: how to “link” multiple fragment shaders, so that when the first fragment shader return, a second fragment shader do his job, based on results from the first fragment shader ?

Try this:

Fragment Shader 1:

vec4 my_frag_shader();

void main()
{
gl_FragColor = my_frag_shader();
}

Fragment Shader 2:

vec4 my_frag_shader()
{
vec4 tmp;
// do something
return tmp;
}

This should work, hope that is what you wanted!

thanks for help

My card is ATI Radeon 9800SE with Catalyst 4.3

Can you test this shader

void main (void)
{
gl_FragColor = vec4 (1.0,0,0,0);
return;
gl_FragColor = vec4 (0,0,1.0,0);
}

and tell me if you have the same problem ? (that is, blue color instead of red)

hm

This shader is a red color shader here:

void main (void)
{
gl_FragColor = vec4 (1.0,0,0,0);
return;
gl_FragColor = vec4 (0,0,1.0,0);
}

I’ve got a Radoen 9800Pro with Catalyst 4.3…

well… maybe it’s because I’ve tested this with 3DLabs SDK example, and maybe it only fully works with 3DLabs cards.

?

This code:

void main (void)
{
gl_FragColor = vec4 (1.0,0,0,0);
return;
gl_FragColor = vec4 (0,0,1.0,0);
}

should be red and it is red when I’ve tested it.

[This message has been edited by Corrail (edited 03-20-2004).]

yes I agree it should be but it is not in the 3DLabs SDK example running with my Radeon 9800SE. But I’ll make another test with a clean code, not 3DLabs related.

No way… I’ve tried with Ffelagund’s ShaderDesigner (www.typhoonlabs.com) but it doesn’t change anything: I still have a blue render when I paste this code into a fragments shader:

void main (void)
{
gl_FragColor = vec4 (1,0,0,0);
return;
gl_FragColor = vec4 (0,0,1,0);
}

I’m… puzzled ! anyone with a radeon 9800se ?

Works !
Actually I was running with Catalyst 4.2
I installed Catalyst 4.3 and everything works well !

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.