Search code examples
3dtexturesmeshlabmtl-file

Meshlab crashes when loading obj files with more than one png textures


I have an OBJ file along with a corresponding MTL and several PNG textures. I use meshlab to open it. This mesh file downloaded from free3d does not specify the texture PNG files in the MTL. So I added it on my own like this:

map_Kd [texture_file_name.png]

Since there are multiple textures, I added two lines of map_Kd in two different places. However, I found that if I only use one of the two (whichever) map_Kd commands, meshlab opens the file alright. But if I use two simultaneously, meshlab crashes on start-up.

I tried running it in terminal, it shows the following:

  • Correctly opened (only one map_Kd):
user@computer:~/data/Bikes2/obj_with_text/3/OBJ$ meshlab Sepeda\ Facific\ Invert.obj 
Qt: Session management error: Could not open network socket
Current Plugins Dir is: /snap/meshlab/36/usr/lib/meshlab/plugins 
Shader directory found '/snap/meshlab/36/usr/share/meshlab/shaders', and it contains 19 gdp files
Mesh is Polygonal!
libpng warning: iCCP: known incorrect sRGB profile
LOG: 0 Opened mesh Sepeda Facific Invert.obj in 519 msec
LOG: 0 All files opened in 521 msec
libpng warning: iCCP: known incorrect sRGB profile
  • Crashes on start-up (two map_Kd commands):
user@computer:~/data/Bikes2/obj_with_text/3/OBJ$ meshlab Sepeda\ Facific\ Invert.obj 
Qt: Session management error: Could not open network socket
Current Plugins Dir is: /snap/meshlab/36/usr/lib/meshlab/plugins 
Shader directory found '/snap/meshlab/36/usr/share/meshlab/shaders', and it contains 19 gdp files
Mesh is Polygonal!
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Segmentation fault (core dumped)

Does anyone know why? Is it a meshlab bug or am I doing something wrong?

I am using Ubuntu20.04 with Meshlab_64bit_fp v2020.12 installed from Ubuntu software center if it matters.


Update 1: Meshlab_64bit_fp v2020.03 on Windows 10 behaves the same.


Update 2:

To make it reproducible, I post my MTL file below. The two map_Kd commands I added are at line 184 (under newmtl col_rangka_wadah_perr) and the last line respectively.

# Blender MTL File: 'Sepeda Facific Invert.blend'
# Material Count: 29

newmtl Material
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.002
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.003
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.004
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.005
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.006
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.007
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl None
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.800000 0.800000 0.800000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl ban_luar.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.064007 0.064007 0.064007
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_ban
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_casing_hp
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_jari2
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_lantai
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_master_btl
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_pegangan_stank
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_pelek
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl col_rangka_per_sepeda
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2


newmtl col_rangka_wadah_perr
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
#map_Kd uv_rangka.png

newmtl col_uv_btl
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl dominan.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl gear.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl guma.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.301176 0.301176 0.301176
Ks 0.447059 0.447059 0.447059
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl skp_front_defaul.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.447059 0.447059 0.447059
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl steel_whiter.001
Ns 94.117647
Ka 1.000000 1.000000 1.000000
Kd 0.589804 0.589804 0.589804
Ks 0.447059 0.447059 0.447059
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl uv_ban_kanan
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl uv_ban_kiri
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl uv_hp
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl uv_pelek_kanan
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl uv_pelek_kiri
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd uv_pelek_kiri.png

Solution

  • Can confirm that this seems to be a bug in meshlab OBJ importer.

    I have managed a workaround using the batch meshlabserver program.

    1. I edited the mtl file to add several textures using map_Kd filename.png lines, same way that you did.
    2. Convert the file using the command line:

    meshlabserver -i Sepeda\ Facific\ Invert.obj -o fixed.obj -m wt

    and got a file which meshlab can load properly: enter image description here