5
$\begingroup$

Recently, I found this funny site, that allows you to generate a 3D model from a 2D image.

It works very well and you can download an OBJ file. Vertex are colored and when I import it using Blender, I can't see any Vertex color.

Using Cycle (I prefer a internal solution if it exists) according to some answers I've found on Blender Stack Exchange, I patched some nodes : Attribute -> Diffuse BDSF -> Material Output.

Unfortunately, I can't get it works, the model stills black.

When I open the OBJ file, I see that color per vertex are there :

v 43.747554 107.000000 69.000000 0.470588 0.380392 0.309804
v 43.780163 115.000000 64.500000 0.427451 0.337255 0.266667
v 43.782527 107.000000 68.500000 0.470588 0.380392 0.309804
v 43.801902 115.000000 65.000000 0.427451 0.337255 0.266667
v 43.806461 107.000000 69.500000 0.470588 0.380392 0.309804
v 43.821703 115.000000 64.000000 0.427451 0.337255 0.266667
v 43.838352 108.000000 68.500000 0.466667 0.376471 0.305882
v 43.854670 106.000000 69.000000 0.482353 0.392157 0.321569
v 43.856176 108.000000 69.000000 0.466667 0.376471 0.305882
v 43.873876 106.000000 69.500000 0.482353 0.392157 0.321569
v 43.888855 110.000000 68.000000 0.466667 0.376471 0.305882
v 43.891471 109.000000 68.000000 0.466667 0.376471 0.305882
v 43.892733 110.000000 67.500000 0.466667 0.376471 0.305882
v 43.895170 108.000000 68.000000 0.466667 0.376471 0.305882
v 43.900904 109.000000 68.500000 0.466667 0.376471 0.305882
v 43.907584 107.000000 68.000000 0.470588 0.380392 0.309804
v 43.917898 115.000000 65.500000 0.427451 0.337255 0.266667
v 43.925000 111.000000 67.500000 0.454902 0.364706 0.294118

According to some answers here, Blender import more easily the vertex color of a PLY file so I tried to convert to PLY with two different sites :

1. meshconvert .com : Give me a 3.5 Mo file

2. greentoken.de/onlineconv : Give me a 2.3 Mo file

(Of course, if you know some other sites I could try, it interest me)

I guess that color data are lost with greentoken (not sure).

When I import the 3.5 Mo PLY file in blender, I need to be in textured display mode, then I think I see my vertex color value but in black & white instead of RGB, that is weird. Anyway, I can't get it work

EDIT 1 : I opened PLY files and color vertex aren't there... I need to find a better converter

EDIT 2 : I tried www.ofoct.com/3d-model-file-for-3d-printer-converter it doens't take vertex color into account. In fact, in each PLY files I converted with the various sites here, there is a common line :

comment Created by Open Asset Import Library - http://assimp.sf.net (v3.2.0)

(the version varies)

EDIT 3 : In fact it seems that model converted by Green token, keep the vertex color. That is weird because that's the smallest file :

ply
format ascii 1.0
comment Created by Open Asset Import Library - http://assimp.sf.net (v3.1.187496374)
element vertex 29793
property float x
property float y
property float z
property float nx
property float ny
property float nz
element face 59582
property list uint uint vertex_index
end_header
82 103 6.37528 0.40963 0.0331735 0.911648
82 102 6.57043 0.272087 0.235193 0.933088
82.6603 103 6.5 -0.14071 0.043367 0.9891
82 103.935 6.5 0.201161 -0.136681 0.969976
81.5475 103 7 0.825371 0.0489484 0.562465
83 102 6.62244 -0.248588 0.147929 0.957247
83 103 6.56417 -0.411487 -0.0867124 0.907281
81.5819 104 7 0.787841 -0.0338904 0.614946
82 105 6.63886 0.0715144 -0.131383 0.988749
83 104 6.77321 -0.431167 -0.171652 0.885794
83.6781 102 7 -0.470137 0.061235 0.880467
83.6327 103 7 -0.543939 -0.0905203 0.834228
83 105 6.96709 -0.445324 -0.163091 0.880391
84 103 7.23724 -0.520118 -0.141377 0.842313
84 104 7.47775 -0.546517 -0.195833 0.814229
84 102 7.16782 -0.416323 -0.021798 0.908955
83.3508 101 7 -0.314426 0.156435 0.936304
84 101 7.22581 -0.280388 0.0301462 0.959413
84.9009 101 7.5 -0.339848 -0.0219793 0.940223
84.6939 102 7.5 -0.435242 -0.0925323 0.895546

