4
$\begingroup$

Example loading in 3D Builder

I've got an OBJ file with vertex colors, created by a machine learning script (PiFuHD). I want to get the mesh and colors into Blender. As far as I can tell, there's no way to change the output format of the script to include a separate MTL file. Exporting from Windows 3D Builder and MeshMixer (two programs I have that can read the vector colors) into the .ply format didn't include the color data.

Example of the format:

v -0.3317 -0.9479 -0.1019 0.3672 0.3232 0.3186
v -0.3316 -0.9479 -0.1038 0.3611 0.3151 0.3100
v -0.3316 -0.9477 -0.1019 0.3600 0.3144 0.3095

I tried to see if I could install this Addon to import them, but it's designed for Blender 2.8, and when I try to install it in Blender 3.2 nothing happens.

I want to be able to touch up the model, both mesh and textures, in Blender. I'm OK if I need to run this OBJ file through another program to get there, but I'm lost at where to go next. Everywhere seems like a dead end right now.

Blender Setup

$\endgroup$
4
  • $\begingroup$ Can you update to Blender 3.3? The new official OBJ importer imports vertex colors by default. $\endgroup$
    – scurest
    Commented Nov 14, 2022 at 20:49
  • $\begingroup$ @scurest Just tried that, using both the Wavefront (.obj) and Wavefront (.obj) (legacy) and I'm still not getting any color. $\endgroup$ Commented Nov 15, 2022 at 2:22
  • 1
    $\begingroup$ The new one is the one that does not say "legacy". Are you checking for a color attribute? The color attribute will be imported but the materials don't use it so you won't see anything special in Material view. $\endgroup$
    – scurest
    Commented Nov 15, 2022 at 2:28
  • $\begingroup$ @scurest Ah, that was what I was missing! After adding a new material, I could change the Base Color to be a Color Attribute, and then the Vertex Color showed up. Although it seems that using this method locks me out of using other modifiers, like Subdivision Surface (Blender crashes), so I might need a way to convert it to another format first. $\endgroup$ Commented Nov 15, 2022 at 4:23

2 Answers 2

3
$\begingroup$

So I have two solutions now:

The first was the comment @scurest gave - upgrade to 3.3, and use the new .obj importer. In the Object Data Properties, under Attributes, you'll see "Color Vertex > Color" if it worked. Then go to Material Properties, create a new material, click the yellow dot next to "Base Color", and in the far left column choose "Color Attribute".

The second way I found was using MeshLab. Go to File > Import Mesh, then go to Render and check the Show UV Tex Param option. Nothing will show up yet, but it's vital to understand the next step. Filters > Texture > Per Wedge Texture Function. Click "Apply" with the defaults (we'll come back and change this later), which will make the UV Tex Param grid show up. Then go to Filters > Texture > Transfer: Vertex Color to Texture, and give it whatever name you want (this will be generate a .png file with the same name). Now the UV Tex Param actually has a texture. In my case that texture was too big and not lined up correctly. To fix this, we have to go back to Filters > Texture > Per Wedge Texture Function. Each function is how you want to move the x or y coordinates of the vertexes. For simplicity, I applied the same formula to all my X and Y values. Check the preview button before you move anything.

So here's my before: Before picture in MeshLab

And here's my after: enter image description here

If you hit apply too early and get a messed up texture, don't worry about it, just focus on getting the silhouette inside the grid (the Per Wedge Texture Function box resets to it's default values each time you open it). After it's positioned correctly you can redo the Filters > Texture > Transfer: Vertex Color to Texture step to get the correct colors in the correct position.

From here, File > Export Mesh As and double check that the extension in the filename and the Save as Type match (I don't know if it matters much, but it kept trying to change it on me).

Here's the two meshes side-by-side in Blender. The Left is Meshlab, the Right is using Blender's Nodes:

Blender results

Right off, I notice that the edges and faces on the Blender version are more noticeable due to the reflective nature of the material it created, while the MeshLab version had some slightly miss colored spots. I'm sure editing the Blender texture would take care of the glossy look, and I think MeshLab's issue came from not applying the same scaling to both X and Y, but it could be an issue with my texture itself that's only because the glossy shine isn't there. If it is a texture issue, Blender's Texture Paint can help fix it with the Mesh Lab approach, but won't be able to with the Vector Color.

$\endgroup$
0
$\begingroup$

Assuming that the linked add-on works as intended in Blender 2.8, which I have not checked, you could try the following steps:

  1. Download and extract the portable version of Blender 2.8 (no installation required)
  2. Install the add-on for Blender 2.8
  3. Import the model with Blender 2.8
  4. Export the model in a format the supports vertex colors, e.g. .ply
  5. Import the properly exported model in your current Blender version.
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .