Abt smooth group

There is something I dont quite know abt smooth group,wot does it mean,and how can I use it to generate surface normal.Thx

p.s. Im workin on a data export plugin currently,and so how my normal didnt works in the right way,hope ya can help me.

Without more info no-one is going to be able to help you.

A submesh, where the 3 vertices of a triangle have normals different from the triangle’s normal. In contrast, a flat-shaded triangle’s vertices have identical normals.
Defining a flat-shaded triangle usually requires unwelding of its vertices (making the triangle use vertices that are not used in any other triangle, can require cloning of vertices and modifying their normal).
Unlike in modelers, in OpenGL triangles store no data. They only contain the indices of the 3 vertices. Thus, without unwelding a vertex normal will be correct only for one of the triangles that use that vertex.
Smoothing groups may need to be separated/unwelded from the rest of the mesh, as in some cases they could overwrite another smoothing-group’s normals.

Nitpick:

  • In GL3.0, you can specify the varying “flat” modifier, which disables interpolation of a varying.
  • geometry shaders practically do unwelding all the time
  • a normal for flat shading can be done in a fragment shader with dFdx()
  • with gl_PrimitiveID you can effectively specify per-triangle data.
  • with ancient GL, drawing of flat triangles is exposed as a toggle, but it is either fixed-func only or relies on older, non-generic specification of attributes and varyings. Probably makes the driver do unwelding.

It doesn’t seem like “Advanced OpenGL” topic. It’s not OpenGL at all, more like to be Math topic.
Nevertheless, the pseudo-code for the normal calculation from smoothing groups info is here:


vertex(i)_normal for face(j) = face(j).surface_normal
for each face(k) sharing vertex(i) with face(j):
   if face(k).sm_groups intersect(&) face(j).sm_groups: 
       vertex(i)_normal += face(k).surface_normal
vertex(i)_normal.normalize()

I hope I wrote it correctly :slight_smile: