SSAO Compositor

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
Praetorian
Google Summer of Code Student
Google Summer of Code Student
Posts: 171
Joined: Fri Aug 10, 2007 10:37 pm
Location: WA - USA
x 5

Re: SSAO Compositor

Post by Praetorian »

Just gave it a go, looks great. :)

I have a geforce 7600GS (512mb), and with OpenGL it failed completely (and I have fairly recent drivers (from December)), the relevent lines of the log file look to be:

Code: Select all

11:49:04: OGRE EXCEPTION(2:InvalidParametersException): All framebuffer formats with this texture internal format unsupported in GLFrameBufferObject::initialise at c:\Ogre_Shoggoth\RenderSystems\GL\src\OgreGLFrameBufferObject.cpp (line 276)
With D3D it worked fine, with the default resolution and 4x FSAA I got an average of 12fps (with the flashlight effect turned off), and with FSAA turned off I got 15-16. It's worth noting that the rest of my computer is ancient (P4 1.8ghz, 512mb RDRAM) and the 7600 is running in a 4x AGP slot. Also I just setup this computer for the internet and so if I turned off AVG and all the networking junk, things would probably run faster.
My Google summer of code 2011 topic: Unit Testing Framework
My Google summer of code thread
My Google summer of code wiki page
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8

Re: SSAO Compositor

Post by eugen »

7900GS doesnt work in openGL

Code: Select all

22:04:57: OGRE EXCEPTION(2:InvalidParametersException): All framebuffer formats with this texture internal format unsupported in GLFrameBufferObject::initialise at c:\Ogre_Shoggoth\RenderSystems\GL\src\OgreGLFrameBufferObject.cpp (line 276)
D3d works fine
User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Re: SSAO Compositor

Post by xadhoom »

Ouch on my notebook with QuadroFx 1500M occurs the same error:

Code: Select all

21:18:40: OGRE EXCEPTION(2:InvalidParametersException): All framebuffer formats with this texture internal format unsupported in GLFrameBufferObject::initialise at c:\Ogre_Shoggoth\RenderSystems\GL\src\OgreGLFrameBufferObject.cpp (line 276)
xad
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Seems like OpenGL doesn't like FLOAT16_RGBA (64-bit format). I'll look into it.
Praetorian wrote: With D3D it worked fine, with the default resolution and 4x FSAA I got an average of 12fps (with the flashlight effect turned off), and with FSAA turned off I got 15-16. It's worth noting that the rest of my computer is ancient (P4 1.8ghz, 512mb RDRAM) and the 7600 is running in a 4x AGP slot. Also I just setup this computer for the internet and so if I turned off AVG and all the networking junk, things would probably run faster.
Hey, that sounds pretty good for a 7600GS. I bet if there weren't so many batches of random objects all over the place, it'd be even faster :D
nortsen1 wrote:Hi

My card is a 4870x2
fps: 25-30
dirver: 9.1

Demo works fine.
Slightly worried about that, though... I get well in excess of 60 FPS on my 8800GTS, which is much weaker than a 4870x2...
broli
Halfling
Posts: 48
Joined: Fri Mar 31, 2006 5:08 pm

Re: SSAO Compositor

Post by broli »

Will you add SSGI to this compositor or separately? I think it would be wiser to put it in one shader as it's just a small addition rather than make a whole new compositor of it. And besides it would be very interesting to see SSGI with such colorful scenes :D.
voxel
Gnome
Posts: 334
Joined: Wed Aug 02, 2006 9:27 am
Location: Toronto, Canada

Re: SSAO Compositor

Post by voxel »

Works fine on a NV 7950GT.
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 220

Re: SSAO Compositor

Post by Jabberwocky »

Nice work, Null. It's great to have more example compositor code around, too.
Image
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany

Re: SSAO Compositor

Post by jjp »

Radeon 4850; about 50FPS with OpenGL, with D3D - depending on how the camera is positioned - between 60 and 100FPS.
Enough is never enough.
Taomorpheus
Gnoblar
Posts: 3
Joined: Sun Feb 15, 2009 7:39 pm

Re: SSAO Compositor

Post by Taomorpheus »

nullsquared wrote:
nortsen1 wrote:Hi

My card is a 4870x2
fps: 25-30
dirver: 9.1

Demo works fine.
Slightly worried about that, though... I get well in excess of 60 FPS on my 8800GTS, which is much weaker than a 4870x2...
I don't think that this test is completely true. Look at my bench, I got an higher framerate with a 4830hd and a single core with 1 gb of ram :P
User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China

Re: SSAO Compositor

Post by iloseall »

NV 8600GT,Vista System.
Work fine!
Window mode,1024*768;
shadowTextureRes = 256
shadowTextureCount = 4
FSAA=4;


