The reason you need GL_RESCALE_NORMAL is because you have scaled your
terrain. OpenGL by default does NOT scale normal on a scale matrix because
the act of rescale requires the use of sqr roots and this is expensive. when
you have a lot of them every frame ( see any good OpenGL book for details)
 
I would recommend that you create your terrain to the correct size and not
scale at run time,
 
 


  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ümit Uzun
Sent: Saturday, July 19, 2008 9:06 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] osg::Light Simple Question ?


Hi Jean,

Thanks for reply. You are right, my model hasn't normals :) So
"terrainScaleMAT->getOrCreateStateSet()->setMode( GL_RESCALE_NORMAL,
osg::StateAttribute::ON );" pattern doesn't work on terrain lightening. Like
your advice I can use osgUtil::SmoothingVisitor but I choose easier way
which is gathering model which has normals in it. So I use new model with
adding GL_RESCALE_NORMAL control and result is perfect like added
screenshot:)

I have a last question about why my model's lightening operation related
with normals rescaling process? I can't understand backgroud of this
command. 

Thanks for helps Jean and Gordon :)
Best Regards.

Ümit UZUN


2008/7/19 Jean-Sébastien Guay <[EMAIL PROTECTED]>:


Hello Ümit, 



I have tried "terrainScaleMAT->getOrCreateStateSet()->setMode(
GL_RESCALE_NORMAL, osg::StateAttribute::ON );" pattern but the result is
same. There is no light effect on the terrain. I don't understand why?



As Gordon said, check if your terrain has normals in the first place...
Rescaling non-existing normals won't do anything :-)

In your .osg file, check for normalArray under your Geometry, and check that
normalBinding is set to PER_VERTEX. If the model has no normals, you can
generate them with a modeling tool or use the osgUtil::SmoothingVisitor to
create smooth normals across the surface.

And BTW, yes you're right that the two suggestions I gave before were
mutually exclusive, i.e. if you checked your model and changed the TexEnv in
it you don't need a NodeVisitor to do the same thing...

Oh, just another little thing, are you sure you're reloading the .osg model
and not the original one without your changes? 


J-S
-- 
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                              http://www.cm-labs.com/

                       http://whitestar02.webhop.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

Reply via email to