switching on shadows influences ambient light

Problems building or running the engine, queries about how to use features etc.
Lastmerlin
Halfling
Posts: 74
Joined: Sun Nov 11, 2007 4:43 pm
x 6

switching on shadows influences ambient light

Post by Lastmerlin »

My scene has three sources of light at the moment:
- ambient light (0.4,0.4,0.4)
- directional light (this is the sun)
- point light above the head of the hero (this illuminates the area around the hero)

When shadows are switched off, the quite bright ambient light is dominant.
This screenshot shows the scene without shadows:

Image

Now I insert these few lines, that activate shadows:

Code: Select all

		light = m_scene_manager->getLight("RegionLight");
		light->setCastShadows(true);
		m_scene_manager->setShadowTextureConfig(0,2048,2048,Ogre::PF_X8R8G8B8);
		m_scene_manager->setShadowColour( Ogre::ColourValue(0.5, 0.5, 0.5) );
		m_scene_manager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE);
The next screenshot shows what I get now:
Image

The shadows are nice, but the whole scene is much darker. The same effect shows up when I remove the ambient light instead of activating shadows. Thats why my guess is, that I have accidently switched off ambient light, but I have no clue why.

Perhaps you can tell me what happened here.

Thanks in advance :)
Lastmerlin
Halfling
Posts: 74
Joined: Sun Nov 11, 2007 4:43 pm
x 6

Re: switching on shadows influences ambient light

Post by Lastmerlin »

i have figured out, that only the ground tiles, which are the shadow receivers dont get any ambient light. If I set them to be shadow casters, then ambient light works form them as well. Unfortunately I have no shadow receivers und no shadows then.

The ground tiles are created in a loop like this:

Code: Select all

for (int i=0; i< dimx; ++i)
			{
				for (int j=0; j<dimy; ++j)
				{
					stream.str("");
					stream << "GroundNode"<<i<<"_"<<j;
					node = m_scene_manager->getRootSceneNode()->createChildSceneNode(stream.str());
					node->setPosition(Ogre::Vector3(i*200+100,0,j*200+100));

					stream.str("");
					stream << "GroundEntity"<<i<<"_"<<j;
					ground = m_scene_manager->createEntity(stream.str(), "ground");
					ground->setMaterialName(region->getGroundMaterial());
					ground->setCastShadows(true);
					ground->setQueryFlags(0);
					node->attachObject(ground);

					static_geom->addSceneNode(node);
				}
			}
The ground mesh is a simple rectangle created by this two lines:

Code: Select all

Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
	mesh_mgr.createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 200, 200, 5, 5, true, 1,1,1,Ogre::Vector3::UNIT_X);
perhaps these additional informations help.