|
本帖最后由 abc-osg 于 2014-8-22 16:21 编辑
//标识阴影接收对象
const int ReceivesShadowTraversalMask = 0x1;
//标识阴影投影对象
const int CastsShadowTraversalMask = 0x2;
mls = new osg:: LightSource();
mls->getLight()->setPosition(osg::Vec4(0,1,-0.5,0));
osg::Vec3 lightDir(0,1,-0.5);
lightDir.normalize();
mls->getLight()->setDirection(lightDir);
mls->getLight()->setAmbient(osg::Vec4(0.2,0.2,0.2,1.0));
mls->getLight()->setDiffuse(osg::Vec4(0.8,0.8,0.8,1.0));
mRoot->addChild(mls);
//创建一个阴影节点,并标识接收对象和投影对象
mShadowedScene = new osgShadow::ShadowedScene();
mShadowedScene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);
mShadowedScene->setCastsShadowTraversalMask(CastsShadowTraversalMask);
//pssm阴影初始化
osg::ref_ptr<osgShadow:: ParallelSplitShadowMap> psst = new osgShadow:: ParallelSplitShadowMap(0,3);
psst->setTextureResolution(1024);
psst->setPolygonOffset(osg::Vec2f(1.0,1.0));
mShadowedScene->setShadowTechnique(psst);
mShadowedScene->addChild(mls);
mShadowedScene->addChild(mRoot);//和上行顺序调整也不对
m_Root->addChild(mShadowedScene.get());//m_Root是场景根节点
模型都添加在mRoot下
出现如下画面:
问题在哪儿呀? |
-
|