# flat shaded polygons (fe-mesh) with VBO ?

Hi,

I have some difficulties to render FE-meshes consist of lots
of nodes (vertex points) and elements (quad or tria polygons).

In fact, I want to draw flat shaded polygon meshes using vertex
buffer object(VBO). but don’t know how to specify each polygon
face normal vectors efficiently in VBO.

With vertex array of size N and corresponding normal vector
array of size N (for each vertex), I think GL_N3F_V3F method

Do I need to create duplicated vertices and normal vectors for each faces ?

Is there any method to specify face normal vectors efficiently with VBO ?

Since OpenGL doesn’t allow multiple indices for a specific group of vertex attributes, you’ll have to duplicate each normal for a specific face 4 times, regardless of the primitive type. The vertices don’t have to be duplicated.

I’m not good at using VBO yet. How can I use vertices without duplication ?
If I use interleaved array with GL_N3F_V3F, I think I have to duplicate all vertices 4 times also.
If I have 100 vertices and 80 rectangular faces, I need 80 * 4 = 240 normal vectors.
So, array size of vertices is 100 and 240 for normal vectors.
This means different array index number for vertex and normal vectors.
How do I use the normal vector index and vertex index separately with glDrawElement() ?

There’s a couple of ways to do this:

Thanks maxlander.

My models are vehicle body FE-meshes, very complex shape with lots of holes, consist of 400~500 panels.
And further more, vertices and faces are create or deleted frequently in the program.
I think it’s very hard to define the mesh sequence with this kind of objects.
It is bit disappointing because I thought that there must be the simplest and faster way to do this…

I think I can use only the first method you’ve suggested.
But I’m afraid that VBO cannot store huge amount of data.

Size is matter. In general, my fe-model is composed of more than 4 million meshes.
This means VBO array size is at least 4,000,000 x 2 (vertex and normal) x 4 (quad or tria) x 4 (float bytes) = 128 MBytes.
And I need another VBO arrays for free-edges, feature lines, and many more other purposes.

If the normals you’re computing for the quad aren’t perturbed or special in any way, you can use a geometry shader to compute them. Draw the quads as lines_adjacency and have the geometry shader produce a triangle strip. If the quads are always planar, you only need to take the cross product of a pair of edges at a vertex to determine the normal. If the points in the quad aren’t coplanar, you can take the cross product of the edges at each vertex, and average the result.

Then, just apply the computed normal to each vertex’s normal in the tristrip you output from the geometry shader.