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

Thread: Separate shader pipelines program problem

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Sep 2012
    Posts
    76

    Separate shader pipelines program problem

    Greetings:
    I am trying to write a program to draw a Bezier curve and its 4 control points. Stand-alone separate programs to do these work fine. The point-drawing program has VS - FS shaders, the curve program has VS - TCS - TES - FS.

    In order to render control points and curve together I am trying to write a program with two pipelines generated with glGenProgramPipelines(2, pipeline) and bound with glBindProgramPipeline(pipeline[0/1]), etc. Obviously, the points pipeline is VS - FS and the curve pipeline VS - TCS - TES - FS. In fact, the VS and FS are same, the points pipeline dropping the TCS and TES and draw call changing from GL_PATCHES to GL_POINTS.

    Here's the problem: the point pipeline seems to be drawing points correctly but the curve pipeline seems to be doing nothing.

    Since the shader logic seems correct (stand-alone programs work) and the app program ok (at least one pipeline functions) I am guessing the problem is in the interface between shaders. I declare
    Code :
    out gl_PerVertex
    {
      vec4 gl_Position;
    };
    in the VS but I am not sure what to do in the other shaders. My FS is a one line color declaration while my TCS and TES are copied from Bailey/Cunningham:
    TCS:
    Code :
    #version 400
    #extension GL_ARB_tessellation_shader: enable
    uniform float uOuter1;
    layout( vertices = 4 ) out; // same size as input,
    // (but doesn’t have to be)
    void main( )
    {
    gl_out[ gl_InvocationID ].gl_Position =
    gl_in[ gl_InvocationID ].gl_Position;
    gl_TessLevelOuter[0] = 1.;
    gl_TessLevelOuter[1] = uOuter1;
    }

    TES:
    Code :
    #version 400
    #extension GL_ARB_tessellation_shader: enable
    layout( isolines, equal_spacing) in;
    void main( )
    {
    vec4 p0 = gl_in[0].gl_Position;
    vec4 p1 = gl_in[1].gl_Position;
    vec4 p2 = gl_in[2].gl_Position;
    vec4 p3 = gl_in[3].gl_Position;
    float u = gl_TessCoord.x;
    // the basis functions:
    float b0 = (1.-u) * (1.-u) * (1.-u);
    float b1 = 3. * u * (1.-u) * (1.-u);
    float b2 = 3. * u * u * (1.-u);
    float b3 = u * u * u;
    gl_Position = b0*p0 + b1*p1 + b2*p2 + b3*p3;
    }
    Really appreciate if you could say how to write the interfaces or suggest other possible issues.
    Thanks,
    Sam

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,104
    try gl_TessLevelOuter[0] with a value other than 1.

  3. #3
    Intern Contributor
    Join Date
    Sep 2012
    Posts
    76
    Quote Originally Posted by tonyo_au View Post
    try gl_TessLevelOuter[0] with a value other than 1.
    Tried 2.0, 3.0. No cigar.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,104
    This is some test code of mine from a while ago - I don't know why but I am setting all the gl_TessLevels

    Code :
    -- beziert.vertex
    #version 400 core
     
     
    layout(location = VERTEX_BINDINGS_POSITION) in vec3 Position;
     
     
    void main()
    {
      gl_Position = vec4(Position,1);
    }
     
     
    -- beziert.tcs
    #version 400 core
     
    layout( vertices = 4 ) out;
    void main( )
    {
     
     
      gl_out[ gl_InvocationID ].gl_Position = gl_in[ gl_InvocationID ].gl_Position;
      gl_TessLevelInner[0] = 10;
      gl_TessLevelInner[1] = 10;
      gl_TessLevelOuter[0] = 10;
      gl_TessLevelOuter[1] = 10;
      gl_TessLevelOuter[2] = 10;
      gl_TessLevelOuter[3] = 10;
    }
    -- beziert.tes
     
    #version 400 core
    uniform mat4 u_CameraModelView ;
    uniform mat4 u_CameraProjection ;
    uniform mat4 u_ModelMatrix;
     
    layout( isolines, equal_spacing) in;
     
     
    void main( )
    {
      vec4 p0 = gl_in[0].gl_Position;
      vec4 p1 = gl_in[1].gl_Position;
      vec4 p2 = gl_in[2].gl_Position;
      vec4 p3 = gl_in[3].gl_Position;
      float u = gl_TessCoord.x;
      // the basis functions:
      float b0 = (1.-u) * (1.-u) * (1.-u);
      float b1 = 3. * u * (1.-u) * (1.-u);
      float b2 = 3. * u * u * (1.-u);
      float b3 = u * u * u;
      vec4 pos = b0*p0 + b1*p1 + b2*p2 + b3*p3;
      gl_Position = u_CameraProjection * u_CameraModelView * u_ModelMatrix * pos;
    }

  5. #5
    Intern Contributor
    Join Date
    Sep 2012
    Posts
    76
    Thanks, tonyo_au.
    After reading your post I went in and declared actually all the built-ins for each shader stage. Still no luck.

    Now, I am beginning to wonder if it's a driver issue. Only way to know would be to try to run code of this sort with multiple pipelines and tessellation shaders that's known to run elsewhere. Appreciate a pointer if you know of such.

Posting Permissions

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