[osg-users] osg::Light Simple Question ?

Gordon Tomlinson gordon.tomlinson at sensor.com
Sat Jul 19 06:19:47 PDT 2008


 
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: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] 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 <jean-sebastien.guay at cm-labs.com>:


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    jean-sebastien.guay at cm-labs.com
                              http://www.cm-labs.com/

                       http://whitestar02.webhop.org/ 

_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080719/75d0c7ad/attachment-0003.htm>


More information about the osg-users mailing list