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
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA

SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 5:35 pm

EDIT: It has been brought to my attention that the mirrors are down. Here is a permanent upload of the demo & src: http://www.nullular.com/files/ssao_demo.7z

I know I already had a thread on this, but this version is much different.

It comes in your favorite .compositor format ;). It's pretty much plug-and-play, with a depth-checked blur, half-resolution SSAO buffer, and so on.

Off:
Image
On:
Image

Off:
Image
On:
Image

Off:
Image
On:
Image

The SSAO buffer itself:
Image
Image

Implementation details:

The compositor uses a 64-bit surface (FLOAT16_RGBA) to store depth / farClipDistance and XYZ normals. You can also only store XY and compute Z, but the computation of Z will be too heavy for the blur shaders, so I figured an exta 16 bits won't hurt. This geometry buffer is rendered after the "previous" scene has been pulled in, then the raw 1/2 resolution SSAO buffer is computed using 6 samples per pixel, then the full-resolution X gaussian blur buffer is computed, and then the full-resolution Y gaussian blur buffer is computed. After that, a simple "modulate" material is used to modulate the previous scene contents with the now blurred SSAO buffer.

The "smart" blur is done using a simple dot product between the original normal and the new pixels' normal. If it's over 0.9, then the pixel is accepted - otherwise, it is rejected.

The compositor does need a small CompositorInstance::Listener, but you can easily fine it in main.cpp, "ssaoListener". It simply passes some custom matrices to the SSAO shader to get rid of shader-side instructions. This allows the SSAO shader to run under pixel shader 2.b, it does not require 3.0.

The demo also features a slightly modified version of my previous shadows code.

The demo runs under both Direct3D and OpenGL. It was compiled with MinGW. See data/config.ini for some settings. If it runs slow, chances are that it's not the SSAO that is the trouble, but either the large amount of objects (non-instanced), or the rather brute-force blurs.

This was only tested on my 8800GTS so far (excellent frame rates), so I do not guarentee that it will run on anything else - but, it really should ;). I'm interested to hear results of ATI users. I'm also interested in results of 7000 series GeForces, 6000 series GeForces, X1000 radeons, X2000 radeons, and any of the newer radeons.

Compiled demo + source mirrors:
mirror0: http://willhostforfood.com/files4/5429919/ssao_demo.7z
mirror1: http://www.MegaShare.com/591606
mirror2: http://rapidshare.com/files/216761501/ssao_demo.7z.html

Controls: WASD for movement, mouse for mouse look, 'L' to place a light at the current camera position, F1 to toggle SSAO compositor on/off, and printscr to make a screen shot.

If you integrate this compositor into your own application, make sure you adjust the units and stuff. Look in ssao.cg, find the "zd" variable inside the loop. When this is calculated, you may want to scale it up or down by a certain coefficient depending on how big or small your world units are (the demo uses meters).
Last edited by spacegaier on Sat Dec 03, 2011 11:30 pm, edited 7 times in total.
Reason: restored after hacking account hacking attack
0 x

User avatar
boost
Greenskin
Posts: 112
Joined: Mon Jan 09, 2006 11:49 pm
Location: Barcelona; New Earth; Degova System

Re: SSAO Compositor

Postby boost » Sun Feb 15, 2009 5:59 pm

dumb question here: is this a sample application to see how use compositors?

forgive my ignorance please!

boost
0 x
Juan Ortanobas

Godlike
Kobold
Posts: 27
Joined: Thu Jul 10, 2008 2:22 pm

Re: SSAO Compositor

Postby Godlike » Sun Feb 15, 2009 6:17 pm

Hi there, I just tried the demo and my graphics looks different from yours, no textures on the environment, everything is black but the thoruses are brown, boxes and spheres are green.
Specularity is visible.
I am going to post a screen in 1 min.
Tried also to change to DX instead of OGL in config ;) runs a lot smoother.
Also I don't have fps on screen :|

My GPU is HD3850 :)

Image
Image
Image
Last edited by Godlike on Sun Feb 15, 2009 6:24 pm, edited 1 time in total.
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 6:23 pm

Godlike wrote:Hi there, I just tried the demo and my graphics looks different from yours, no textures on the environment, everything is black but the thoruses are brown, boxes and spheres are green.
Specularity is visible.
I am going to post a screen in 1 min.
Tried also to change to DX instead of OGL in config ;) runs a lot smoother.
Also I don't have fps on screen :|

My GPU is HD3850 :)

Hm, the whole ATI stuff is very interesting. See, in Portalized, we have the same issues with ATI cards. NVidia cards are 100% good to go, but ATI cards always end up with weird issues that we just can't quite solve.

By "runs a lot smoother" under D3D, do the textures appear? I mean, does the issue arise only under OpenGL?
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 6:27 pm

Hm. That seems very weird - everything looks like it's working (even the SSAO), just the colours are messed up. I'll look into it. Direct3D has the same issue?
0 x

Godlike
Kobold
Posts: 27
Joined: Thu Jul 10, 2008 2:22 pm

Re: SSAO Compositor

Postby Godlike » Sun Feb 15, 2009 6:28 pm

nullsquared wrote:
Godlike wrote:Hi there, I just tried the demo and my graphics looks different from yours, no textures on the environment, everything is black but the thoruses are brown, boxes and spheres are green.
Specularity is visible.
I am going to post a screen in 1 min.
Tried also to change to DX instead of OGL in config ;) runs a lot smoother.
Also I don't have fps on screen :|

My GPU is HD3850 :)

Hm, the whole ATI stuff is very interesting. See, in Portalized, we have the same issues with ATI cards. NVidia cards are 100% good to go, but ATI cards always end up with weird issues that we just can't quite solve.

By "runs a lot smoother" under D3D, do the textures appear? I mean, does the issue arise only under OpenGL?


No, no textures, output is identical. In fact these screens were taken with DX active.
And I really can't help you with this issue on ATI cards... too much technical for me, I guess there's some really "fun" setting or instruction or depth that makes them mad.
Unluckily, all the dev world must still deal with them...
Last edited by Godlike on Sun Feb 15, 2009 6:33 pm, edited 2 times in total.
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 6:30 pm

Godlike wrote:
nullsquared wrote:
Godlike wrote:Hi there, I just tried the demo and my graphics looks different from yours, no textures on the environment, everything is black but the thoruses are brown, boxes and spheres are green.
Specularity is visible.
I am going to post a screen in 1 min.
Tried also to change to DX instead of OGL in config ;) runs a lot smoother.
Also I don't have fps on screen :|

My GPU is HD3850 :)

Hm, the whole ATI stuff is very interesting. See, in Portalized, we have the same issues with ATI cards. NVidia cards are 100% good to go, but ATI cards always end up with weird issues that we just can't quite solve.

By "runs a lot smoother" under D3D, do the textures appear? I mean, does the issue arise only under OpenGL?


No, no textures, output is identical. In fact these screens were taken with DX active.
And I really can't help you with this issue on ATI cards... too much technical for me, I guess there's some really "fun" setting or instruction or depth that makes them mad.
Unluckily, all the dev world must still deal with them...

I'll look into it, because the issue looks like it's some pixel format issue that messes up the colours...
boost wrote:dumb question here: is this a sample application to see how use compositors?

forgive my ignorance please!

boost

It's a SSAO demo that uses Ogre compositors. My previous SSAO demo did not, instead it used (an old version of) my own compositor-like system.
0 x

Godlike
Kobold
Posts: 27
Joined: Thu Jul 10, 2008 2:22 pm

Re: SSAO Compositor

Postby Godlike » Sun Feb 15, 2009 6:33 pm

Now that I think on it... it's not that I must unpack it on C:/ isn't it? :mrgreen:
Maybe the only problem is it doesn't find textures :D
0 x

Caphalor
Greenskin
Posts: 116
Joined: Tue Feb 06, 2007 8:54 pm
Location: Berlin, Germany

Re: SSAO Compositor

Postby Caphalor » Sun Feb 15, 2009 6:41 pm

Ati x1900xt - runs great. :)
0 x
Image
Generated with vBaum - voxel based procedural geometry generator with python interface.

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 6:46 pm

Caphalor wrote:Ati x1900xt - runs great. :)

Glad to hear :). What kind of speed? I know there's no FPS measure, but just tell me how jerky or smooth it feels.

Godlike wrote:Now that I think on it... it's not that I must unpack it on C:/ isn't it? :mrgreen:
Maybe the only problem is it doesn't find textures :D

