[osg-users] OBJ reader and Ns / shininess
Bradley Baker Searles
bsearles at carsim.com
Thu Apr 7 08:49:16 PDT 2011
We have a fairly large array of legacy shapes that we're loading with our OSG application in the OBJ/MTL format, and I think the OSG reader may not be handling the shininess value correctly.
It has been noticed that the built-in OBJ exporter (v0.97b by guruware) in 3ds Max 2011 outputs its shininess value in its native range (0-100), and this value is then scaled (by a large amount) within the OSG OBJ reader. The reader is expecting the OBJ (well, actually the accompanying MTL file) to have an Ns (shininess) range of [0 ... 1000], so it scales the value to the [0 ... 128] range.
I think the OSG OBJ reader should just clamp the Ns value from [0 ... 128], since it's simply an exponent to the specular lighting equation.
I also think the OBJ exporter in Max should probably support the full [0 ... 1000] range of the OBJ format, and we've filed a support ticket with Autodesk, who have confirmed this as a bug (along with another weird behavior or two with the OBJ exporter).
The OBJ/MTL formats are old Wavefront technologies, and there does not appear to be a current definitive format specification. The best sources I've found are:
Material Library File (.mtl) specification from wotsit.org (an actual Alias|Wavefront document from 1995). Ns is simply called a specular exponent here. I haven't found further detail in other documents I've found:
The web page listed as a source in src/osgPlugins/obj/ReaderWriterOBJ.cpp (where the conversion takes place), which doesn't exist anymore, but can be dug up via the internet time machine. This page says Ns is *clamped* to [0 ... 128]:
http://replay.waybackmachine.org/20071214191634/http://java3d.j3d.org/utilities/loaders/obj/sun.html (time machine version from Dec 17th, 2007, nearest to the commit date of Dec 10th, for revision 7651 where the code was introduced)
If anyone is familiar with this issue, or could illuminate my thinking it would be greatly appreciated.
Read this topic online here:
More information about the osg-users