Wrong model color with texture from .obj + .mtl

When I try to add to scene model with a texture that is loaded with OBJLoader2 and MTLLoader the model color is wrong (100% black).

.mtl file looks like this

newmtl lambert2SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd elf_flame_colorTest.jpg
Ni 1.00

if I change
Kd 0.00 0.00 0.00
Kd 1.00 1.00 1.00
or delete this line the model looks perfectly fine, with all textures.

Is this an error because model cant have texture and color at the same time (if yes, is there an option to ignore color if texture applied?) or other parameters from .mtl should fix this but currently ignored? Or specific material should be used?


see OBJLoader + MTLLoader not loading texture image


I see.
What can go wrong if before I set Materials to OBJLoader2 I’ll loop over this materials object, check if a material has a map property and it’s a Texture and set Color(1,1,1) to these materials? I think that it will fix the problem with black models, but can it also cause new one?

No, I think that should work. Alternatively, you could also try to change the values in the MTL file.

1 Like