|
本帖最后由 abc-osg 于 2013-10-28 12:24 编辑
谁使用ParallelSplitShadowMap实现光照阴影过。我的不知道哪儿设置有问题实现不了
下面是代码
osg::ref_ptr<osgShadow:: ShadowedScene> mShadowedScene;
osg::ref_ptr<osg:: LightSource> mls;
mls = new osg:: LightSource();
mls->getLight()->setPosition(osg::Vec4(0,-1,1,0));//无穷远
osg::Vec3 lightDir(0,-1,1);
lightDir.normalize();
mls->getLight()->setDirection(lightDir);
mls->getLight()->setAmbient(osg::Vec4(1.0,0.8,1.1,0));
mls->getLight()->setDiffuse(osg::Vec4(1.0,1.0,0.8,1.0));
mRoot->addChild(mls);
//创建一个阴影节点,并标识接收对象和投影对象
mShadowedScene = new osgShadow::ShadowedScene();
mShadowedScene->setReceivesShadowTraversalMask( 0x1 );
mShadowedScene->setCastsShadowTraversalMask( 0x2 );
//pssm阴影初始化
osg::ref_ptr<osgShadow:: ParallelSplitShadowMap> psst = new osgShadow:: ParallelSplitShadowMap(0,3);
psst->setTextureResolution(1024);
mShadowedScene->setShadowTechnique(psst.get());
mShadowedScene->addChild(mRoot);
mViewer->setSceneData(mShadowedScene.get());//
显示只有光照,没有见阴影。 |
|