|
用osgShadow::MinimalShadowMap的算法做的阴影效果,场景地形相对复杂,有3层纹理,第一层是本身的材质,第二层是colormap,第三层是lightmap,我的阴影设置在第四层,部分代码如下:
osg::ref_ptr<osgShadow::MinimalShadowMap> mShadowMap = new osgShadow::MinimalShadowMap();
mShadowMap->setShadowTextureUnit(3);
mShadowMap->setShadowVertexShader( NULL);
mShadowMap->setShadowFragmentShader( NULL );
mShadowMap->setMainVertexShader( NULL );
mShadowMap->setMainFragmentShader( NULL );
mShadowMap->setTextureSize( osg::Vec2s( 2048, 2048 ) );
mShadowMap->setLight(light.get());
float minLightMargin = 100.f;
float maxFarPlane =5000;
unsigned int texSize = 1024;
unsigned int baseTexUnit = 0;
unsigned int shadowTexUnit = 1;
mShadowMap->setMinLightMargin( minLightMargin );
mShadowMap->setMaxFarPlane( maxFarPlane );
mShadowMap->setShadowTextureCoordIndex( shadowTexUnit );
mShadowMap->setBaseTextureCoordIndex( baseTexUnit );
mShadowMap->setBaseTextureUnit( baseTexUnit );
运行之后阴影都是黑色的,很不自然,请各位大牛帮忙解答下,哪里出问题了? |
|