render depth buffer using compositor

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
andreahmed
Kobold
Posts: 34
Joined: Wed Dec 31, 2014 2:26 am

render depth buffer using compositor

Post by andreahmed » Tue Nov 21, 2017 3:07 pm

Hi All,
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
            }
        }
    }
}
0 x

andreahmed
Kobold
Posts: 34
Joined: Wed Dec 31, 2014 2:26 am

Re: render depth buffer using compositor

Post by andreahmed » Wed Nov 22, 2017 8:08 pm

please help me :(
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3455
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
Contact:

Re: render depth buffer using compositor

Post by dark_sylinc » Thu Nov 23, 2017 8:24 pm

Ogre 1.x doesn't support reading from the depth buffer.

However you can use PF_FLOAT16_R / PF_FLOAT32_R to render depth to the colour buffer.
If you do that, you need to write your own pixel shader that outputs depth to the colour buffer. Maybe there's a sample already doing it you can look at, but I don't know.
0 x

Post Reply