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

SSAO [Screen Space Ambient Occlusion] Demo + Source

Post by nullsquared »

Edit: Some additional screen-shots!

Off:
Image
On:
Image

Off:
Image
On:
Image

And less emphasis on the SSAO:

Off:
Image
On:
Image

====================================================

Download:
- http://cheapfilehost.com/file.php?file= ... 98b2013f4b
- http://www.MegaShare.com/434579
- courtesy of tuan kuranes : http://tuan.kuranes.free.fr/OgreDemo_SSAO.zip
(if anyone would like to mirror it, please do so, and I'll post the link here)

Make sure you read the readme. All source is included, along with binaries. No blur is done on the SSAO.

Image

Image

Image

// just same playing around at 1024x768
Image

(yes, the same scene from the shadows demo, with improved lighting! :lol:)

I've yet to make it work completely under OpenGL. BTW, you can use this as a demo to reconstruct a 3D view-space position from linear view-space depth.

Issues: It won't work on non-SM 3.0 cards as it is right now, since I'm using a 128-bit G-buffer; no multi render targets, but there's a an R32G32B32A32 floating point render target being used. First thing you can do is compile with R16G16B16A16 instead, which halves the amount of bits for each pixel from 128 to 64. You can also just use a single channel texture just for the depth (R16 or R32), and use the provided computeViewNorm() shader function to calculate the normals from the position. Note that this is a lot less accurate than storing the actual interpolated normals, but it tends to work fine enough in most cases.

I'd love to see if anyone integrates this into their own stuff. The only problem is that there is a lot of manual code:
- manually generating the information for the SSAO
- manually generating the SSAO into an off-screen texture
- manually projecting the SSAO in the ambient shader
But I found Ogre's compositors just not powerful enough to do this in such a simple manner such as effect->update(). Or maybe I just don't understand how to use them :lol:. If anyone wishes for guidance, please post so.
Last edited by nullsquared on Sun Aug 03, 2008 1:14 pm, edited 8 times in total.
User avatar
Samuelgames
Gnoblar
Posts: 15
Joined: Fri Mar 14, 2008 12:44 am

Post by Samuelgames »

HOLY SHIT

You managed to add f***ing specular WITH SSAO :o

Null, i love you.

EDIT:

Wow wait, this is not just 'specular', this shit is dynamic

(now do that on HL2) [/post on FP]
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

Samuelgames wrote:HOLY SHIT

You managed to add f***ing specular WITH SSAO :o

Null, i love you.
:)
EDIT:

Wow wait, this is not just 'specular', this shit is dynamic
Yeah, my demo scenes suck, so just place some knots with space to see that it is indeed dynamic.
(now do that on HL2) [/post on FP]
I'm sorry, but Ogre > Source (at least the rendering portion), and thus I declare the above statement impossible. :lol: :roll:
User avatar
Samuelgames
Gnoblar
Posts: 15
Joined: Fri Mar 14, 2008 12:44 am

Post by Samuelgames »

nullsquared wrote: I'm sorry, but Ogre > Source (at least the rendering portion), and thus I declare the above statement impossible. :lol: :roll:
The just fact that Ogre is Opensource and Multi Plataform makes it better.

And it is a lot better than source in rendering terms
Yeah, my demo scenes suck, so just place some knots with space to see that it is indeed dynamic.
I mean, that is not specular, that is light reflection
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

Samuelgames wrote: I mean, that is not specular, that is light reflection
Uh. Not to burst your bubble, but no light is getting reflected here (no global illumination). Just some relatively nice SSAO + diffuse/specular shading with soft shadows.
User avatar
Samuelgames
Gnoblar
Posts: 15
Joined: Fri Mar 14, 2008 12:44 am

Post by Samuelgames »

nullsquared wrote:
Samuelgames wrote: I mean, that is not specular, that is light reflection
Uh. Not to burst your bubble, but no light is getting reflected here (no global illumination). Just some relatively nice SSAO + diffuse/specular shading with soft shadows.
Then i'm blind.

It just, doesn't look like specular
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