Yeah, that might definitely be the issue (doesn't need to be unpacked onto C:/, though, anywhere is fine). It definitely looks like the textures are missing.
0 x

Godlike
Kobold
Posts: 27
Joined: Thu Jul 10, 2008 2:22 pm

Re: SSAO Compositor

Postby Godlike » Sun Feb 15, 2009 6:55 pm

Yeah, that might definitely be the issue (doesn't need to be unpacked onto C:/, though, anywhere is fine). It definitely looks like the textures are missing.


Well I just unpacked it on the desktop with WinRAR and it retains all the dir structure... so I don't know what can be wrong.
Last edited by Godlike on Sun Feb 15, 2009 7:09 pm, edited 1 time in total.
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 7:05 pm

Godlike wrote:Yeah, that might definitely be the issue (doesn't need to be unpacked onto C:/, though, anywhere is fine). It definitely looks like the textures are missing.


Well I just unpacked it on the desktop with WinRAR and it retains all the dir structure... so I don't know what can be wrong.[/quote]
Hm.

Well, apparently it runs on the 1950xt. I'll do further investigation.
0 x

Caphalor
Greenskin
Posts: 116
Joined: Tue Feb 06, 2007 8:54 pm
Location: Berlin, Germany

Re: SSAO Compositor

Postby Caphalor » Sun Feb 15, 2009 7:07 pm

If I zoom out and all objects are visible, the fps go down to 16. Otherwise, I get 25 - 35 frames per second.
0 x
Image
Generated with vBaum - voxel based procedural geometry generator with python interface.

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 7:21 pm

Caphalor wrote:If I zoom out and all objects are visible, the fps go down to 16. Otherwise, I get 25 - 35 frames per second.

Sounds pretty good. There's a lot of objects in the scene, so it's the batch count which is hurting your frames, not the SSAO :D
0 x

User avatar
boost
Greenskin
Posts: 112
Joined: Mon Jan 09, 2006 11:49 pm
Location: Barcelona; New Earth; Degova System

Re: SSAO Compositor

Postby boost » Sun Feb 15, 2009 7:31 pm

nullsquared wrote:
boost wrote:dumb question here: is this a sample application to see how use compositors?

forgive my ignorance please!

boost

It's a SSAO demo that uses Ogre compositors. My previous SSAO demo did not, instead it used (an old version of) my own compositor-like system.


thanks for your reply! :)

my next dumb question is: what is SSAO?

why I'm asking so much dumb questions? I'm trying to figure out where to put this amazing demo in the wiki, and my 3D conceps are near NULL :mrgreen:

I'm working on a new wiki page that contains up and running applications that may be used to learn OGRE. Could this demo fit in this page? I don't know.

any help please?
0 x
Juan Ortanobas

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
Contact:

Re: SSAO Compositor

Postby Wolfmanfx » Sun Feb 15, 2009 7:33 pm

@boost
what driver version you are using ? latest ati?

@null
demo works fine 9650 GT :)
0 x

nortsen1
Gnoblar
Posts: 2
Joined: Tue Dec 30, 2008 12:04 pm

Re: SSAO Compositor

Postby nortsen1 » Sun Feb 15, 2009 7:39 pm

Hi

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

Demo works fine.
0 x

Taomorpheus
Gnoblar
Posts: 3
Joined: Sun Feb 15, 2009 7:39 pm

Re: SSAO Compositor

Postby Taomorpheus » Sun Feb 15, 2009 7:46 pm

Test it.

Nice job!!! :)

My spec:
cpu: amd 4000+ 2.4ghz
mem: 1gb
GPU: ati 4830HD 512mb
SO: xp sp 3 32 bit
Catalyst: 2009.0113.2222.40119

So, I have put 3 lights in the corners and done a "virtual tour" in the map, that's the benchmark:

Time (ms) 51176
Min 15
Max 72
Avg 36.814

So the avarage is 37 and I didn't feel any lag during my tour.

That's a screen made with my 4830hd :D
Image
0 x

User avatar
Azgur
Goblin
Posts: 264
Joined: Thu Aug 21, 2008 4:48 pm

Re: SSAO Compositor

Postby Azgur » Sun Feb 15, 2009 7:51 pm

nullsquared wrote:It comes in your favorite .compositor format ;)


Now that's nice and convenient :D

Thank you!
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 7:56 pm

Azgur wrote:
nullsquared wrote:It comes in your favorite .compositor format ;)


Now that's nice and convenient :D

Thank you!

Just don't forget the CompositorInstance::Listener "ssaoListener" class in main.cpp. It updates some necessary camera-related parameters.
0 x

User avatar
boost
Greenskin
Posts: 112
Joined: Mon Jan 09, 2006 11:49 pm
Location: Barcelona; New Earth; Degova System

Re: SSAO Compositor

Postby boost » Sun Feb 15, 2009 8:06 pm

Wolfmanfx wrote:@boost
what driver version you are using ? latest ati?


humm... the thing is I don't know :(

but I'm not running the demo.

I'm interested in what I asked in my last post...

thanks in advance

boost
0 x
Juan Ortanobas

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 8:36 pm

boost wrote:my next dumb question is: what is SSAO?

Lots of info about it on Google.
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: SSAO Compositor

Postby xadhoom » Sun Feb 15, 2009 8:42 pm

@Nullsquared: Nvidia suggest as less textures as possible (e.g. for precalc ramps etc.). How did calculating the distance affect the performance against using a larger texture?
Thanks for sharing!

@boost: Refer to the explanation here (look for SSAO): http://ati.amd.com/developer/SIGGRAPH08 ... raftII.pdf

xad
0 x

Godlike
Kobold
Posts: 27
Joined: Thu Jul 10, 2008 2:22 pm

Re: SSAO Compositor

Postby Godlike » Sun Feb 15, 2009 8:48 pm

I have read a doc about SSAO on Starcraft II.
They say they added a frame of pixels (or something similar) around the camera view to avoid the effect of occlusion with the external of the screen.
At first I thought that maybe that was only a fine detail and of little importance, but even if I cannot watch the demo well, I can spot that instead it looks very important and it is a disturbing effect.
Nobody else noticed this incongruence on the sides of the screen?
0 x

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

Re: SSAO Compositor

Postby nullsquared » Sun Feb 15, 2009 8:55 pm

xadhoom wrote:@Nullsquared: Nvidia suggest as less textures as possible (e.g. for precalc ramps etc.). How did calculating the distance affect the performance against using a larger texture?
Thanks for sharing!

I'm confused. Calculating what distance? The SSAO texture is simply 1/2 the size of the actual viewport.
0 x


Return to “Showcase”

Who is online

Users browsing this forum: No registered users and 3 guests