0

By using the element buffer you send indices that indicate which verts to be used for a certain face. But what about normals? If I would want to render a cube with a basic diffuse shader, I would get smoothed normals (if I smooth them before). However when trying to render hard surfaced edges like a cube i can't draw hard edges, since some faces share the same vertex.

Is there a way to still use the element buffer for hard surfaced Objects?

I don't like the waste of memory when using glDrawArrays().

RIJIK
  • 398
  • 2
  • 10

1 Answers1

1

Generally speaking, a "Vertex" (in OpenGL terms) should contain all the necessary information for it to be rendered. This includes position, but may (and in your case probably should) also include things like Texture Coordinates, Normals, etc. So if you're working with two vertices that have the same position, but different texture coordinates or normals (which is quite common when dealing with cubes or other "flat shaded" object seams) you should be storing them as unique vertices.

You can still use an element buffer if you do this. You will have to increase the memory size of your vertex buffer object, and if you're rendering something as simple as a cube, you probably won't save much memory, but your element buffer object shouldn't be any bigger than before, if you do it correctly.

Xirema
  • 18,577
  • 4
  • 26
  • 60