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

Thread: Vertex Arrays and Normals

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2002
    Posts
    166

    Vertex Arrays and Normals

    Simple Question:

    Using Vertext Arrays, I can send 8 vertices and 36 indexes to render a cube without lighting. If I want to light the cube, do I need to send 24 vertices and 24 normals and 36 indexes?

    Thank you for any info

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Vertex Arrays and Normals

    Whichever way you choose to render an object, for VA's you will have 1 normal per vertex, 1 tex coord (Tex Unit 0) per vertex, etc

    Right now you have chosen not to share vertices across faces, so normal interpolation is not what you want Im assuming.

    PS: accelerating cubes was actually suggested in opengl in the suggestions section. Shot dead on the spot!

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2002
    Posts
    166

    Re: Vertex Arrays and Normals

    I would like to share vertices across faces, but the shared vertex would have a different normal for each face. How can I share vertexes across faces and still have the proper normal used?

    Thanks again for your help

  4. #4
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3,032

    Re: Vertex Arrays and Normals

    You can't.
    You'll have to have duplicate vertices.
    Knackered

  5. #5
    Junior Member Regular Contributor
    Join Date
    May 2002
    Posts
    166

    Re: Vertex Arrays and Normals

    Thats what I was afraid of.

    I am loading a .3ds file that stores shared vertices along with the face indexes. It does not store the normals, so to render it I was going to "unshare" the vertices, generate the normals, and send everything in an expanded form. Is there any way to have OpenGL calculate the normals for me automaticially? That way I will only send the shared vertices and the indexes?

    Thanks again for any help

  6. #6
    Junior Member Regular Contributor
    Join Date
    May 2002
    Posts
    166

    Re: Vertex Arrays and Normals

    My question really is do I have to specify vertex normals to use lighting?

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Vertex Arrays and Normals

    as lighting depends on the surface normal of each pixel (or in gl of each vertex), yes

    don't be afraid of it..
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  8. #8
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Vertex Arrays and Normals

    For organic models (smooth surfaces) you will probably want to average normals for a shared vertex of neighboring sufaces.

    For non-organic models (a cube), you will be forced to duplicate vertices.

    Maybe Studio Max has some output feature for "unsharing vertices"???

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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