Re: [osg-users] specular highlight with SEPARATE_SPECULAR_COLOR

2007-10-23 Thread David Callu
Hi Riccardo

Linux Fedora 7
OSG 2.2
NVidia GeForce 8800


All work fine for me.
I just do osglight_modified cow.osg

I join the osglight_modified.cpp simplified and updated to OSG2.2.

Many bug has be fix and feature added since the OSG 1.2 Version.
Perhaps an update to OSG 2.2 will be a good choice for you.

HTH
David



2007/10/23, Riccardo Corsi [EMAIL PROTECTED]:

 Hi all,

 I'm try to get a specular highlights effect by using the
 osg::LightModel::SEPARATE_SPECULAR_COLOR mode.

 If I got it straight, this should compute a second color for the
 specular component to be added after lighting and texturing.
 So for instance, by using a light with white specular component and on a
 material with white specular color, I'd expect a white highlight in the
 final result. Instead what I get is the highlight modulated by the
 texture, as if I were using osg::LightModel::SINGLE_COLOR mode.

 Any suggestion on where I might be wrong?

 Find attached a modified osgLight example to reproduce the problem with
 a sample model.
 I basically removed the model animation, set a white specular on the
 light number 2, and added these lines of code:

 osg::StateSet* pSS = rootnode-getOrCreateStateSet();
 // set separate specular color
 osg::LightModel* pLightModel =new osg::LightModel;
 pLightModel-setLocalViewer(true);
 pLightModel-setColorControl(osg::LightModel::SEPARATE_SPECULAR_COLOR);
 pSS-setAttributeAndModes(pLightModel, osg::StateAttribute::ON
 |osg::StateAttribute::OVERRIDE);

 I'm on
 osg 1.2
 WinXP
 nVidia 7900 GTX (tried both older and latest drivers)

 Thank you
 Ricky



 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] specular highlight with SEPARATE_SPECULAR_COLOR

2007-10-23 Thread David Callu
oups forget the file :-)

2007/10/23, David Callu [EMAIL PROTECTED]:

 Hi Riccardo

 Linux Fedora 7
 OSG 2.2
 NVidia GeForce 8800


 All work fine for me.
 I just do osglight_modified cow.osg

 I join the osglight_modified.cpp simplified and updated to OSG2.2 .

 Many bug has be fix and feature added since the OSG 1.2 Version.
 Perhaps an update to OSG 2.2 will be a good choice for you.

 HTH
 David



 2007/10/23, Riccardo Corsi  [EMAIL PROTECTED]:
 
  Hi all,
 
  I'm try to get a specular highlights effect by using the
  osg::LightModel::SEPARATE_SPECULAR_COLOR mode.
 
  If I got it straight, this should compute a second color for the
  specular component to be added after lighting and texturing.
  So for instance, by using a light with white specular component and on a
  material with white specular color, I'd expect a white highlight in the
  final result. Instead what I get is the highlight modulated by the
  texture, as if I were using osg::LightModel::SINGLE_COLOR mode.
 
  Any suggestion on where I might be wrong?
 
  Find attached a modified osgLight example to reproduce the problem with
  a sample model.
  I basically removed the model animation, set a white specular on the
  light number 2, and added these lines of code:
 
  osg::StateSet* pSS = rootnode-getOrCreateStateSet();
  // set separate specular color
  osg::LightModel* pLightModel =new osg::LightModel;
  pLightModel-setLocalViewer(true);
  pLightModel-setColorControl(osg::LightModel::SEPARATE_SPECULAR_COLOR);
  pSS-setAttributeAndModes(pLightModel, osg::StateAttribute::ON
  |osg::StateAttribute::OVERRIDE);
 
  I'm on
  osg 1.2
  WinXP
  nVidia 7900 GTX (tried both older and latest drivers)
 
  Thank you
  Ricky
 
 
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 

#include osgViewer/Viewer

#include osg/Group
#include osg/Node

#include osg/Material
#include osg/Light
#include osg/LightSource
#include osg/StateAttribute
#include osg/Geometry
#include osg/Point

#include osg/MatrixTransform
#include osg/PositionAttitudeTransform

#include osgDB/Registry
#include osgDB/ReadFile

#include osgUtil/Optimizer
#include osgUtil/SmoothingVisitor

#include osgViewer/ViewerEventHandlers

#include osgGA/TrackballManipulator
#include osgGA/StateSetManipulator


#include iostream

// rigky
#include osg/LightModel