OGL:
SSAO on : 27fps
SSAO off: 51fps
D3D:
SSAO on: 43fps
SSAO off: 110fps
nortsen1
Gnoblar
Posts: 2
Joined: Tue Dec 30, 2008 12:04 pm

Re: SSAO Compositor

Post by nortsen1 »

Taomorpheus wrote:
nullsquared wrote:
nortsen1 wrote:Hi

My card is a 4870x2
fps: 25-30
dirver: 9.1

Demo works fine.
Slightly worried about that, though... I get well in excess of 60 FPS on my 8800GTS, which is much weaker than a 4870x2...
I don't think that this test is completely true. Look at my bench, I got an higher framerate with a 4830hd and a single core with 1 gb of ram :P
I checked up some properties

At the latest resoult the gpu/memory clock was 507/500 mhz in window mode, this is the wrong feature of ati driver.
I adjusted to default clocks (750/900) with rivatuner and with the demo default settings was 32 fps.

Additional tests

OGL 1024x768:

FSAA=4, 32fps (?)
FSAA=0, 114fps
Fullscreen=1 FSAA=4, bad filckering screen (~8 fps)
fullscreen=1 FSAA=0, 114fps


D3D 1024x768:

FSAA=4, 120 fps
FSAA=0, 137 fps
fullscreen=1 FSAA=4, 120 fps
fullscreen=1 FSAA=0, 137 fps


OGL 1920x1200:

fullscreen=1 FSAA=0, 55 fps


D3D 1920x1200:

fullscreen=1 FSAA=4, 53 fps
fullscreen=1 FSAA=0, 62 fps


My system:
Phenom II 940BE
Shappire 4870x2 2GB
4GB RAM (1066)
Vista Business x64

Thx for sharing ssao compositor demo.

I hope i could help you.
User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm
x 3

Re: SSAO Compositor

Post by aguru »

Thanks very much for this, null. Its fun reading through your example code, the comments are a lot of help. Also I wanted to report that getting it to work on linux was a matter of minutes, so I think at least with a 8800gt this can be considered linux friendly :)
artn3r
Halfling
Posts: 72
Joined: Wed Jul 16, 2008 10:01 am

Re: SSAO Compositor

Post by artn3r »

Hello, i just integrated your SSAO in my project,
but it looks like this:

Image

Do you know whats going wrong? the sky is affected too,
its caelum system!

Thanks,
Regards, Christian
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

What unit scale are you using? Meaning, are you using 1unit = 1meter, or what? Also, did you add the SSAO listener? (check main.cpp, the CompositorInstance needs a listener)
artn3r
Halfling
Posts: 72
Joined: Wed Jul 16, 2008 10:01 am

Re: SSAO Compositor

Post by artn3r »

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

Code: Select all

 m_Window->swapBuffers();
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
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

artn3r wrote: 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.
Just out of curiosity, set your far clip distance to something like 1000 or even 100 (instead of 5000), tell me if it gets any better... I just want to see if this is the problem or not (probably isn't).
3. ) copied the files of the media folder of the demo into my ressource folder
You really only need ssao.compositor, ssao.material, and ssao.cg. Also, you need to make sure that all of your materials has a "geom" scheme and technique (like in data/diffuse.material). You can simply copy over all of the "geom" shaders from diffuse.cg, diffuse.material, and diffuse.program and add a "geom" scheme to your own materials.

Code: Select all

m_Root->getRenderSystem()->clearFrameBuffer(Ogre::FBT_COLOUR | Ogre::FBT_DEPTH);
5. ) I added this line to my rendering loop

Code: Select all

 m_Window->swapBuffers();
This is unnecessary, I just used them for the demo because I was rendering manually.
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!
First, make sure you have a "geom" scheme in all of your scene materials (see above). Second, open up your "geom" shader, and find the line

Code: Select all

OUT.c = float4(length(vp.xyz) / far, normalize(vn.xyz).xyz);
Change it to:

Code: Select all

float COEF = 1;
OUT.c = float4(length(vp.xyz) * COEF / far, normalize(vn.xyz).xyz);
Play with COEF, like 0.5, or 2, etc. You say your units are in meters, but your clip planes are at 1 and 5000 - are you sure they are in meters? Probably not. This is why you need the COEF above (don't play with the "zd" inside the SSAO itself, the above is more elegant).
If you allow me to, i would try to integrate this into my school project, its a kind of "virtual school 3d chat"
Of course, it'd be awesome to have this be useful in other projects :D
artn3r
Halfling
Posts: 72
Joined: Wed Jul 16, 2008 10:01 am

Re: SSAO Compositor

Post by artn3r »

Ok, thanks for the long and detailed answer,
i will try to implement you sugesstions as soon
as possible, and then i will post my results =)