Guys, no one is testing this? Seems like people are reading the thread but forgetting to post, which is the biggest point since this is far from "finished and generally usable easily" ;)
Samuelgames wrote:
nullsquared wrote:
Samuelgames wrote: I mean, that is not specular, that is light reflection
Uh. Not to burst your bubble, but no light is getting reflected here (no global illumination). Just some relatively nice SSAO + diffuse/specular shading with soft shadows.
Then i'm blind.

It just, doesn't look like specular
Haha.
TSM
Gnoblar
Posts: 17
Joined: Sun Feb 05, 2006 9:31 pm

Post by TSM »

Great job null.

I find it amusing how you`re a watchdog on your threads (quick responses are always great!). :P

I'm generally a lurker here on Ogre - since I was investigating it for a rendering engine (but sucked up for C4, which has a terrible rendering engine ... well not terrible but not robust OR flexible at all).

I'm simply stunned that you`re 14 (8th grade?) and writing complex shaders like SSAO - just .. amazing. I've learned a lot from your code - so sorry I can't test it. I just use it as learning material!

Keep at it good sir!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

TSM wrote:Great job null.

I find it amusing how you`re a watchdog on your threads (quick responses are always great!). :P
Well, it's night, and I'm on the computer cross-checking all of gamedev, ogre, and facepunch. I'm also txting this girl that randomly decided to tell me she's going out with this guy that's an obsessive loser, but that's a different story :lol:. (yes, I like this girl)
I'm generally a lurker here on Ogre - since I was investigating it for a rendering engine (but sucked up for C4, which has a terrible rendering engine ... well not terrible but not robust OR flexible at all).
Haha.
I'm simply stunned that you`re 14 (8th grade?) and writing complex shaders like SSAO - just .. amazing. I've learned a lot from your code - so sorry I can't test it. I just use it as learning material!
Heh, only 2 more finals (spanish and math), and I'm done with 8th grade, w00t!
Keep at it good sir!
Thanks :)
TSM
Gnoblar
Posts: 17
Joined: Sun Feb 05, 2006 9:31 pm

Post by TSM »

Any way to minimize the AO at the intercepts between the geometry (walls) ?
_Anonymous

Post by _Anonymous »

The hell ?
Only support for SM3.0 ???

EDIT : And in the readme says "pixel shader 2.b" ?
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

_Anonymous wrote:The hell ?
Only support for SM3.0 ???

EDIT : And in the readme says "pixel shader 2.b" ?
What are you so surprised about? Pixel Shader 2.b is probably just cutting it to fit the shader instructions, but 2.b support is wretched. On top of that, Shader Model 2 cards would have a hard time processing all that extra stuff. I just compiled in Cg with PS 2.b and 3.0, and it came out to 285 or so instructions. That would eat a PS 2.b card most of the time.

Edit:
Oh ya, the demo. Looks absolutely fantastic - the code looks really professional, too.
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Post by jjp »

Great job :)
Enough is never enough.
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

Post by DanielSefton »

Amazing! Really, great work. I'll test it in my game ASAP.

As for the demo, it's really jerky for me. Not as in slow framerate (though it would have been useful to display it in the demo), but it randomly stops and starts. My card is an NVidia 6600, which is reasonable enough, and it supports SM3. (The AO is working fine)

Just out of interest, what card are you using to develop this with?

Edit: Also, how does this stack up against the technique used in CryEngine?
Last edited by DanielSefton on Mon Jun 23, 2008 10:52 am, edited 2 times in total.
User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Post by xadhoom »

Hi Null!

Very great Demo. Good work! Works on my XPS with a QuadroFx 1500 smoothly :P

I currently try to derive some materials from your shadow demo. Now I have to switch to your SSAO :wink:

Btw, the odd fade problem is still there, but thats another thread :wink:
_Anonymous

Post by _Anonymous »

I use GMA 950 => support PM 2.0 + VS 3.0 => can't run the demo.
But I've tried it using swiftshader v2.1. It run slow but look fine.
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

DanielSefton wrote:Amazing! Really, great work. I'll test it in my game ASAP.

