There is a line with setting light techniques:
Code: Select all
scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
Using SHADOWTYPE_STENCIL_MODULATIVE (which has more or less ok results) creates on the back of the ninja some weird artifacts.
Would appreciate for any help and additional links for materials where I can get better understanding what is going on and how should I do these things (with lighting) in 1.10 version.
For reference I am giving setup() method content:
Code: Select all
// do not forget to call the base first
OgreBites::ApplicationContext::setup();
// get a pointer to the already created root
Ogre::Root* root = getRoot();
Ogre::SceneManager* scnMgr = root->createSceneManager(Ogre::ST_GENERIC);
// register our scene with the RTSS
Ogre::RTShader::ShaderGenerator* shadergen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
shadergen->addSceneManager(scnMgr);
// -- tutorial section start --
Ogre::SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Camera* cam = scnMgr->createCamera("myCam");
cam->setNearClipDistance(5); // specific to this sample
camNode->attachObject(cam);//
camNode->setPosition(200, 300, 300);
camNode->lookAt(Ogre::Vector3(0, 0, 0), Ogre::Node::TransformSpace::TS_WORLD);
Ogre::Viewport* vp = mWindow->addViewport(cam);
vp->setBackgroundColour(Ogre::ColourValue(0, 0, 0));
cam->setAspectRatio(
Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())
);
Ogre::Entity* ninjaEntity = scnMgr->createEntity("ninja.mesh");
ninjaEntity->setCastShadows(true);
scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninjaEntity);
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane(
"ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
1500, 1500, 20, 20,
true,
1, 5, 5,
Ogre::Vector3::UNIT_Z);
Ogre::Entity* groundEntity = scnMgr->createEntity("ground");
scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
groundEntity->setCastShadows(false);
groundEntity->setMaterialName("Examples/Rockwall");
scnMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
// TODO: this thing does not work for some reason:
// scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
// this one works but not as expected
scnMgr->setShadowTechnique(Ogre::ShadowTechnique::SHADOWTYPE_STENCIL_MODULATIVE);
Ogre::Light* spotLight = scnMgr->createLight("SpotLight");
spotLight->setDiffuseColour(0, 0, 1.0);
spotLight->setSpecularColour(0, 0, 1.0);
spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
spotLight->setDirection(-1, -1, 0);
spotLight->setPosition(Ogre::Vector3(200, 200, 0));
spotLight->setSpotlightRange(Ogre::Degree(35), Ogre::Degree(50));
Ogre::Light* directionalLight = scnMgr->createLight("DirectionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.4, 0, 0));
directionalLight->setSpecularColour(Ogre::ColourValue(.4, 0, 0));
directionalLight->setDirection(Ogre::Vector3(0, -1, 1));
Ogre::Light* pointLight = scnMgr->createLight("PointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setDiffuseColour(.3, .3, .3);
pointLight->setSpecularColour(.3, .3, .3);
pointLight->setPosition(Ogre::Vector3(0, 150, 250));