SMOOTH-SHADING and Normal Vectors

Hello! :slight_smile:

I´ve written a program which reads STL-Data to show it with OpenGL on the screen.
An STL-File consists of many triangles WITHOUT ANY ORDER! Each of this triangles has one normal vector and three vertices.

The program shows the object now correctly, but…

My problem is: I want to make a Smooth-Shading. This means that I need to know the normal vector of EVERY vertex. But I have only one per Facet.
I tried it with the medium of all vectors of the neigbours of each facet. But in this case the progam needs many time to order the facets. :frowning:

My cuestion is:
1.) Is there any solucion for Flat-Shading without using normal vectors for every Vertex??
2.) Is there any data structure which is recomended for OpenGL?? (I´m using a list of the facets… very simple)… or much better: Is there any data structure PROVIDED BY OpenGL?? :stuck_out_tongue:


Thanks for helping me…

Greetings from Germany


btw, I don’t think your question is related to GLSL…

About the problem of finding the normals for each vertex, you can preprocess your file and save them in your own format.

  1. flat shading :
    for each face :
    glNormal (n)

  2. some data sturctures are faster on some hardware, and not on others. Try to align your data on nice 4,8,16 bytes boundaries. search for VBO and interleaved arrays. But I don’t know much about that, sorry.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.