As for the demo, it's really jerky for me. Not as in slow framerate (though it would have been useful to display it in the demo), but it randomly stops and starts. My card is an NVidia 6600, which is reasonable enough, and it supports SM3. (The AO is working fine)
That sounds a bit odd. Maybe its getting stuck calculating/rendering something. Which drivers?
Just out of interest, what card are you using to develop this with?
8800 GTS :D this is why I need more people testing, instead of thinking that it's good to go just because it runs at 100+ FPS here :lol:
Edit: Also, how does this stack up against the technique used in CryEngine?
Well, the general idea is the same. Of course, the guys at Crytek probably know what they're doing better than I do ;)

@ _Anonymous: I can guarantee you that a GMA 950 will not run any SSAO whatsoever in hardware.

@ TSM: Well, technically, the "creases" there are getting slightly occluded. I think it looks better than just flat ambiency at the creases of the level. It might look better with a larger AO radius, but then that makes everything else look crappy :D

@ Hexidave: Yeah, IIRC it uses 12 random samples. Simply moving those down to 8 should help out. AFAIK Crysis doesn't even do any projection inside the loop (I have *no* idea how), so that saves them speed as well. Really, there's lots of little tweaks and stuff to make it work better. For one, I could probably get rid of the 128-bit G-buffer (one texture, but it stores normals and depth), and instead store a 16-bit (or 32-bit) depth only. Then I can calculate the normals from the position, but that'll get rid of the smoothed normals and instead it'll give me the face normals :| (which doesn't look too bad for SSAO, but it just doesn't look "the best")
Last edited by nullsquared on Mon Jun 23, 2008 3:56 pm, edited 1 time in total.
kro
Gnoblar
Posts: 24
Joined: Wed Aug 02, 2006 1:02 pm
Location: Copenhagen, Denmark

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

Post by kro »

Nice demo!

Runs great on 8800GTX, but when cam is very close or within a torus one of my dual screens flickers black (running windowed mode)...strange
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Very nice and smooth demo !


Here's a mirror :
http://tuan.kuranes.free.fr/OgreDemo_SSAO.zip
If you need to host some other files, just ask.

But you should really open your own googlepages site with all your ogre source demo and code. (100MB of space).
User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany
x 1

Post by xadhoom »

It seems that the the SSAO shadows "move" heavily depending on angle
and surface on screen. In the most confusing situation it looks like a torus
knot is very near to a wall and if you rotate around it the SSAO shadow
disappears and you can see that there is a signifcant distance between wall
and knot... can this be avoided by lowering a distance threshold?
You have to turn out the flashlight to see that...
_Anonymous

Post by _Anonymous »

Well, I said it CAN'T run on my GMA 950. Then I used swiftshader v2.1
(a software rasterizer) so it ran at ~15 fps. Not bad ! I also tried running it on Radeon X1300 Mobility and it ran fast, about 50fps or more :wink:
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

xadhoom wrote:It seems that the the SSAO shadows "move" heavily depending on angle
and surface on screen. In the most confusing situation it looks like a torus
knot is very near to a wall and if you rotate around it the SSAO shadow
disappears and you can see that there is a signifcant distance between wall
and knot... can this be avoided by lowering a distance threshold?
You have to turn out the flashlight to see that...
Well, that's really one of the bigger issues with SSAO, it's in screen space. So, obviously as the screen data (the depth) changes, so will the SSAO. The point for SSAO is not to produce 100% correct AO, but to merely trick the eye into believing there is indeed AO going on.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

Looks very nice. But I have a really old graphics card (GeForce FX 5600), and get really low FPS on most good looking stuff like this. :(
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

nikki wrote:Looks very nice. But I have a really old graphics card (GeForce FX 5600), and get really low FPS on most good looking stuff like this. :(
Does your 5600FX even run this? Because the demo renders to a 128-bit texture (32 bits for each channel)...
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

nullsquared wrote:
nikki wrote:Looks very nice. But I have a really old graphics card (GeForce FX 5600), and get really low FPS on most good looking stuff like this. :(
Does your 5600FX even run this? Because the demo renders to a 128-bit texture (32 bits for each channel)...
Yeah, it does, but then I had to count seconds per frame instead of frames per second. :roll: Don't worry about it though, I'm going to get a new graphics card anyway (its just that my motherboard was confining me to the older ones, I gotta get a new motherboard too).
Post Reply