How to convert exported obj with vertex colors to obj with texture

I’m doing this to use exported obj files in Unity, with the Shapr3D colors. Once in Unity, you could change the texture, colors and shader. It should also work for other 3D apps. For instance, you could then convert obj to USDZ and use your model in AR through Apple’s Reality Composer. I’ll try that next and report back.

Meshlab is free, open source and cross platform. Let me know if I have left out any steps or if there are other questions.

How to convert Shapr3D export obj with vertex colors to obj with texture using Meshlab.

Export from Shapr3D
In Export, choose 3D model, then Obj
Third choice determines whether export is one mesh or several
Click Advanced Options (tiny, dim at bottom) and turn on Include Vertex Colors

Import mesh from Shapr3D into Meshlab
File/Import Mesh
It opens with the vertex colors showing, but Z axis is wrong - needs changing

Filters/Normals, Curvatures, and Orientation/Transform: Flip and/or swap axis
In panel, click Preview, Fli[p Z axis, Swap Y-Z axis, and Freeze Matrix, in that order
Confirm that the model is right side up - that you have correct Y and Z
Apply, close

Filters/Texture/Parameterization: per Triangle
In panel, change 1024 to 2048 (worked for me YMMV)
Apply, close

Filters/Texture/Transfer: Vertex Attributes to Texture (1 or 2 meshes)
The name of your exported mesh from Shapr3D will be in in both source and target - that’s fine
Enter a new name for the png texture file (especially if you are doing multiple tries at this)
Texture width and height change to 2048
Enable (check) Assign Texture and Fill Texture
Apply, close

Export Mesh…
File/Export Mesh as……
Give your exported mesh a name
At bottom make sure you change to Alias Wavefront Object (obj)
Pick a destination for the file and press Save

NOTE: the obj and mtl files will save where you specified… If the original export is not in the same place, you will find the png texture in the same directory as the original file

Create a new folder for your export and drag all three files into it

Import into Unity (or other app)
Open Unity
Drag the folder with the three files into the Assets folder
In Unity, open the imported folder - there will be a prefab cube, an obj and a texture file
Drag the prefab into your scene

3 Likes