Thank you!
Regard,
Christian
User avatar
Evak
Orc Shaman
Posts: 707
Joined: Sun Apr 02, 2006 7:51 pm
Location: Sacramento, CA
x 1

Re: SSAO Compositor

Post by Evak »

Seems to default to GL judging by the log, and won't run on my 7800GS. Don't know how to change to D3D since your app doesn't show any setup/options just loads a GL window and crashes.

Still it's cool someone made a compositor for SSAO, I has been on my wishlist for the past year or so, unfortunately being an artist with no coding skills meant I couldn't do it myself.Hopefully the probs will get ironed out soon. thanks for doing it and look forward to trying it in D3D when I figure out how :)
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: SSAO Compositor

Post by stealth977 »

Evak wrote:Seems to default to GL judging by the log, and won't run on my 7800GS. Don't know how to change to D3D since your app doesn't show any setup/options just loads a GL window and crashes.

Still it's cool someone made a compositor for SSAO, I has been on my wishlist for the past year or so, unfortunately being an artist with no coding skills meant I couldn't do it myself.Hopefully the probs will get ironed out soon. thanks for doing it and look forward to trying it in D3D when I figure out how :)
edit config.ini or something in the data folder :)
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Yeah, sorry, I kind of rushed it without any readme or anything. Just go to data/config.ini and change "OGL" to "D3D".
artn3r
Halfling
Posts: 72
Joined: Wed Jul 16, 2008 10:01 am

Re: SSAO Compositor

Post by artn3r »

Yeah i got it working now =)
I forgot to define the geom scheme,
thats all.

here are some screenshots:

http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO2.png SSAO off
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO1.png SSAO on
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO3.png SSAO on
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO4.png SSAO on

I will post this project in the showcase forum
when it's done! (virtual school 3d chat)

I have another question to you, nullsquared!
You released this great SSGI Demo here:
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=46794

Do you think about combining this into this compositor?
That would be great =)

Regards, Christian
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

artn3r wrote:Yeah i got it working now =)
I forgot to define the geom scheme,
thats all.

here are some screenshots:

http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO2.png SSAO off
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO1.png SSAO on
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO3.png SSAO on
http://www.artn3r.com/ogre/SHOWCASE/OGRESSAO4.png SSAO on
I'm glad you got it working, but it seems the radius is a bit too high. Find this line in ssao.cg:

Code: Select all

#define RADIUS 0.2125
float4 nuv = mul(ptMat, float4(viewPos.xyz + randomDir * RADIUS, 1));
And play with the RADIUS value - the SSAO looks rather 'off' as it is right now.
I have another question to you, nullsquared!
You released this great SSGI Demo here:
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=46794

Do you think about combining this into this compositor?
Well, it's a bit complicated. For "SSGI" you need to separate your lighting stages into direct lighting/shading, ambient lighting, and then SSAO + "SSGI." The problem, is that with a compositor, ambient lighting and direct lighting is all already completed. You would need to turn off ambient light for all of the materials, and then integrate it into the SSAO... I'm not too sure if I'll make an "SSGI" compositor, sorry. Maybe later in time.
jAyTeA
Kobold
Posts: 33
Joined: Mon Jan 01, 2007 3:26 pm

Re: SSAO Compositor

Post by jAyTeA »

I tested it on my Laptop with an old nvidia 7600 go, 1gb ram and amd turion 64 x2 (1.8ghz/core) and it ran with 4-5 fps... with disabled ssao I get about 20.
I have a multihead setup so i think a little bit of performence gets lost there.
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

jAyTeA wrote:I tested it on my Laptop with an old nvidia 7600 go, 1gb ram and amd turion 64 x2 (1.8ghz/core) and it ran with 4-5 fps... with disabled ssao I get about 20.
I have a multihead setup so i think a little bit of performence gets lost there.
Well I supposed that's not too bad considering it's a laptop card (and you have a multi-head setup). But then again, I don't know what you can compare this against, so it might be bad anyways. Did you try both D3D and OGL? (edit data/config.ini)

The thing about these post processes is that they require a lot of fillrate. On my 8800GTS, I get about 100FPS with the SSAO on. But the difference between the fillrate of a desktop 8800GTS and a 7600GO is immense.
jAyTeA
Kobold
Posts: 33
Joined: Mon Jan 01, 2007 3:26 pm

Re: SSAO Compositor

Post by jAyTeA »

yes, the difference is really big.
Also, I just tested the demo with D3D and it runs faster, I think (fraps left me here, so I'm guessing) its about 15-20 fps.
I would say that is really good for such an effect, considering that I have to turn graphic effects to low an any new game to get acceptable framerates of at least 25fps.

So long
Jay