SSAO [Screen Space Ambient Occlusion] Demo + Source

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!
Tuftux
Gnoblar
Posts: 20
Joined: Mon Aug 04, 2008 9:19 pm

Post by Tuftux » Sun Aug 10, 2008 7:20 pm

I'm a big noob with Ogre, but with my ATI HD3850 it says

Code: Select all

20:13:59: OGRE EXCEPTION(2:InvalidParametersException): Parameter called invSMSize does not exist.  in GpuProgramParameters::_findNamedConstantDefinition at D:\Ogre_CVS\ogrenew\OgreMain\src\OgreGpuProgram.cpp (line 883)
20:13:59: Error at line 33 of 00diffuse.material: Invalid param_named_auto attribute - Parameter called invSMSize does not exist.
And a little later

Code: Select all

20:13:59: Error at line 39 of ssao.material: Error in program ssao_ps_sm3 parameter compile_aruments is not valid.
So when i run the demo i only see normal soft shadows.

But this looks so greeeeeaaaaat !
0 x

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

Post by nullsquared » Sun Aug 10, 2008 7:26 pm

Right, I made a type :oops:

Open up line 39 of data/ssao.material and change "compile_aruments" to "compile_arguments"
0 x

Tuftux
Gnoblar
Posts: 20
Joined: Mon Aug 04, 2008 9:19 pm

Post by Tuftux » Sun Aug 10, 2008 7:34 pm

Mmmh right but the the two first errors stills there. I commented

Code: Select all

delegate ssao_ps_sm3
And it works but very slowly, it has a very very bad FPS when i'm closed to an object. I think its because it's using PS 2.

But really impressive :)[/code]
0 x

NintenDave
Halfling
Posts: 43
Joined: Fri Jul 04, 2008 10:36 am
Location: Wales

Post by NintenDave » Tue Aug 26, 2008 11:05 pm

I have an HD 4870 and I have to comment delegate ssao_ps_sm3 to get this to work. Supposedly, this card should have SM 4.1 support. Is ATI just a shit?
0 x

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

Post by nullsquared » Wed Aug 27, 2008 3:18 am

NintenDave wrote:I have an HD 4870 and I have to comment delegate ssao_ps_sm3 to get this to work. Supposedly, this card should have SM 4.1 support. Is ATI just a shit?
I'm pretty sure it should work right, but I had a typo in there, "delete ssao_ps_sm3". Make sure it's "delegate ssao_ps_sm3". And if it is but it still doesn't work, then ... :|
0 x

User avatar
almondega
Halfling
Posts: 67
Joined: Mon Jun 23, 2008 7:34 pm
Location: Brazil

Post by almondega » Wed Sep 03, 2008 10:34 pm

in the sample i got 30 fps
i have a GeForce 8600 GT (shader 3), core 2 duo 2.3ghz 4mb

is that correct?
0 x

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

Post by nullsquared » Thu Sep 04, 2008 12:57 am

Sounds about right. I tested Portalized on my 8600GT with nothing but SSAO turned on, and it was about 50-70 FPS. Mainly due to 8 samples instead of 16 (as in the SSAO demo), due to some (minor) optimizations and changes, such as the random samples array.
0 x

User avatar
almondega
Halfling
Posts: 67
Joined: Mon Jun 23, 2008 7:34 pm
Location: Brazil

Post by almondega » Thu Sep 04, 2008 1:41 am

16 samples :shock: ?
i'll test another day with 8 samples
tks =]
0 x

User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post by yuriythebest » Thu Sep 04, 2008 4:23 am

wow tested it and looks just amazing, all those shadows really do make a difference. And in stereoscopic 3d it's just.... wow!!
0 x
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie

MephsUK
Gnoblar
Posts: 4
Joined: Mon Sep 08, 2008 10:55 pm

Post by MephsUK » Tue Sep 09, 2008 8:30 am

Hey all,

Just posting as I myself am very intrigued by the potential offered by SSAO and thanks to this fantastic thread I've gotten off to a flying start with implementing it.

Having finally implemented it in ogre, roughly as has been done here (with the same shader, albeit, minus the light/shadows).

I've been tinkering with the shader since getting a successful implementation though, and I think I've hit upon something which looks a bit nicer and brings out a bit more detail.

Here is a sample of the full final effect (which is kinda on the dark side just for the sake of emphasising the effect):
Image

and here is a sample of the SSAO shader output:
Image

I'm not 100% sure why my changes have resulted in this output which I consider to show more detail (and a distinct haze in areas where there is no object in the background), but I did wonder if perhaps I am being biased... does it look like any better an effect to you guys, or is it just me?

