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!

SSAO [Screen Space Ambient Occlusion] Demo + Source

Postby nullsquared » Sun Jun 22, 2008 11:25 pm

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.

For this message the author nullsquared has received kudos
User avatar
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby Samuelgames » Mon Jun 23, 2008 1:30 am

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
Samuelgames
Gnoblar
 
Posts: 15
Kudos: 0
Joined: 14 Mar 2008

Postby nullsquared » Mon Jun 23, 2008 1:37 am

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
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby Samuelgames » Mon Jun 23, 2008 1:50 am

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
Samuelgames
Gnoblar
 
Posts: 15
Kudos: 0
Joined: 14 Mar 2008

Postby nullsquared » Mon Jun 23, 2008 2:01 am

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
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby Samuelgames » Mon Jun 23, 2008 2:10 am

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
Samuelgames
Gnoblar
 
Posts: 15
Kudos: 0
Joined: 14 Mar 2008

Postby nullsquared » Mon Jun 23, 2008 2:12 am

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.
User avatar
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby TSM » Mon Jun 23, 2008 2:33 am

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!
TSM
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 05 Feb 2006

Postby nullsquared » Mon Jun 23, 2008 2:41 am

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 :)
User avatar
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby TSM » Mon Jun 23, 2008 3:41 am

Any way to minimize the AO at the intercepts between the geometry (walls) ?
TSM
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 05 Feb 2006

Postby quanganht » Mon Jun 23, 2008 7:49 am

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

EDIT : And in the readme says "pixel shader 2.b" ?
quanganht
Halfling
 
Posts: 56
Kudos: 0
Joined: 19 Jun 2008

Postby HexiDave » Mon Jun 23, 2008 9:09 am

quanganht 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.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby jjp » Mon Jun 23, 2008 9:34 am

Great job :)
Enough is never enough.
jjp
Silver Sponsor
Silver Sponsor
 
Posts: 597
Kudos: 0
Joined: 07 Jan 2007
Location: Cologne, Germany

Postby DanielSefton » Mon Jun 23, 2008 10:32 am

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
DanielSefton
Ogre Magi
 
Posts: 1235
Kudos: 9
Joined: 26 Oct 2007
Location: Mountain View, CA

Postby xadhoom » Mon Jun 23, 2008 10:47 am

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:
User avatar
xadhoom
Minaton
 
Posts: 973
Kudos: 2
Joined: 28 Dec 2007
Location: Germany

Postby quanganht » Mon Jun 23, 2008 10:48 am

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.
quanganht
Halfling
 
Posts: 56
Kudos: 0
Joined: 19 Jun 2008

Postby nullsquared » Mon Jun 23, 2008 11:02 am

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 ;)

@ quanganht: 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.
User avatar
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

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

Postby kro » Mon Jun 23, 2008 11:15 am

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
kro
Gnoblar
 
Posts: 24
Kudos: 0
Joined: 02 Aug 2006
Location: Copenhagen, Denmark

Postby tuan kuranes » Mon Jun 23, 2008 12:34 pm

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
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 3064
Kudos: 4
Joined: 24 Sep 2003
Location: Haute Garonne, France

Postby xadhoom » Mon Jun 23, 2008 12:52 pm

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...
User avatar
xadhoom
Minaton
 
Posts: 973
Kudos: 2
Joined: 28 Dec 2007
Location: Germany

Postby quanganht » Mon Jun 23, 2008 1:04 pm

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:
quanganht
Halfling
 
Posts: 56
Kudos: 0
Joined: 19 Jun 2008

Postby nullsquared » Mon Jun 23, 2008 3:55 pm

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
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby nikki » Mon Jun 23, 2008 4:26 pm

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
nikki
Old One
 
Posts: 2730
Kudos: 12
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA

Postby nullsquared » Mon Jun 23, 2008 4:33 pm

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
nullsquared
Old One
 
Posts: 3245
Kudos: 9
Joined: 24 Apr 2007
Location: NY, NY, USA

Postby nikki » Mon Jun 23, 2008 4:41 pm

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).
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 12
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA

Next

Return to Showcase

Who is online

Users browsing this forum: No registered users and 4 guests