View Full Version : return in fragment shader and linking multiple fragment shaders
divide
03-20-2004, 02:31 AM
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 ?
Corrail
03-20-2004, 03:43 AM
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!
divide
03-20-2004, 04:24 AM
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)
Corrail
03-20-2004, 06:51 AM
*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...
divide
03-20-2004, 08:35 AM
well.. maybe it's because I've tested this with 3DLabs SDK example, and maybe it only fully works with 3DLabs cards.
Corrail
03-20-2004, 08:58 AM
?
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).]
divide
03-20-2004, 11:08 AM
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.
divide
03-20-2004, 11:34 AM
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 ?
divide
03-20-2004, 11:25 PM
Works !
Actually I was running with Catalyst 4.2
I installed Catalyst 4.3 and everything works well !
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.