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 3 of 3

Thread: Multiple out variables in fragment shader

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    Multiple out variables in fragment shader

    I want to use two outs in frag shader and both of them are not vec4. If we use extended blending functionality it allows 2 outs which are vec4 and would be given input to blend equations. Now if my out is having only one channel, how can i use it, i mean in extended blending we have out variables with all 4 channels? How can we choose to use particular out variable at a time?

    i have sample shader with two out vars:
    i have sample shader with two out vars:
    Code :
     
    layout(location = 0) out float fragOut0;
    layout(location = 1) out float fragOut1;
    void main (void)
    {
    fragOut0 = float(vOutColour.r) + float(0.5);
    fragOut1 = float(vOutColour.b) + float(0);
    }

    how can i write a program which will use above frag shader.
    Last edited by debonair; 05-30-2013 at 02:00 AM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    2 blend outs is different to just multiple output buffers. Your code will work so long as you create a frame buffer with 2 attached texture buffers each with size of 1 float.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Thanks for your reply.

    What i got from you comment is that:
    Create FBO and 2 texture attachments, and each texture for each out variable. Now how can i select which out variable i am using. I know we can write to particular attachment by glDrawBuffers(). Is it like, if we have 2 variables with indexing done with "layout" in shader, then 0th indexed will be for first attachement?

    Quote Originally Posted by tonyo_au View Post
    frame buffer with 2 attached texture buffers each with size of 1 float..
    Can you please explain this?

Posting Permissions

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