Operating System: Windows 10
Render System: GL
Hi,
Using the example in the following link (http://wiki.ogre3d.org/Intermediate+Tutorial+7), I managed to use the RTT to create a minimap. There is a strange issue however that I don't know what's causing it. Simplifying the scene to explain the problem - I have a flat floor, with an object on it at about (0, 17, 0). In the scene, there is a spotlight at (0, 350, 0). In the main camera and viewport, the scene is lit, the object has a shadow, but in the RTT camera view, the scene is much darker. When the object at (0, 17, 0) is moved from that point, the RTT viewport becomes fully lit like the main viewport is. Why is the position of the object affecting the lighting of the RTT viewport? In addition, in more complex scenes, when any object intersects with 0 in the x and z directions the same problem occurs. I should add that the object in question has a radius of only about 5.
Here is the relevant code for the creation of the light:
Code: Select all
light.reset(sceneManager->createLight(lightName));
light->setDiffuseColour(Ogre::ColourValue::White);
light->setSpecularColour(Ogre::ColourValue::White);
light->setType(Ogre::Light::LT_SPOTLIGHT);
lightNode.reset(sceneManager->getRootSceneNode()->createChildSceneNode());
lightNode->attachObject(light.get());
lightNode->setDirection(0, -1, 0);
lightNode->setPosition(Ogre::Vector3(0, 350, 0));
light->setCastShadows(true);
light->setSpotlightRange(Ogre::Degree(35), Ogre::Degree(50));
Code: Select all
cameraNode.reset(sceneManager->getRootSceneNode()->createChildSceneNode());
cameraNode->setPosition(cameraPos);
camera = sceneManager->createCamera("MiniMapCamera");
camera->setNearClipDistance(1);
camera->setFarClipDistance(5000);
cameraNode->attachObject(camera);
texPtr = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, window->getWidth(), window->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET);
renderTexture = texPtr->getBuffer()->getRenderTarget();
renderTexture->addListener(this);
viewport = renderTexture->addViewport(camera);
viewport->setClearEveryFrame(true);
viewport->setBackgroundColour(Ogre::ColourValue::Black);
viewport->setOverlaysEnabled(false);
viewport->setShadowsEnabled(false);
rect = new Ogre::Rectangle2D(true);
rect->setCorners(-0.25f, 0.975f, 0.25f, 0.475f);
rect->setBoundingBox(Ogre::AxisAlignedBox::BOX_INFINITE);
textureNode = sceneManager->getRootSceneNode()->createChildSceneNode();
textureNode->attachObject(rect);
Ogre::MaterialPtr matPtr = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
matPtr->getTechnique(0)->getPass(0)->setLightingEnabled(false);
matPtr->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
rect->setMaterial(matPtr);