[osg-users] OBJ reader and Ns / shininess

Bradley Baker Searles bsearles at carsim.com
Fri Apr 8 12:39:06 PDT 2011


Hi David-

Thank you for your thoughtful reply.

The more I look at this, the more sure I am that the OBJ importer should not be scaling the Ns value into the OSG shininess. I've attached some screens with the (tiny) change I made, which behaves as you'd expect (unlike the scaling). When we run in fixed function the behavior is the same.

3DS Max allows you to set the lighting model, it defaults to Blinn, which isn't much different from Phong (what we use in our shaders, as well as (I think) what the fixed function mode uses).

So anyway, this line in src/osgPlugins/obj/ReaderWriterOBJ.cpp:


Code:

osg_material->setShininess(osg::Material::FRONT_AND_BACK,(material.Ns/1000.0f)*128.0f ); // note OBJ shiniess is 0..1000.




changed to this:


Code:

float shininess = (material.Ns < 128.0f) ? material.Ns : 128.0f;
osg_material->setShininess(osg::Material::FRONT_AND_BACK, shininess); // note OBJ shiniess is 0..1000, clamp.




And all is well. If no one objects I'll suggest this change get submitted into trunk.

I'm attaching a few files to illustrate the problem of converting an Ns value of 20 to a shininess of ~2.5.

Thanks-
Baker

P.S. Yeah, every place I've worked professionally has already had a Brad, so I just started going by my middle name, it's so much easier that way :) Sorry for the confusion.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38339#38339




Attachments: 
http://forum.openscenegraph.org//files/max_obj_shininess_173.jpg
http://forum.openscenegraph.org//files/max_obj_shininess_default_importer_214.jpg





More information about the osg-users mailing list