deferred shading without compositor?

Problems building or running the engine, queries about how to use features etc.
Post Reply
kuma
Kobold
Posts: 25
Joined: Sat May 17, 2014 6:35 am

deferred shading without compositor?

Post by kuma »

I'm trying to get a simpler type of deferred shading setup that does not use compositor.

A similar topic is discussed at http://www.ogre3d.org/forums/viewtopic.php?f=2&t=43085

So far I have my code like this.

One shader outputs Diffuse, Normal, Depth.
Then set scheme MRT on my material technique 0
Finally bind these to a multirendertarget as is shown in the MRT guide. (as follows)

Code: Select all

    Ogre::MaterialManager::getSingleton().initialise();
    Ogre::ResourceGroupManager::getSingleton().createResourceGroup("RTT");
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    Ogre::Camera* camera = OgreFramework::getSingletonPtr()->m_pSceneMgr->getCamera("PrimaryCam");
    Ogre::Viewport* vp = OgreFramework::getSingletonPtr()->m_pSceneMgr->getCamera("PrimaryCam")->getViewport();
    int DSWidth = vp->getActualWidth();
    int DSHeight = vp->getActualHeight();

    RTT_Texture_DfShTexture0 = Ogre::TextureManager::getSingleton().createManual("RttTex_DfShTexture0",
          "RTT", Ogre::TEX_TYPE_2D, DSWidth, DSHeight, 0, Ogre::PF_FLOAT16_RGB,
                Ogre::TU_RENDERTARGET);

    // init tex 2
    renderTexture_DfShTexture0 = RTT_Texture_DfShTexture0->getBuffer()->getRenderTarget();
    renderTexture_DfShTexture0->addViewport(camera);
    renderTexture_DfShTexture0->getViewport(0)->setClearEveryFrame(true, Ogre::FBT_COLOUR|Ogre::FBT_DEPTH);
    renderTexture_DfShTexture0->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
    renderTexture_DfShTexture0->getViewport(0)->setOverlaysEnabled(false);

    RTT_Mat_DfShTexture0 = Ogre::MaterialManager::getSingleton().create("RttMat_DfShTexture0", "RTT");
    RTT_Technique_DfShTexture0 = RTT_Mat_DfShTexture0->createTechnique();
    RTT_Technique_DfShTexture0->createPass();
    Ogre::TextureUnitState* tState_DfShTexture0 = RTT_Mat_DfShTexture0->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex_DfShTexture0");
    tState_DfShTexture0->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
    RTT_Mat_DfShTexture0->getTechnique(0)->getPass(0)->setLightingEnabled(false);
    RTT_Mat_DfShTexture0->getTechnique(0)->getPass(0)->setTextureFiltering(Ogre::TFO_NONE);

    RTT_Texture_DfShTexture1 = Ogre::TextureManager::getSingleton().createManual("RttTex_DfShTexture1",
          "RTT", Ogre::TEX_TYPE_2D, DSWidth, DSHeight, 0, Ogre::PF_FLOAT16_RGB,
                Ogre::TU_RENDERTARGET);

    renderTexture_DfShTexture1 = RTT_Texture_DfShTexture1->getBuffer()->getRenderTarget();
    renderTexture_DfShTexture1->addViewport(camera);
    renderTexture_DfShTexture1->getViewport(0)->setClearEveryFrame(true, Ogre::FBT_COLOUR|Ogre::FBT_DEPTH);
    renderTexture_DfShTexture1->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
    renderTexture_DfShTexture1->getViewport(0)->setOverlaysEnabled(false);

    RTT_Mat_DfShTexture1 = Ogre::MaterialManager::getSingleton().create("RttMat_DfShTexture1", "RTT");
    renderTexture_DfShTexture0->setAutoUpdated(false);
    renderTexture_DfShTexture1->setAutoUpdated(false);

    m_mrttex->bindSurface(0, renderTexture_DfShTexture0);
    m_mrttex->bindSurface(1, renderTexture_DfShTexture1);

    m_mrttex->setAutoUpdated(true);
    m_viewmrt = m_mrttex->addViewport(camera);
    m_viewmrt->setMaterialScheme("MRT");
    m_viewmrt->setClearEveryFrame(true);
    m_viewmrt->setOverlaysEnabled(false);
    m_viewmrt->setSkiesEnabled(false);
    m_viewmrt->setBackgroundColour(Ogre::ColourValue(0,0,0,0));

    OgreFramework::getSingletonPtr()->m_pViewport = m_viewmrt;
Now. I'm super confused what to do next? :shock: How do I render this MRT back into the final fragment shader?
Can I send it to the second pass of the same material?

Essenitially I am attempting to do the same as the below glsl tutorial.
http://www.codinglabs.net/tutorial_simp ... ering.aspx
kuma
Kobold
Posts: 25
Joined: Sat May 17, 2014 6:35 am

Re: deferred shading without compositor?

Post by kuma »

Shameless bump. still stuck... :(
Post Reply