shadow_receiver_vertex_program_ref in a material corrupts shadow behaviour for other materials

Description

Original reporter: BSer

If using a shadow_receiver_vertex_program_ref declaration in a material, the default shadows for other materials and objects will be rendered improperly, if they are rendered after said material.

The following forum post has some images of the problem: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63152&p=419521#p419521 [^]

This bug can be replicated in the terrain demo for 1.6.4, and maybe the terrain demo for 1.7.x as well. To replicate, add the code in the Additional Information section to the end of the createScene function in terrain.h.

Look around and you'll see an Ogre head, over a plane. Pay attention and you'll see a shadow of the Ogre head cast onto the plane, that is in the wrong place, scaled wrong and moves with camera rotation.

If the code for loading the terrain is commented out, this defect does not occur. In that case, the shadow is correctly cast onto the plane.

Conclusion based on this and other evidence: Using shadow_receiver_vertex_program_ref for shadows can corrupt the behavior of the shadow system for materials that are rendered afterward.
mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
mSceneMgr->setShadowColour(ColourValue(0.4,0.4,0.4));
mSceneMgr->setShadowFarDistance(200.0);
mSceneMgr->setShadowTextureSize(512);

Entity* e = mSceneMgr->createEntity("head", "ogrehead.mesh");
e->setRenderQueueGroup(RENDER_QUEUE_MAIN + 1);
SceneNode* Node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Node->attachObject(e);
Node->setPosition(50,50,50);

e = mSceneMgr->createEntity("plane", SceneManager:T_PLANE);
e->setMaterialName("Examples/BumpyMetal");
e->setRenderQueueGroup(RENDER_QUEUE_MAIN + 1);
e->setCastShadows(false);
Node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Node->attachObject(e);
Node->setOrientation(Quaternion(Ogre::Radian(-1.5707963268f), Vector3::UNIT_X));
Node->setPosition(50,10,50);

mCamera->setPosition(180, 100, 180);

Original Mantis Ticket: http://www.ogre3d.org/mantis/view.php?id=416

Environment

None

Assignee

Murat Sari

Reporter

Philip Allgaier

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure