Results 1 to 2 of 2

Thread: shared information between vertices on a same triangle

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    8

    shared information between vertices on a same triangle

    Hello guys,

    I have a question about sharing information between vertices on a same triangle when writing GLES 2 shaders.

    before, when we use Opengl, sharing an information between vertices on a same triangle is very easy.

    for example, if we want the normal of the three vertices of the triangle be the same, we can simply do this:

    glBegin(GL_TRIANGLES);
    glNormal3f();
    glVertex3f();
    glVertex3f();
    glVertex3f();
    glEnd();

    the three points will have the same normal inside the shader program.

    but as for GLES2 (and i guess the new opengl standard), we are forced to use vertex attributes.

    so how do i share an information between points on the same triangle.

    the normal case is one example. another example is the texture coordinate case.

    for example, if i want to texture map a ball. there must be some points that are on the seam of the texture. in other words, those points must have two sets of texture coordinates or even more.

    depending on which triangle you are drawing, you assign difference texture coordinates to the point.

    but with gles 2 shader, i don't know how to do this, because it seems that a vertex always maps to a single texture coordinate:

    attribute vec4 vertex;
    attribute vec4 texcoord;

    of course, duplicating points is a solution, but in the facet normal case, you need to duplicate a lot of points in order to use different normals on different facet.


    i would like to give another example:

    suppose we have a geometry object formed by triangles.

    now, i need to write a gles 2 shader that color different triangle with different color.

    how do i do that?

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: shared information between vertices on a same triangle

    Yes, you'll have to duplicate the data. glBegin(); glNormal3f();...; glEnd(); is simply duplicating the data for you.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Information concerning memory access
    By benschaff in forum OpenCL
    Replies: 14
    Last Post: 03-04-2010, 01:25 PM

Posting Permissions

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