osg::Node* createLights(osg::StateSet* rootStateSet)
{
osg::Group* lightGroup = new osg::Group;


// create a spot light.
osg::Light* myLight1 = new osg::Light;
myLight1-setLightNum(0);
myLight1-setPosition(osg::Vec4(10.0f, 10.0f, 10.0f, 1.0f));
myLight1-setAmbient(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
myLight1-setDiffuse(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
myLight1-setSpecular(osg::Vec4(1.0f,1.0f,1.0f,1.0f));

//myLight1-setSpotCutoff(20.0f);
//myLight1-setSpotExponent(50.0f);
myLight1-setDirection(osg::Vec3(-1.0f,-1.0f,-1.0f));

osg::LightSource* lightS1 = new osg::LightSource;
lightS1-setLight(myLight1);
lightS1-setLocalStateSetModes(osg::StateAttribute::ON); 
lightS1-setStateSetModes(*rootStateSet,osg::StateAttribute::ON);

lightGroup-addChild(lightS1);


// create marker for point light.
osg::Geometry* marker = new osg::Geometry;
osg::Vec3Array* vertices = new osg::Vec3Array;
vertices-push_back(osg::Vec3(0.0,0.0,0.0));
marker-setVertexArray(vertices);
marker-addPrimitiveSet(new osg::DrawArrays(GL_POINTS,0,1));

osg::StateSet* stateset = new osg::StateSet;
osg::Point* point = new osg::Point;
point-setSize(4.0f);
stateset-setAttribute(point);

marker-setStateSet(stateset);

osg::Geode* markerGeode = new osg::Geode;
markerGeode-addDrawable(marker);

//lightGroup-addChild(markerGeode);

return lightGroup;
}


int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(argc,argv);

// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()-setDescription(arguments.getApplicationName()+ is the example which demonstrates use of OpenGL vertex lighting.);
arguments.getApplicationUsage()-setCommandLineUsage(arguments.getApplicationName()+ [options] filename ...);
arguments.getApplicationUsage()-addCommandLineOption(-h or --help,Display this information);

// construct the viewer.
osgViewer::Viewer viewer(arguments);

// set up the value with sensible default event handlers.
//viewer.setUpViewer(osgViewer::Viewer::STANDARD_SETTINGS);

// get details on keyboard and mouse bindings used by the viewer.
viewer.getUsage(*arguments.getApplicationUsage());

// if user request help write it out to cout.
if (arguments.read(-h) || arguments.read(--help))
{
   

Re: [osg-users] specular highlight with SEPARATE_SPECULAR_COLOR

2007-10-23 Thread Riccardo Corsi
Hi David,

thanks a lot for your suggestion. With the svn osg version everything
works fine!

Not finding anything in the archives I did guess that no bugs were around.
I'll switch to osg 2.x as soon as Delta3D guys finish the porting to the
new osg.

Thanks,
Ricky

David Callu wrote:
 oups forget the file :-)

 2007/10/23, David Callu [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]:

 Hi Riccardo

 Linux Fedora 7
 OSG 2.2
 NVidia GeForce 8800


 All work fine for me.
 I just do osglight_modified cow.osg

 I join the osglight_modified.cpp simplified and updated to OSG2.2 .

 Many bug has be fix and feature added since the OSG 1.2 Version.
 Perhaps an update to OSG 2.2 will be a good choice for you.

 HTH
 David



 2007/10/23, Riccardo Corsi  [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]:

 Hi all,

 I'm try to get a specular highlights effect by using the
 osg::LightModel::SEPARATE_SPECULAR_COLOR mode.

 If I got it straight, this should compute a second color for the
 specular component to be added after lighting and texturing.
 So for instance, by using a light with white specular
 component and on a
 material with white specular color, I'd expect a white
 highlight in the
 final result. Instead what I get is the highlight modulated by
 the
 texture, as if I were using osg::LightModel::SINGLE_COLOR mode.

 Any suggestion on where I might be wrong?

 Find attached a modified osgLight example to reproduce the
 problem with
 a sample model.
 I basically removed the model animation, set a white specular
 on the
 light number 2, and added these lines of code:

 osg::StateSet* pSS = rootnode-getOrCreateStateSet();
 // set separate specular color
 osg::LightModel* pLightModel =new osg::LightModel;
 pLightModel-setLocalViewer(true);
 
 pLightModel-setColorControl(osg::LightModel::SEPARATE_SPECULAR_COLOR);
 pSS-setAttributeAndModes(pLightModel, osg::StateAttribute::ON
 |osg::StateAttribute::OVERRIDE);

 I'm on
 osg 1.2
 WinXP
 nVidia 7900 GTX (tried both older and latest drivers)

 Thank you
 Ricky



 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 mailto:osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




 

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org