I always wondered, why the terrain sample is producing such nice shadows and I just don't get it running. Now I modified the sample just a tiny little bit - and it produces immediately similar errors as I have (see http://www.ogre3d.org/forums/viewtopic.php?f=2&t=68686).
To summarize the errors:
- Shadows only appear when viewing nearly exact the direction of the light.
- Shadows disappear, when closer to the geometry.
Look also at the attachement.
For this to reproduce, I modified the sample as follows:
- initialize with depth shadow mode
- directly after terrain creation, activate that shadow mode
to be exact:
Code: Select all
--- C:/dev/Ogre/ogre_src_v1-8-0RC1/Samples/Terrain/include/Terrain_1.8_Rc1.h Sa Feb 18 15:02:37 2012
+++ C:/dev/Ogre/ogre_src_v1-8-0RC1/Samples/Terrain/include/Terrain.h Sa Feb 18 15:02:38 2012
@@ -54,6 +54,7 @@
, mTerrainsImported(false)
{
+ this->mShadowMode = SHADOWS_DEPTH;
mInfo["Title"] = "Terrain";
mInfo["Description"] = "Demonstrates use of the terrain rendering plugin.";
mInfo["Thumbnail"] = "thumb_terrain.png";
@@ -744,7 +745,7 @@
mShadowsMenu->addItem("None");
mShadowsMenu->addItem("Colour Shadows");
mShadowsMenu->addItem("Depth Shadows");
- mShadowsMenu->selectItem(0); // no edit mode
+ mShadowsMenu->selectItem(2); // depth shadow mode
// a friendly reminder
StringVector names;
@@ -827,6 +828,7 @@
mTerrainGroup->freeTemporaryResources();
+ changeShadows();
// create a few entities on the terrain
Interestingly, when the call to changeShadows() is made after the other scene entities have been setup, meaning it will be the last instruction in setupContents(), everything is working as expected.
What is going on here? Can anybody confirm this behavior? How do you setup the terrain shadows, do you immediatly configure the terrain material profile (SM2Profile) to include shadows or after some specific time / calls / something else?