Cheers,

Steve
0 x

User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal » Tue Sep 09, 2008 2:08 pm

Do you get the same outline/haze if you put something in the background? Try using a plane for a backdrop and see if it looks the same.
0 x

MephsUK
Gnoblar
Posts: 4
Joined: Mon Sep 08, 2008 10:55 pm

Post by MephsUK » Tue Sep 09, 2008 2:16 pm

I don't know actually. I'll give it a try this evening and see what the outcome is and then post my results... I'll see if I can get a slightly lighter version of the shader running too to see if I can get a bit more of a natural look.

If anyone is interested, I can post my shader modifications tonight too... but I guess it's still up for debate as to whether it looks any better or not.
0 x

User avatar
sisyphus
Halfling
Posts: 50
Joined: Mon May 12, 2008 11:13 am
Location: London, England
Contact:

Looks interesting

Post by sisyphus » Tue Sep 09, 2008 4:21 pm

@MephsUK - I would be interested in getting a look at the modifications...
0 x
http://GPForge.com | digital art and entertainment

MephsUK
Gnoblar
Posts: 4
Joined: Mon Sep 08, 2008 10:55 pm

Post by MephsUK » Tue Sep 09, 2008 4:51 pm

Well, as a quick description before I head home and get the full changes, I basically just changed the order of the depth comparison (I think from "depth - new sampled depth" to "new sampled depth - depth" and inverted the resultant occlusion factor. I also think I did a bit of fettering with clamping values here and there... but that is essentially it.

I'm not sure why it makes such a difference for me (taking my change out seems to lose a lot of detail)... perhaps it's not really doing anything special and it's my other changes that are helping, but I was curious to give it a try. I just wonder if perhaps by inverting the calculation in a sense preserves more occlusion data somehow?

*EDIT* I also wonder what would happen if you took both approaches in the shader (if possible) and took the average of the two values... just a thought.
0 x

MephsUK
Gnoblar
Posts: 4
Joined: Mon Sep 08, 2008 10:55 pm

Post by MephsUK » Tue Sep 09, 2008 8:57 pm

I've not yet tried putting an object in the background, but I have got a new set of comparisons. I'll work on putting in a background plane ASAP.

With normal SSAO:
Image

With inversed depth calculation:
Image

Using average of normal SSAO and inversed depth calculation:
Image

I actually think the average of the two works best and seems to remove all of the dark outline around the edge of the model... would this be the halo effect everyone mentions?

Oh, I also forgot to mention that I did away with the quadratic falloff in my own version of the shader as suggested earlier. Also, I am using the PS2 model shader as the PS3 one does not work on my machine (despite supposedly supporting it). Finally... the output I am doing here is to a texture that is half the resolution of the screen. I am guessing that quality would further improve with a higher resolution render target, but I'm doing this for speeds sake.

What do you think of the difference?

Thanks,s,

Steve

*EDIT* I've been tinkering further and yes, there do seem to be artefacts on objects that are large distances apart. The walls of the room in the picture I am about to show you really suffered from it originally.

However, I have been tinkering even further and have hit upon some even more interesting results with a couple more changes. I have removed the negation of the final occlusion value. Reduced the Z scale from 50 to 10, kept the averaging system and negated the normal direction bias and have got the following results:

Image

Image

Image

Image


Again, I think these are very interesting results in their own way. Noise is less of a problem here. I don't think the lighting is quite as emphasised, but it is a bit more natural, still picks out a LOT of detail and suffers much less from noise problems. It almost looks like my changes have turned the shader into an outlining/ambient occlusion hybrid shader.

I'll try and keep each revision of my shader saved aside in case the code is useful for anyone :)
0 x

User avatar
Night Elf
Halfling
Posts: 96
Joined: Sun Jun 26, 2005 5:25 pm
Location: Argentina
Contact:

Post by Night Elf » Thu Sep 11, 2008 1:25 am

Hi, I'm trying to compile this sample but I'm having a hard time getting it to work... Has anyone succesfully converted the demo to work with Ogre 1.6?

I updated the classes a bit following the Shoggoth porting notes but, although it builds and runs ok, it doesn't manage to find/compile the materials...

Here's part of my Ogre.log:

Code: Select all

...
20:46:18: Parsing scripts for resource group Media
20:46:18: Parsing script 00ambient.material
20:46:18: Parsing script 00diffuse.material
20:46:18: OGRE EXCEPTION(2:InvalidParametersException): Parameter called invSMSize does not exist.  in GpuProgramParameters::_findNamedConstantDefinition at c:\libs\ogre-1.6\ogremain\src\ogregpuprogram.cpp (line 1095)
20:46:18: Compiler error: invalid parameters in 00diffuse.material(30): setting of constant failed
20:46:18: Parsing script metal.material
20:46:18: Compiler error: unknown error in metal.material(1): base object named "diffuse_template" not found in script definition
20:46:18: Parsing script ogre.material
20:46:18: Compiler error: unknown error in ogre.material(1): base object named "diffuse_template" not found in script definition
20:46:18: Parsing script shadow_caster.material
20:46:18: Parsing script ssao.material
20:46:18: Parsing script white.material
20:46:18: Compiler error: unknown error in white.material(1): base object named "diffuse_template" not found in script definition
20:46:18: Parsing script debug.overlay
20:46:18: Finished parsing scripts for resource group Media
20:46:18: Texture: random.png: Loading 1 faces(PF_A8R8G8B8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
20:46:18: WARNING: material metal has no supportable Techniques and will be blank. Explanation: 

20:46:18: Mesh: Loading knot.mesh.
...
0 x
Mariano Ruggiero // Follow me on Twitter (@ArtCoder) // Check out our games:
NEW! Elemental Rage - metroidvania-style adventure platformer
Silent Swords // Silent Swords ZERO // Crunchy Planets

User avatar
Night Elf
Halfling
Posts: 96
Joined: Sun Jun 26, 2005 5:25 pm
Location: Argentina
Contact:

Post by Night Elf » Fri Sep 12, 2008 12:19 am

I managed to get rid of most of the errors by making the following change:

Code: Select all

fragment_program diffuse_ps cg
{
    source diffuse.cg
    profiles ps_3_x arbfp1     <--- ps_3_x instead of ps_2_x
    entry_point diffuse_ps

    default_params
    {
      ...
I don't know if that was really necessary...

But I still have a couple of errors:

Code: Select all

Compiler error: unknown error in metal.material(1): base object named "diffuse_template" not found in script definition
The same error repeats for ogre.material and white.material. Any ideas?
0 x
Mariano Ruggiero // Follow me on Twitter (@ArtCoder) // Check out our games:
NEW! Elemental Rage - metroidvania-style adventure platformer
Silent Swords // Silent Swords ZERO // Crunchy Planets

User avatar
Night Elf
Halfling
Posts: 96
Joined: Sun Jun 26, 2005 5:25 pm
Location: Argentina
Contact:

Post by Night Elf » Fri Sep 12, 2008 1:17 am

:) Yes! I solved it!

You just have to add the import statement to be able to use diffuse_template as a base material (this is a new Shoggoth feature):

Code: Select all

import diffuse_template from 00diffuse.material
0 x
Mariano Ruggiero // Follow me on Twitter (@ArtCoder) // Check out our games:
NEW! Elemental Rage - metroidvania-style adventure platformer
Silent Swords // Silent Swords ZERO // Crunchy Planets

gamedboy
Gremlin
Posts: 168
Joined: Wed Sep 19, 2007 1:19 pm
Location: singapore

Post by gamedboy » Sun Oct 12, 2008 5:23 pm

This is very Cool!!!!!!!!!!!!!!

I had just integrated it in my editor
a screenshot is here
http://www.gamedboy.com/tiki-browse_image.php?imageId=1

Thanks alot for it.

just to add my 2 cent, you can try the following codes to reduce halo

Code: Select all

float occlusionFactor = clamp(viewPos.w - sampleDepth, 0, depthScale);
float halfDepth = depthScale * 0.5;
occlusionFactor = abs(occlusionFactor - halfDepth);
occlusion += smoothstep(0, halfDepth, occlusionFactor);
i am using depthScale of 3, so any depth above 3m is ignore
1.5m will give the darkest shading.

Code: Select all

float angleFactor = saturate(faceAngleBias + dot(viewNormal, sampleNormal));
occlusion += max(smoothstep(0, halfDepth, occlusionFactor), angleFactor);
occlusion happen when the angle between the 2 normal is between 0 - 90 degree, so I am using dot(viewNormal, sampleNormal) to get the angle between the 2 normal.

I am also clearing the normal and depth buffer to float4(0, 0, 1, 10000)
that is to prevent unwanted occlusion when there are no object in the background.
0 x

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

Post by nullsquared » Sun Oct 12, 2008 11:20 pm

Sounds good. Can you link to the image directly? I need to log on to see the image, and I don't feel like registering right now ;)

There are many ways to reduce the halos. One of them being adding the depth to the occlusion (as I have it in Portalized), or some kind of stepping of it (as you have it there). Though, did you reduce the gbuffer footprint? It can be made a lot smaller than the demo's 128-bit texture. 48-bits should be enough (16 bit depth, 16 bit normal.r, 16 bit normal.g).
0 x

gamedboy
Gremlin
Posts: 168
Joined: Wed Sep 19, 2007 1:19 pm
Location: singapore

Post by gamedboy » Mon Oct 13, 2008 2:11 am

:oops:
The link work now. It shldn't need any logon, as no one can register :twisted:

I have not tested using 48bit gbuffer yet, but will doing so
0 x

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

Post by nullsquared » Mon Oct 13, 2008 2:28 am

Wow, cool :D. I think you got it looking pretty nice. Your editor looks just as nice ;).

As for the 48 bit gbuffer, here's some details if you need them:
- FLOAT16_RGB
- store length(viewSpacePos.xyz) in R channel, viewSpaceNormal.x in G channel, and viewSpaceNormal.y in B channel
- extract Z portion of normal using float3(xy, sqrt(1.0 - dot(xy, xy)))
(basically, since there is no normal mapping for the SSAO normals, you can only have a positive Z in view space, and since the normal is unit length, you can find Z that way without explicitly storing it)

Now, the only problem is with the 16-bit depth, so you might want to play with that. Maybe use FLOAT16_RGBA and store 1/2 the depth in R, 1/2 the depth in G, or something like that. Still 64 bits is 1/2 the original 128 bits ;)
0 x

gamedboy
Gremlin
Posts: 168
Joined: Wed Sep 19, 2007 1:19 pm
Location: singapore

Post by gamedboy » Mon Oct 13, 2008 2:41 am

wow you are so fast !!!!!
Now, the only problem is with the 16-bit depth, so you might want to play with that. Maybe use FLOAT16_RGBA and store 1/2 the depth in R, 1/2 the depth in G, or something like that. Still 64 bits is 1/2 the original 128 bits
I think this shld work. Now I just have to optimise to make it run faster.
the screenie is using 6 sample, my home comp crawl when i use more :?
0 x

gamedboy
Gremlin
Posts: 168
Joined: Wed Sep 19, 2007 1:19 pm
Location: singapore

Post by gamedboy » Sun Nov 02, 2008 2:57 am

just uploaded a video of ssao in action on youtube
http://www.youtube.com/watch?v=blZNwi3GNaI

look at where the elbow is meeting the ground

a much better quality can be downloaded here

http://www.gamedboy.com/public_images/ssao.avi
it is about 1 meg
0 x

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

Re: SSAO [Screen Space Ambient Occlusion] Demo + Source

Post by Praetorian » Sat Jan 03, 2009 9:09 pm

I know this topic is sorta old, but since my project itself isn't ready for a showcase and I thought this little test turned out well I figured I'd post a couple quick shots of the SSAO in it (and I just now got a graphics card that could support SSAO....):

First off, nullsquared, thanks so much for releasing this, really great work. :)

