Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: return in fragment shader and linking multiple fragment shaders

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    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 ?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: 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 ?
    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:
    Code :
    vec4 my_frag_shader();
     
    void main()
    {
      gl_FragColor = my_frag_shader();
    }
    Fragment Shader 2:
    Code :
    vec4 my_frag_shader()
    {
      vec4 tmp;
      // do something
      return tmp;
    }
    This should work, hope that is what you wanted!
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: return in fragment shader and linking multiple fragment shaders

    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)

  4. #4
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: return in fragment shader and linking multiple fragment shaders

    *hm*

    This shader is a red color shader here:
    Code :
    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...
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: return in fragment shader and linking multiple fragment shaders

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

  6. #6
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: return in fragment shader and linking multiple fragment shaders

    ?

    This code:
    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).]
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: return in fragment shader and linking multiple fragment shaders

    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.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: return in fragment shader and linking multiple fragment shaders

    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 ?

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    France
    Posts
    134

    Re: return in fragment shader and linking multiple fragment shaders

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •