I'm trying to render the depth buffer using a RTT then pass it to compositor then render a full screen quad.
but I don't get any depth texture at all
here is my code
CODE: SELECT ALL
// Create the depth render texture
Ogre::TexturePtr depthTexture = Ogre::TextureManager::getSingleton().createManual(
"DepthMap", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, mOgreCamera->getViewport()->getActualWidth(), mOgreCamera->getViewport()->getActualHeight(),
0, Ogre::PF_FLOAT16_R, Ogre::TU_RENDERTARGET);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("Ogre/Compositor/SSAO");
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("DepthMap");
// material->getTechnique(0)->getPass(0)->setVertexProgram( "SSAO_vs" );
// material->getTechnique(0)->getPass(0)->setFragmentProgram( "SSAO_fs" );
//material->load();
Ogre::RenderTexture* renderTexture = depthTexture->getBuffer()->getRenderTarget();
renderTexture->addViewport(mOgreCamera);
renderTexture->getViewport(0)->setClearEveryFrame(true);
renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue( 0.8f, 0.8f, 0.8f ));
renderTexture->getViewport(0)->setOverlaysEnabled(false);
and that's the compositor
CODE: SELECT ALL
compositor DepthMap
{
technique
{
// Temporary textures
texture rt0 target_width target_height PF_A8R8G8B8
target rt0
{
// Render output from previous compositor (or original scene)
input previous
}
target_output
{
// Start with clear output
input none
// Draw a fullscreen quad with the black and white image
pass render_quad
{
// Renders a fullscreen quad with a material
material Ogre/Compositor/SSAO
input 0 rt0
}
}
}
}
↧