Devlog/Level Editor

OBJ Export: Material & Texture Fixes

Level Editor 1 min read
OBJ Export: Material & Texture Fixes

OBJ Export — Three Fixes

The MTL file only contained newmtl, Kd, Ka, Ks, Ns, d — no map_Kd line, so renderers that rely on it (Raylib, others) showed no texture. Fix: ExportObjOptions now carries a texture_paths map (texture name → absolute file path) and an optional copy_textures flag. In OnExportOBJ, the map is populated from g_projectSettings.textures before calling the exporter. ObjWriter stores a mat_to_tex map built at triangle-add time. write_mtl now emits map_Kd <path> for every material that has a resolved path. When copy_textures is true, the files are copied into a textures/ subfolder next to the OBJ and the MTL references them with a relative path.

Every texture previously produced three MTL entries: FLOOR_X, CEIL_X, WALL_X. A map with ten unique textures generated thirty material slots in Blender. The fix removes the prefix entirely — the material name is now the texture name itself. Floor, ceiling, and wall surfaces that share the same texture automatically share one MTL entry.

Get Level Editor Comment on itch.io Level Editor overview