As you can see, nx, ny and nz correspond to RGB values..

$\endgroup$
  • $\begingroup$ I already seen this question, not simple as that. I'm doing some experimentations, with convertion to PLY files, I will add some details soon $\endgroup$ – snoob dogg Sep 23 '17 at 11:37
  • $\begingroup$ You are right, looks like Blender's importer does not support those RGB values in OBJ format. It would be nice topic for a custom addon :) I am sure you are on the right path - just find an utility which can work with this extended OBJ format and export it to other format supporting VCOL which Blender can work with. Then you should see it in Solid shading and VCOLs should be listed in Object Data -> Vertex Colors. $\endgroup$ – Jan Kadeřábek Sep 23 '17 at 12:24
  • $\begingroup$ @JanKadeřábek yes, I will probably do a script at least for convert that greentoken ply file I think its possible, the header needs to be modifed and three last float value needs to be UCHAR between 0 255 $\endgroup$ – snoob dogg Sep 23 '17 at 12:44
  • $\begingroup$ Use Meshlab to convert the mesh to PLY format. I never tried the sites you mentioned, but I'm sure that with Meshlab teh colour will be preserved. $\endgroup$ – Carlo Sep 23 '17 at 13:15
  • 1
    $\begingroup$ @Carlo Ok I wil have a look to this one : ) $\endgroup$ – snoob dogg Sep 23 '17 at 13:21
5
$\begingroup$

As others stated, the OBJ format specification officially does not have the ability to contain any vertex color information, but some apps extend the format to support this feature (RGB values are appended after vertex position values).

I managed to modify the Blender's OBJ importer to import & assign vertex colors as well.

Caution - the current implementation is really dirty at this moment (I am going to dig into the code more in the future), also I have not tested it properly so some bugs can occur.

DOWNLOAD / HOW TO USE

To try the modified importer, download the latest version of the import_obj.py script from my GitHub repo and replace the original one located in blender\2.x\scripts\addons\io_scene_obj (make a backup of the previous one, of course).

Then just cross all your fingers and try importing an OBJ model. To see vertex colors clearly, create & assign a new material to the object, set it Shadeless and enable Vertex Color Paint in Options. Then just set the 3D view shading to Material (as in the gif below).

This is an example of an OBJ model exported from http://www.cs.nott.ac.uk/~psxasj/3dme/index.php and imported using the modified importer:

enter image description here Please let me know whether it works for you!

$\endgroup$
  • $\begingroup$ Works perfectly ! thanks ! But please... use the face of someone else the next time ;) $\endgroup$ – snoob dogg Sep 24 '17 at 3:24
  • 2
    $\begingroup$ Face changed, let me know if my post is correct now :) $\endgroup$ – Jan Kadeřábek Sep 24 '17 at 3:26
  • $\begingroup$ @JanKadeřábek: do you possibly have some advice on how to do this in blender 2.8 ? In 2.79 your solution works nicely, thanks! $\endgroup$ – Quit007 Jul 16 at 21:46
  • $\begingroup$ @Quit007 I am sorry, I don't use 2.8, I even don't need to work with OBJ format anymore, so I am not sure. If I have some time, I will look at it, but can't promise it at this moment. $\endgroup$ – Jan Kadeřábek Jul 17 at 9:39
  • $\begingroup$ what about the other way around? say we have a texuture uv mapped blend file, how do we get the vertex RGB color for all the vertices? $\endgroup$ – June Wang Sep 24 at 13:00
1
$\begingroup$

Thanks to Carlo's comment. Meshlab did it ! I just had to import the OBJ mesh and export it as PLY. Then, I import the mesh in Blender, add a material and just check Vertex Color Paint in option for blender internal rendering. Works like a charm :)

$\endgroup$

protected by Community Aug 7 at 20:48

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.