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: extra vertices in vertex shader

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    11

    extra vertices in vertex shader

    I'll try to be as clear as I can to be easily understood.

    I know that by means of certain variables passed from vs to fs values are interpolated so each fragment gets the appropriate ones (like the fragment coords).
    I want to take advantage of this "free" interpolation and input a second set of 4 vertices in vs for a second texture so that in fs I can mix texture[0] with a displaced (projected) texture[1] just by specifying texCoord[0] and (ready interpolated)texCoord[1].

    1. Is it possible in the first place?
    2. Does GL know to match current fragment coords to the respective coords of the second set of vertices?
    3. In what order are the vertices to be specified to match?
    4. What qualifiers can the vertices be? (attributes, varyings) Can you give an example?

    What steps do I have to do? Where can I read about them?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    The vertex shader can have whatever output variables it wants. The fragment shader must have the same variables as inputs. The outputs from the vertex shader are interpolated and the interpolated value is passed to each invocation of the fragment shader.

    If you're using the compatibility profile, a number of such variables are pre-defined (e.g. gl_TexCoord). These behave the same as user-defined variables but don't need to be explicitly declared.

    The "varying" qualifier is deprecated. Values passed from the vertex shader to the fragment shader are declared as "out" in the vertex shader and "in" in the fragment shader.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    11
    Thank you.

Posting Permissions

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