the ShadowMap is not correct !

zhucde

03-02-2010 05:59:27

I use ETL(ETM has the same problem), i generate terrain shadow with follow code:



Ogre::ColourValue color(mSunLight->getDiffuseColour().r,mSunLight->getDiffuseColour().g,mSunLight->getDiffuseColour().b);
Ogre::Vector3 direction = mSunLight->getDirection();

direction.normalise();
if(direction.x == 0.0f && direction.z == 0.0f) return;
// calculate new lightmap
ET::ColourArray2D mArray (m_LightMapSize,m_LightMapSize, Ogre::ColourValue::White);
ET::generateLightMap(mArray, m_Terrain, direction,
color, mSceneMgr->getAmbientLight());
ET::generateShadowMap(mArray, m_Terrain, direction, mShadowColor );
ET::boxFilter(mArray, 2); //blur
m_LightMap->setColourArray(mArray);
m_LightMap->update();


the result is :
[attachment=1]裁剪.jpg[/attachment]

you see, the terrain's shadow is not correct, it won't farther than tree's shadow, tree's shadow generated by OGRE shadow technology,
correct is :
[attachment=0]裁剪3.jpg[/attachment]

what's wrong ? anybody help me?