Braden
Braden

Reputation: 31

Why do Stereolithography (.STL) files require each triangle to have a normal vector?

I'm trying to write some code to manipulate .STL ASCII files, and I'm trying to fully understand the file format. From what I've seen, the content of the "facet normal" line of each triangle has no effect on the triangle drawn. It also does not have any effect on which side of the triangle is considered the "outside", which is done by reversing the order of the vertices.

This triangle

facet normal 1 1 1
   outer loop
      vertex -1 1 1
      vertex 1 -1 1
      vertex 1 1 -1
   endloop
endfacet

is identical to this triangle

facet normal -1 -1 -1
   outer loop
      vertex -1 1 1
      vertex 1 -1 1
      vertex 1 1 -1
   endloop
endfacet

which is also identical to this triangle.

facet normal 1 0 0
   outer loop
      vertex -1 1 1
      vertex 1 -1 1
      vertex 1 1 -1
   endloop
endfacet

Given that having an explicit normal vector is redundant information mathematically, and that it's not even used in the drawing of the solid anyway, why is it in the file format? And if it's used for something, what is it for?

EDIT: I should add that I'm opening these files in Autodesk Meshmixer.

Upvotes: 2

Views: 1441

Answers (1)

Spektre
Spektre

Reputation: 51863

You did tested this how? If normal is not used by program you used to test then that does not mean the normals are not used at all in any other program there is. There are several reasons to include normal:

  1. smooth graphic shading (rendering)

    without normals you can not have smooth shading and smooth surfaces would look choppy unless very high triangle count is used...

    choppy Earth

    However to achieve really smooth shading we need per vertex normals and IIRC STL has only per face normals so the smoothing can be used only for artifact surface triangles.

  2. Declare tool access side and angle (printing)

    The STL is meant for 3D printing and depending on the technology used the normal could have special meaning like determining the access angle of tool to the surface or even can be used to tweak the layer structure or what ever. All of this this depend on how the control software of the printer interprets or use it.

Upvotes: 1

Related Questions