0

I'm working on three.js and I'm trying to import a .obj file with its corresponding mtl file. The textures the mtl file was referencing were .bmp so I tweaked the mtl file to point to all .dds files and converted all my assests to dds. Problem is that its just rendering white texture. I'm not sure its related but it said that PVRTC compressed textures are not supported. Here is the code I used for the obj/mtl loader:

var onProgress = function(xhr) {
  if (xhr.lengthComputable) {
    var percentComplete = xhr.loaded / xhr.total * 100;
    console.log(Math.round(percentComplete, 2) + '% downloaded');
  }
};
var onError = function(xhr) {};
THREE.Loader.Handlers.add(/\.dds$/i, new THREE.DDSLoader());
var loader = new THREE.OBJMTLLoader();
loader.load('assets/FirstPersonExampleMap.obj', 'assets/FirstPersonExampleMap.mtl', function(object) {
  object.position.y = 0;
  scene.add(object);
}, onProgress, onError);

And here is an example of my tweaked .mtl file:

newmtl assets/M_WhiteEditQuarter_M_WhiteEditQuarter
 map_Kd M_WhiteEditQuarter_M_WhiteEditQuarter_D.dds
 map_Ks M_WhiteEditQuarter_M_WhiteEditQuarter_S.dds
 bump M_WhiteEditQuarter_M_WhiteEditQuarter_N.dds
Mat
  • 7
  • 6
  • When my files were bmp, it was also rendering white... At some point before I tweaked the mtl file (the assets/M_WhiteEdit... part) it was rendering black – Mat Jun 05 '15 at 20:37
  • are your textures in assets? – gaitat Jun 05 '15 at 20:41
  • Yes, the textures are in the assets directory. Assets and the JS folder where I have all my code, are both the root directory ( but are separate from each other). – Mat Jun 05 '15 at 20:45

1 Answers1

1

The references to your textures in the .mtl directory should be with respect to where your html file is. So the .mtl should look like this:

newmtl M_WhiteEditQuarter_M_WhiteEditQuarter
    map_Kd assets/M_WhiteEditQuarter_M_WhiteEditQuarter_D.dds
    map_Ks assets/M_WhiteEditQuarter_M_WhiteEditQuarter_S.dds
    bump assets/M_WhiteEditQuarter_M_WhiteEditQuarter_N.dds

the newmtl is just a name so it does not have to prefixed with assets. The rest are actual paths to your textures.

Update 1

General comments: Your model is huge. That is one thing. The other is that you are using a lot of 1x1 textures. Why? There is a lot of delay caused by them. The third issue is that your textures are also very big. For your diffuse textures that is ok? but your normal maps do not have such detail to warrant the space they take.

Back to the issue

Looking at your bmp version; Your .obj and .mtl files need fixing. As I said newmtl is just a name so it does not have to be path prefixed. But there is an inconsistency between your .obj and .mtl files. In one file newmtl is path prefixed and in the other it is not. So when .obj loads it will never find the materials. So once I fixed that I got the textures to appear.

Also in one case an mtl definition FirstPersonExampleMap_FirstPersonExampleMap_PersistentLevel_SkySphereBlueprint_Sky Sphere mesh_MaterialInstanceDynamic_3 has spaces in it. I am not sure this is valid.

The tool I am using to see the changes is http://www.finalmesh.com/

Note: It seems that the is a big sphere around your world and also there are elements around your church that are actually white. I had to zoom in a lot until I got material to show.

https://i.stack.imgur.com/Z4iZT.jpg

https://i.stack.imgur.com/xhVUH.jpg

gaitat
  • 12,449
  • 4
  • 52
  • 76
  • Sorry, it didn't work... It was already finding the files before. I pushed my code on github if you want to take another look: https://github.com/mgavaudan/gacVR – Mat Jun 05 '15 at 22:25
  • can you also push the bmp files? – gaitat Jun 05 '15 at 22:32
  • No problem, I'm creating a new branch where I try to load the bmp files. It'll be up in three minutes – Mat Jun 05 '15 at 22:47
  • the two branches are up (dds and bmp) and both are rendering white models – Mat Jun 05 '15 at 23:53
  • updated my answer which Is still true after looking at your .obj and .mtl files. – gaitat Jun 06 '15 at 13:20
  • Thank you so much for noticing the discrepancy, it turns out that my lights were also way too strong and were making everything white... Furthermore the Unreal Engine exporter sucks and doesn't save the right textures... Thanks for your help though! If you have any other ideas as to how I could reduce the loading time for my page please let me know! – Mat Jun 09 '15 at 18:24