The OBJ file format and 3D printing go hand in hand. Find out all you need to know about OBJ file format for CAD and 3D printing in this guide.
The OBJ file format is one of the most important file formats in 3D printing and 3D graphics applications. It is the preferred format for multi-color 3D printing and is widely used as a neutral interchange format for non-animated 3D models in graphics applications.
In this article, we will discuss the OBJ file format in detail. We will talk about how the format is different from other competing file formats such as STL in the case of 3D printing or COLLADA and FBX in the case of graphics applications. What makes it better or worse?
We will also go through the different features offered by the OBJ file format and provide tips on how you can use these features to improve your 3D models. For 3D printing hobbyists, we will answer some commonly asked questions on the use of OBJ file format in 3D printing applications. For the hardcore readers, we will cover the full specifications so that you can read, understand and tweak the files manually. There’s also a section on resources, where we list websites and software for downloading, opening, editing and repairing OBJ files.
In a nutshell, the OBJ file format stores information about 3D models. It can encode surface geometry of a 3D model and can also store color and texture information. This format does not store any scene information (such as light position) or animations.
An OBJ file is usually generated by a CAD (Computer Aided Design) software as an end product of the 3D modeling process. The file extension corresponding to the OBJ file format is simply “.OBJ”.
The OBJ file format is open source and neutral. It is heavily used for sharing 3D models in graphics applications because it enjoys good import and export support from almost all CAD software. In recent years, it is also becoming popular as the de facto file format for multi-color 3D printing because the otherwise standard 3D printing format STL does not support color and texture information.
The OBJ file format was originally created by Wavefront Technologies for its Advanced Visualizer application to store geometric objects composed of lines, polygons, and free-form curves and surfaces. The most recently documented version is v3.0, superseding the previous v2.11 release.
The most recently documented version of the format is v3.0, superseding the previous v2.11 release.
The full name of this file type is “Wavefront OBJect”, but nobody bothers to use the full name anymore. It is simply referred to as the OBJ file format.
The most dominant format in the world of 3D printing is STL. However, STL is an old file format that, though being very popular, hasn’t really kept up with the times.
The fidelity of 3D printing is rapidly approaching micron level resolution and multi-color models are becoming increasingly popular. The STL file format cannot handle high resolutions very well since a higher resolution comes at the cost of increasing file size. The STL format is also not fit for multi-color 3D printing because it does not support color and texture information.
In contrast, it can approximate surface geometry as precisely as required without blowing up the file size. This is possible using Bezier curves and a method called NURBS which we will discuss later in this article. Furthermore, the OBJ file format has native support for multiple colors and textures within the same model.
Thus the OBJ file format wins over the STL format if you need precise, multi-color models and it is likely to become a very popular 3D printing format in the future because of this.
On the flipside, the OBJ file format isn’t as universal as the STL format. Almost all 3D printers support the STL format. The same cannot be said about the format, even though it enjoys reasonable adoption and support as well. Therefore, if you are 3D printing a mono-color model with a standard printer, the STL format is still preferable.
Both OBJ and STL formats have a very mature ecosystem with a large invested user base and plenty of third-party tooling.
The other 3D printing file format contenders are VRML, AMF, and 3MF. But they don’t have comparable support and are not serious alternatives to the STL and the OBJ file formats at this point.
The most commonly used file formats in 3D Graphics applications are OBJ, FBX, and COLLADA.
The most important difference between the OBJ file format and the other is the support for scene information (such as light sources) and animations. The OBJ file format does not support scene information and animations while FBX and COLLADA does. Therefore, if you need animations for your game or movie, then you better use the FBX and COLLADA format.
But in case you don’t need the full scene or animations, there are certain advantages to using the OBJ file format.
Firstly, the OBJ file format is a simple and open format. It has wide export and import support among CAD software. This means if you share your 3D model as an OBJ file, then other CAD software will interpret it correctly and consistently. The same cannot be said of the FBX or the COLLADA formats. The COLLADA format is also open source, but it is quite complicated. Different CAD software interprets it differently and this leads to inconsistencies.
The FBX format is a closed and proprietary format and offers an SDK for converting existing formats into FBX (Export). However, it is not so easy to go the other way – converting an FBX file into another format (Import). Developers of non-AutoDesk CAD software typically have to hack their way into implementing a plausible FBX import. This leads to inconsistencies if you are using non-AutoDesk software.
An OBJ file is also going to be much more lightweight and small in size compared to the FBX file or COLLADA file of the same 3D model. This is because of the simplicity of the OBJ file format compared to the other specifications and because of its native binary encoding.
Thus, if you don’t need the full scene or animations, and you care about support and consistent interpretation by different CAD software, the OBJ file format is the right format. In almost all other cases, FBX is the optimal format for 3D graphics applications.
In terms of modern features, the FBX format is the most progressive format offering plenty of cutting edge features and regular updates and improvements. The OBJ file format comes second in terms of features while the COLLADA format is considered slow to change.
The main purpose of the OBJ file format is to encode the surface geometry of a 3D object. The OBJ file format is quite versatile in this respect. It allows several choices for encoding surface geometry. Each of the three allowed methods outlined below have their own advantages and disadvantages.
In its simplest form, the OBJ file format allows the user to tessellate (tile) the surface of the 3D model with simple geometric shapes like triangles, quadrilaterals or more complex polygons. The vertices of the polygons and the normal to each polygon are then stored in a file to encode the surface geometry of the model.
For example, here is an image showing how a 3D model of a pig’s head can be tessellated with tiny triangles.
Tessellations with polygonal faces have advantages and disadvantages. Polygons are simple geometric shapes and this method is actually the simplest way to describe surface geometry. However, approximating a curved surface with polygons introduces coarseness to the model.
In the case of 3D printing, the 3D printer will print the object with the same coarseness as specified by the file. Of course, by making the triangles smaller and smaller, the approximation can be made better and better, resulting in good quality prints. However, as you decrease the size of the triangle, the number of triangles needed to cover the surface also increases. This leads to gigantic file sizes which 3D printing slicers struggle to handle. It’s also a pain to share or upload huge files like that.
It is therefore very important to find the right balance between file size and print quality. It does not make sense to reduce the size of the triangles ad infinitum because at some point your eye is not going to be able to distinguish between the print qualities.
The OBJ file format also allows for specifying the surface geometry of a model using freeform curves. The basic idea is that the user defines a collection of free form curves (Cardinal Splines, Bezier curves etc.) that run along the surface of the model. The surface is then approximated from this collection of curves.
Here is an example illustrating a free form curve on the surface of a 3D model.
As you can see, free-form curves are definitely more complicated than polygonal faces. But by sacrificing simplicity, we gain a lot too. Since freeform curves can describe curved lines exactly using a few mathematical parameters, they require far fewer data to describe the same surface when compared to an approximate method like polygonal tessellations. Therefore, we can create a high-quality encoding of any 3D model using free-form curves without blowing up the file size.
With the OBJ file format, you can also specify the surface geometry by tiling the surface with free-form surface patches instead of simple polygons. This kind of surface patches is very useful for describing surfaces that are not like planes, spheres, cylinders or cones i.e. surfaces that do not have a rigid radial dimension. Examples of such surfaces include the body of a car, the wings of an airplane or the hull of a boat.
The most common freeform surface is called NURBS (Non-Uniform Rational B Spline) and the OBJ file format supports it. The GIF shows an example of how a NURBS surface looks like.
The advantages of using freeform surfaces are somewhat similar to the advantages of using free-form curves – they are more precise and they lead to smaller file sizes at higher precision compared to other methods. In fact, one could argue that freeform surfaces are more precise than freeform curves since they encode the surface exactly as opposed to approximating the surface using curves. This is why they find application in engineering disciplines that are unforgiving when it comes to precision – such as aerospace engineering and automotive engineering.
In many applications, the appearance of the 3D model is of prime importance. For example, no one wants to play Need For Speed with dull, colorless cars. The cars better be colorful and shiny! The color and shine of a car are examples of appearance related properties. In simple terms, appearance describes surface properties such as material type, texture, color etc. This decides how the model looks like when it is rendered.
The OBJ file format lets you store color and texture information in a companion file format called the Material Template Library (MTL) format. This partner file has the extension .MTL.
With these two files together it is possible to render a multi-color textured model.
MTL files contain ASCII text that defines the light reflecting properties of a surface according to the Phong reflection model. One can define material properties like ambient color, diffuse color, specular color, transparency etc. We will discuss the MTL file specifications in more detail in a later section.
In addition to supporting these material properties, the MTL format also supports texture maps, which is a more convenient method of specifying colors and textures. In texture mapping, every point in the 3D model’s surface (or the polygonal mesh) is mapped to a 2-dimensional image. The coordinates of the 2D image have attributes like color and texture. When rendering the 3D model, every surface point is assigned a coordinate in this 2-dimensional image. The vertices of the mesh are mapped first. The other points are then assigned coordinates by interpolating between the coordinates of the vertices.
Recently, XYZ Printing announced the world’s first full-color desktop 3D printer. Priced at around $3000, it’s not unrealistic to say the 3D printing industry is slowly moving away from the monochromatic model to multi-color printing.
The OBJ file format absolutely supports multi-color 3D printing. In fact, it is right now the best choice if you choose to go the multi-color route. The standard 3D printing format STL does not support colors, and the other 3D printing formats like AMF, 3MF, and VRML are too fringe to consider for mainstream use.
For 3D printing, the file has to be opened in a dedicated slicer like Slic3r. What’s a slicer? It’s a piece of 3D printing software that converts digital 3D models into printing instructions for your 3D printer to create an object.
The slicer chops up your OBJ file into hundreds (sometimes thousands) of flat horizontal layers based on the settings you choose and calculates a tool-path to follow that will physically render your model, layer by layer. This process also calculates estimates for how much material your printer will need to extrude and how long it will take to do it.
All of this information is then bundled up into a GCode file, the native language of your 3D printer. Slicer settings do have an impact the quality of your print so it’s important to have the right software and settings to get you the best quality print possible. It’s also important to check if your Slicer supports OBJ files, and if yes, which features it supports. Some slicers might support simple polygonal meshes but throw an error if you used freeform curves or surfaces in your encoding.
Once the GCode has been uploaded to your 3D printer, the next stage is for those separate two-dimensional layers to be reassembled as a three-dimensional object on your print-bed. This is done by depositing a succession of thin layers of plastics, metals, or composite materials, and building up the model one layer at a time.
Unfortunately not. Only a 3D design that’s specifically made for 3D printing is 3D printable. The OBJ file is just the container for the data, not a guarantee that something is printable. Remember that the OBJ file format is also used as an interchange format for 3D graphics applications, a use case that has nothing to do with 3D printing.
3D models suitable for 3D printing need to have a minimum wall thickness and a “watertight” surface geometry to be 3D printable. Even if it’s visible on a computer screen, it’s impossible to print something with a wall thickness of zero.
There’s also the consideration of overhanging elements on the model. Look at the All3DP logo in the picture above; if the model is printed upright, then overhanging elements with more than a 45-degree angle will require supports (which you can see in green).
When downloading a file you didn’t create yourself, it’s worth taking the time to verify that it is indeed 3D printable. This will save you a lot of time, frustration and wasted filament.
In this section, we will share some awesome software and resources that you can use for downloading, viewing, editing and repairing OBJ files.
There are many repositories, marketplaces and search engines on the web containing literally thousands of free files. The major places for downloading OBJ files are TurboSquid, Free 3D, CGTrader, Archive3D, Clara, The Free 3D Models and Oyonale.
Fortunately, opening an OBJ file is not too complicated. Most CAD software can handle the OBJ file format and will let you view it. In particular, you can try Solidworks, Fusion 360, Blender, Rhino, Cinema4D, and Unity.
You can also view the files online without the hassle of downloading and installing software on your machine: Autodesk360Viewer, 3DViewerOnline, 3D-Tool are online 3D model viewers that support the OBJ file format.
There are several programs which can help with repairing a broken OBJ file. For example, Netfabb Basic, Meshmixer and Meshlab are all great tools for repairing the most common printing problems.
So far, we have discussed a lot about what the OBJ file format can do and what it cannot do. But how does the OBJ file format encode the information about geometry and material properties in a file? What will you actually see if you open the file with a text editor?
In this section we will go through the most basic parts of the specification, examining how the OBJ file format really works. After going through the information, you will understand and appreciate what each line of an OBJ file stores. If you are a programmer and want to create a parser, this knowledge is indispensable. The full OBJ file specification is available here.
The OBJ file format is an ASCII file format. If you are really hardcore, you can edit the files in a text editor.
The original specification doesn’t specify what the end of line character should be, so some software use carriage-returns and some use linefeeds. You might have to convert the end of line characters if your text editor or software fails to read the file.
The first character of each line is very important. It specifies the type of command. If the first character is #, that line is a comment and everything else in that line is ignored. Blank lines are also ignored.
Below we list out all the common commands. The first character is always a command type. It is followed by arguments. Everything shown in square brackets is optional.
# a comment line
As we discussed before, the # character indicates that the line is a comment and should be ignored. The first line is usually always a comment which specifies which program produced the file.
v x y z
This is the vertex command. In this simplified version of the specification, we will only cover polygonal faces, therefore the vertex command can be used to specify the vertices of the polygon. When using freeform surfaces and curves, there is a similar command vp that can be used to specify control points of the surface or curve.
The v command specifies a vertex by its three cartesian coordinates x, y, and z. The vertex is automatically assigned a name depending on the order in which it is found in the file. The first vertex in the file gets the name ‘1’, the second as ‘2’, the third as ‘3’ and so on.
vn x y z
This is the vertex normal command. It specifies the normal vector to the surface. x, y and z are the components of the normal vector. Note that this normal vector is not yet associated to any vertex point. We will have to associate it with a vertex later with another command called the f command.
The vertex normal command is omitted in a lot of files because when we will group vertices into polygonal faces with the f command, it will automatically determine the normal vector from the vertex coordinates and the order in which the vertices appear.
vt u v [w]
The vertex texture command specifies a point in the texture map, which we covered in an earlier section. U and V are the X and Y coordinates in the texture map. These will be floating point numbers between 0 and 1. They really don’t tell you anything by themselves, they must be grouped with a vertex in a f face command, just like the vertex normals.
f v1[/vt1][/vn1] v2[/vt2][/vn2] v3[/vt3][/vn3] ...
The face command is probably the most important command. It specifies a polygonal face made from the vertices that came before this line.
To reference a vertex you just follow the implicit numbering system of the vertices. For example ‘f 23 24 25 27’ means a polygonal face built from vertices 23, 24, 25 and 27 in order.
For each vertex, you may associate a vn command, which then associates that vertex normal to the corresponding vertex. Similarly, you can associate a vt command with a vertex, which will determine the texture mapping to use at this point.
If you specify a vt or vn for a vertex, you must specify it for all of them.
The group name command specifies a sub-object grouping. All f face commands that follow will be in the same group. This is useful if we want to reuse a particular information, such as material type, for a select part of an object.
The use material command lets you name a material to use. All following f face commands will use the same material until another usemtl command appears.
Putting all of this together, here is a rough outline of a simple OBJ file
# comment about what application generated this file. # all the 'v' commands are listed v x y z v ... # all the 'vn' commands are listed vn ... # all the 'vt' commands are listed vt x y z vt ... # a group is defined and the material for the group is set g object usemtl material # all the 'f' commands are listed f 1/1 2/2 3/3 4/4 f ....
The accompanying MTL file specifies the color and texture of the model. This MTL file is referenced by using the command
where the name is the name of the MTL file.
Since the materials are specified in the MTL file, the mtlib command must precede the usemtl command.
An MTL file may specify many materials. Materials are defined with the newmtl command.
The properties of the material are defined subsequently. Here are some commands that define properties.
Ka R G B
For example, this command defines the ambient color of the material. R, G and B are the red, green and blue channels. Each can take a value from 0 to 1.
Kd R G B
Similarly, Kd is the diffuse color.
This command specifies the transparency of the material. Values can be from 0 (totally transparent) to 1 (totally opaque).
This command specifies the illumination mode. Multiple choices are available, which are listed below:
0. Color on and Ambient off 1. Color on and Ambient on 2. Highlight on 3. Reflection on and Ray trace on 4. Transparency: Glass on, Reflection: Ray trace on 5. Reflection: Fresnel on and Ray trace on 6. Transparency: Refraction on, Reflection: Fresnel off and Ray trace on 7. Transparency: Refraction on, Reflection: Fresnel on and Ray trace on 8. Reflection on and Ray trace off 9. Transparency: Glass on, Reflection: Ray trace off 10. Casts shadows onto invisible surfaces
Finally, all of these properties can also be declared in a texture map. For example, if you want to declare the ambient color using a texture map, simply use the following command.
map_Ka square.tga # the ambient texture map
Here, the texture map is specified in a separate texture file with the extension .TGA.
To put everything together, here is an actual data file for a simple textured 2×2 square. It references an MTL file called master.mtl. This MTL file defines the material properties using a 1×1 texture map.
# A 2 x 2 square mapped with a 1 x 1 square # texture stretched to fit the square exactly. mtllib master.mtl v 0.000000 2.000000 0.000000 v 0.000000 0.000000 0.000000 v 2.000000 0.000000 0.000000 v 2.000000 2.000000 0.000000 vt 0.000000 1.000000 vt 0.000000 0.000000 vt 1.000000 0.000000 vt 1.000000 1.000000 # 4 vertices usemtl wood # The first number is the point, then the slash, and the second is the texture point f 1/1 2/2 3/3 4/4 # 1 element
In conclusion, we have learned a lot about the OBJ file format. We talked about how it compares with the other popular 3D printing and 3D graphics file formats and when to use each of these formats. Next, we discussed the features and later, presented a simple version of the full technical specification. We answered some common questions regarding the OBJ file format and its use in 3D printing. Finally, we shared some resources using which you can download, view and repair them.
We hope that an in-depth understanding of the OBJ file format helps you become a more knowledgeable 3D designer and a more informed user of your 3D printer. If you found this article useful, share it with other 3D design and printing enthusiasts and spread the word. Do you have some questions or remarks? Let us know in the comments below.
License: The text of "OBJ File Format – Simply Explained for CAD and 3D Printing" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.
Subscribe to updates from All3DP
You are subscribed to updates from All3DP
You can’t subscribe to updates from All3DP. Learn more…