The basic wavefront object file can omit or include many things. I am wondering if that is also true for the wavefront material file (.mtl). Available to me are:
However, I think all I need in my use case is the diffuse color. Is it possible to just specify this, and nothing else?
If not, what of those fields are required, and what are not?
It looks like when viewing the .OBJ and .MTL files in this tool: https://www.creators3d.com/online-viewer
That just having the diffuse color does indeed work. Nothing else is required.
IE, the following works:
newmtl 1
Kd 0.000000 0.000000 0.500000
newmtl 2
Kd 0.000000 0.000000 0.562500
newmtl 3
Kd 0.000000 0.000000 0.625000
As a sidenote for anyone who may have trouble with .mtl files in the future, if you want tools to read in the .mtl file correctly, you need to link it in by using something like this at the very top of the OBJ file:
mtllib mymtlfile.mtl
Otherwise, tools will not know where to look for the MTL file, even if it is in the same directory.
And in order to apply it, the keyword usemtl
must be used. Any faces following usemtl
will use that material, regardless of other divisions. If you want every face to have a different material, you would need to put usemtl [material number]
like usemtl 5
before each quad, tri, etc written out.