Hi,
I´m a bit lost about how to correctly use the RT ShaderSystem in practice. The
wiki page still lacks some important bits, the sample browser does not reuse the RT ShaderSystem at all and trilobytes description of his approach here did not help either.
My problem is that I have a world of objects which is restarted several times which includes creation and destruction of entities and their materials. While everything runs fine on the first run restarting leads to the first frame showing blank materials for all objects and on the following frames unshaded (default textured) materials.
The initialisation works fine as I can see on the first run. My problem is how to remove certain materials (of destroyed objects/materials). Currently I do the following on world destruciton:
Code: Select all
(... go through all objects and remove them ...)
// remove the viewport
mFramework->getRenderWnd()->removeViewport(mViewport->getZOrder());
// remove all shader based techniques here to avoid referencing issues of materials
// which were already deleted
mFramework->getShaderGenerator()->removeAllShaderBasedTechniques();
mFramework->getShaderGenerator()->removeSceneManager(mSceneMgr);
// destroy our ogre scene manager
mFramework->getRoot()->destroySceneManager(mSceneMgr);
Although "removeAllShaderBasedTechniques()" is already a wooden hammer at least I hoped that would avoid the crashes I encountered so far when the RTShaderSystem tried to access already deleted materials. But now I run into the problem described above. When I recreate the world the materials are white and then unshaded.
I receive no useful log entries about these problem.
My initialisation of the world looks like this:
Code: Select all
// create our scene manager, camera etc.
mSceneMgr = mFramework->getRoot()->createSceneManager(ST_GENERIC, "SceneManager");
// create our world camera and set its initial position/orientation/FOV
mCamera = mSceneMgr->createCamera("Camera");
// set our camera as "fullscreen" viewport with zOrder 0
mViewport = mFramework->getRenderWnd()->addViewport(mCamera);
// add our scene manager as shader material target and change scheme to RTShaderLib scheme
mFramework->getShaderGenerator()->addSceneManager(mSceneMgr);
mViewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
How can I dynamically create and delete materials with the RTShaderSystem robustly in a scenario like above?
xad