I just gave that a shot, but remembered I'd tried that before back when I was trying to manually render the shadows. It produces very glitchy results, especially now that I'm back to using automatic shadow code. Only part of the screen gets cleared, and you can see artifacts from the rendered shadow maps in it.
I'm 66% confident this is an automatic shadow code thing, as opposed to my own coding, so hopefully my workaround will suffice. I use the manual method to clear other textures and it works fine, just not on the surface that uses shadows.
Edit: Here's the code I used
Code: Select all
renderTexture_DSShadow->getViewport(0)->setClearEveryFrame(false);
...
m_pRoot->getRenderSystem()->_setViewport(renderTexture_DSShadow->getViewport(0)) ;
m_pRoot->getRenderSystem()->clearFrameBuffer(Ogre::FBT_COLOUR|Ogre::FBT_DEPTH, Ogre::ColourValue(1, 0, 0, 0));
renderTexture_DSShadow->update(true) ;
The red 1 was just a test to see if it was having an effect. I just realized the area cleared is only equal to the size of the shadow maps. So if shadow maps are 512x512, then only 512x512 of the screen gets cleared, and has shadow glitches on it. Not only that, but the area outside the "shadow map" range is cleared as usual, (0,0,0,1), even though automatic clearing is turned off.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.