I rewrote the listener as follows:
Code: Select all
#include "SSAOListener.h"
SSAOListener::SSAOListener(void)
{
}
void SSAOListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if (pass_id != 42) // not SSAO, return
return;
// this is the camera you're using
Ogre::Camera *cam = MainClass::getSingleton().m_Camera;
// calculate the far-top-right corner in view-space
Ogre::Vector3 farCorner = cam->getViewMatrix(true) * cam->getWorldSpaceCorners()[4];
// get the pass
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
// get the vertex shader parameters
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
// set the camera's far-top-right corner
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
// get the fragment shader parameters
params = pass->getFragmentProgramParameters();
// set the projection matrix we need
static const Ogre::Matrix4 CLIP_SPACE_TO_IMAGE_SPACE(
0.5, 0, 0, 0.5,
0, -0.5, 0, 0.5,
0, 0, 1, 0,
0, 0, 0, 1);
if (params->_findNamedConstantDefinition("ptMat"))
params->setNamedConstant("ptMat", CLIP_SPACE_TO_IMAGE_SPACE * cam->getProjectionMatrixWithRSDepth());
if (params->_findNamedConstantDefinition("far"))
params->setNamedConstant("far", cam->getFarClipDistance());
}
It is called!
I use the ogremax exporter and the dotscene loader, i did the models in 3dsmax,
they are ~1m. 1 unit in ogre is 1 meter or not? What camera setup should be used?
my clip calues are going from 1 to 5000, i need this high value because of the caelum clouds.
I integrated your great work as follows:
1. ) Added this code:
Code: Select all
ssao = Ogre::CompositorManager::getSingleton().addCompositor(MainClass::getSingleton().m_Camera->getViewport(), "ssao");
ssao->setEnabled(true);
SSAOListener *ssaol = new SSAOListener();
ssao->addListener(ssaol);
2. ) Added the above listener code
3. ) copied the files of the media folder of the demo into my ressource folder
4. ) I added this line to my rendering loop
Code: Select all
m_Root->getRenderSystem()->clearFrameBuffer(Ogre::FBT_COLOUR | Ogre::FBT_DEPTH);
5. ) I added this line to my rendering loop
I played with the zd value in the shader code, the results are getting better as at the picture above,
but it looks not as 1% of your demo!
If you allow me to, i would try to integrate this into my school project, its a kind of "virtual school 3d chat"
thanks for helping,
christian