Hi,
I am trying to apply some shadows from the osgShadow library to the Sponza
scene from http://graphics.cs.williams.edu/data/meshes.xml and I was already
told at school, that I shouldn't really use any point lights, because their
omnidirectionality somehow messes up the shadow mapping techniques, so then I
allegedly have to try spotlights instead and be careful on where do I put them.
Still however, so far I haven't really been able to find the right settings
that would allow me to create shadows in this scene without any significant
glitches. Below I am posting my code and some screens hopefully showing some of
the worst of these glitches. Any ideas?
(SponzaScene is derived from ShadowedScene)
Code:
SponzaScene::SponzaScene()
{
// shadow setup
ref_ptr<SoftShadowMap> softShadowMap (new SoftShadowMap);
setShadowTechnique(softShadowMap.get());
// model scaling
Matrix sponzaScaleMatrix;
sponzaScaleMatrix.makeScale(2.5f, 2.5f, 2.5f);
ref_ptr<MatrixTransform> sponzaScaleXform (new MatrixTransform);
sponzaScaleXform->setMatrix(sponzaScaleMatrix);
addChild(sponzaScaleXform.get());
// model loading
ref_ptr<Node> sponzaNode = readNodeFile("sponza.osg");
if (!sponzaNode)
{ // nie je dostupny v nativnom formate, treba ho vytvorit
sponzaNode = readNodeFile("sponza\\sponza.obj");
writeNodeFile(*sponzaNode, "..\\res\\models\\sponza.osg");
}
sponzaScaleXform->addChild(sponzaNode.get());
// horizontal light position (so I can change it via callback if I wish
to)
Vec3 lightPosition(7.5f, 0.0f, 0.0f);
ref_ptr<PositionAttitudeTransform> lightPosXform (new
PositionAttitudeTransform);
lightPosXform->setPosition(lightPosition);
sponzaScaleXform->addChild(lightPosXform.get());
// light marker
ref_ptr<Geode> lightMarkerGeode (new Geode);
lightMarkerGeode->addDrawable(new ShapeDrawable(new Sphere(Vec3f( 0.0f,
0.0f, 10.0f), 0.2f)));
lightPosXform->addChild(lightMarkerGeode.get());
// state set
ref_ptr<StateSet> lightStateSet = getOrCreateStateSet();
// light setup - spotlight
ref_ptr<Light> light (new Light);
light->setLightNum(0);
light->setPosition(Vec4f(0.0f, 0.0f, 9.5f, 1.0f));
light->setAmbient(Vec4f(0.1f, 0.1f, 0.1f, 1.0f));
light->setDiffuse(Vec4f(0.9f, 0.9f, 0.9f, 1.0f));
light->setDirection(Vec3f(0.0f, 0.0f, -1.0f));
light->setSpotCutoff(75.0f);
light->setSpotExponent(0.0f);
ref_ptr<LightSource> lightSource (new LightSource);
lightSource->setLight(light.get());
lightSource->setLocalStateSetModes(StateAttribute::ON);
lightSource->setStateSetModes(*lightStateSet, StateAttribute::ON);
lightPosXform->addChild(lightSource.get());
}
[Image: http://i.imgur.com/4npO0LY.png ]
[Image: http://i.imgur.com/ob6QapJ.png ]
Also, at some point I will need to measure the rendering performance in a way,
that would let's say dump the average FPS rate of a 0.4s interval into a file
every said 0.4s for the duration of 20s or so while adjusting the position of
camera. Could somebody please give me at least a brief overview of what do I
need to do (and how) to achieve this functionality in OSG with osgViewer (if
possible)?
Thank you!
Cheers,
Martin[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52892#52892
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org