My goal yesterday was to implement basic lighting and shadows. Knowing ogres uses( i am happy):
- 4 shadow types
Code: Select all
SHADOWTYPE_TEXTURE_MODULATIVE
SHADOWTYPE_TEXTURE_ADDITIVE
SHADOWTYPE_STENCIL_MODULATIVE
SHADOWTYPE_STENCIL_ADDITIVE
Code: Select all
DIRECTIONAL
POINT
SPOTLIGHT
- a Heightmap
- Entities(player model, world objects) directly attached to sceneNode.
- Static geometry for nature objects(trees for now)
- Water plane with Ocean Shader(from ogre's demo)
- Skyplane
- SkySphere
After my issues arrived i went looking for more information in the manual and on the forum.
Issues i met:
- Flickering shadows due to ocean.
- Black heightmap
- Shadows not cast by static geometry
- Shadows moving thru objects (showing multiple shadow)
- With addtive shadows a black area.
This brought me to the shadow demo. after examening it i came to the conclusion of using SHADOWTYPE_TEXTURE_MODULATIVE in combination with a SPOTLIGHT. And this i tried resulting in the following picture:
Problem: Tree is not casting a shadow, neither is teh player model, some Black shadow line is crossing the screen, can't find out where it is comming from ?
Code used for this:
Code: Select all
// settings on
mSceneMgr->setShowDebugShadows(true);
mSceneMgr->setShadowTextureSelfShadow(true);
// SHADOW
sceneMgrTerrain->setShadowColour(Ogre::ColourValue(0.1, 0.1, 0.1));
sceneMgrTerrain->setShadowTextureSettings(512, 2);
sceneMgrTerrain->setShadowTechnique( SHADOWTYPE_TEXTURE_MODULATIVE );
sceneMgrTerrain->setShadowFarDistance( 200 );
// LIGHT
Ogre::Light* light = sceneMgrTerrain->createLight( "ABCDLIGHT" );
light->setType( Ogre::Light::LT_SPOTLIGHT );
light->setCastShadows( true );
light->setPosition( 175, 400, 175);
light->setDirection( Ogre::Vector3::NEGATIVE_UNIT_Z );
light->setDiffuseColour( 1, 1, 1 );
light->setSpecularColour( 1, 1, 1 );
light->setAttenuation(8000, 1, 0.5005, 0);
light->setSpotlightRange(Ogre::Degree(80), Ogre::Degree(90));
// Tree
Entity* ent5 = mSceneMgr->createEntity("PAlmTree1", "palm.mesh" );
ent5->setCastShadows(true);
ent5->setNormaliseNormals(true);
SceneNode* Node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("PalmtreeX");
Node2->attachObject(ent5);
Node2->translate(190, 65, 160);
// static geometry
sgNature->setCastShadows(true);
sgNature->build();
Can anybody help me?
Tell me what i'm doing wrong or a better way in accomplishing the task at hand.
Thank you