Really the look of this is far from the graphical style I had planned, but got bored and started messing around in blender and sorta liked the result... :).. especially since I'm usually more programmer than artist....

And as the Hikari overlay in the corner shows, my project's preliminary name is Quanta (and it invovles 3D puzzle solving somewhat like portal but without portals :lol: , instead relying on physics and time manipulation (it's a lot deeper than it sounds... but that's enough about it for now.....)).

All of the ambient occlusion shown in that shot is done by the SSAO, I had a baked AO map at one point, but the SSAO actually looked a lot better (all the pipes and such didn't lend themselves well to uv mapping for the baked AO). In the shots the SSAO is using something like 20-30 samples (way too much but performance was slow as heck anyways), also I blurred the SSAO map slightly to get rid of a little bit of the noise. This is also using variance shadow mapping based off the earlier soft shadows demo (again thanks null, great stuff...).

These shots were taken at 1280x1024 resolution, with 8xS antialiasing, 16x anisotropic filtering, etc etc.... pretty much the highest i could set everything. On my ancient computer (Pentium 4 1.8Ghz, 512 mb RDRAM ( :( ), and a new agp 7600GS 512mb) I got about 2fps with those settings, though if I toned things down to the minimum I got about 30fps and it still looked great...)

Image
Image
0 x
My Google summer of code 2011 topic: Unit Testing Framework
My Google summer of code thread
My Google summer of code wiki page

Post Reply