Twinklebear / tobj

Tiny OBJ Loader in Rust
MIT License
233 stars 47 forks source link

Fix normal map parsing in MTL files #25

Closed azymohliad closed 4 years ago

azymohliad commented 4 years ago

Hello. So it seems tobj parses paths to normal maps incorrectly.

According to wiki and MTL specification, map_Ns is related to specular highlights, not a normal map. And normal map is bump by specs, plus wiki says that many implementations use map_bump and blender exports map_Bump. I checked this part in obj crate implementation and it also checks for these three: bump, map_bump and map_Bump.

And Ns probably needs another field in Material structure, not sure about the name. I don't touch it here.

Twinklebear commented 4 years ago

Thanks @azymohliad ! Yeah the Ns/map_NS parameters are for the "shininess" term in the Blinn-Phong material model for OBJ. I'll add that later to the material as a new Ns/map_Ns parameter since I mixed up the names here it looks like.