SSAO [Screen Space Ambient Occlusion] Demo + Source
- 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
Edit: Some additional screen-shots!
Off:
On:
Off:
On:
And less emphasis on the SSAO:
Off:
On:
====================================================
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.
// just same playing around at 1024x768
(yes, the same scene from the shadows demo, with improved lighting! )
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 . If anyone wishes for guidance, please post so.
Off:
On:
Off:
On:
And less emphasis on the SSAO:
Off:
On:
====================================================
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.
// just same playing around at 1024x768
(yes, the same scene from the shadows demo, with improved lighting! )
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 . 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.
- Samuelgames
- Gnoblar
- Posts: 15
- Joined: Fri Mar 14, 2008 12:44 am
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
Samuelgames wrote:HOLY SHIT
You managed to add f***ing specular WITH SSAO
Null, i love you.
Yeah, my demo scenes suck, so just place some knots with space to see that it is indeed dynamic.EDIT:
Wow wait, this is not just 'specular', this shit is dynamic
I'm sorry, but Ogre > Source (at least the rendering portion), and thus I declare the above statement impossible.(now do that on HL2) [/post on FP]
- Samuelgames
- Gnoblar
- Posts: 15
- Joined: Fri Mar 14, 2008 12:44 am
The just fact that Ogre is Opensource and Multi Plataform makes it better.nullsquared wrote: I'm sorry, but Ogre > Source (at least the rendering portion), and thus I declare the above statement impossible.
And it is a lot better than source in rendering terms
I mean, that is not specular, that is light reflectionYeah, my demo scenes suck, so just place some knots with space to see that it is indeed dynamic.
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- Samuelgames
- Gnoblar
- Posts: 15
- Joined: Fri Mar 14, 2008 12:44 am
Then i'm blind.nullsquared wrote: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.Samuelgames wrote: I mean, that is not specular, that is light reflection
It just, doesn't look like specular
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
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"
Haha.Samuelgames wrote:Then i'm blind.nullsquared wrote: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.Samuelgames wrote: I mean, that is not specular, that is light reflection
It just, doesn't look like specular
-
- Gnoblar
- Posts: 17
- Joined: Sun Feb 05, 2006 9:31 pm
Great job null.
I find it amusing how you`re a watchdog on your threads (quick responses are always great!).
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!
I find it amusing how you`re a watchdog on your threads (quick responses are always great!).
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!
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
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 . (yes, I like this girl)TSM wrote:Great job null.
I find it amusing how you`re a watchdog on your threads (quick responses are always great!).
Haha.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).
Heh, only 2 more finals (spanish and math), and I'm done with 8th grade, w00t!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!
ThanksKeep at it good sir!
- HexiDave
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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._Anonymous wrote:The hell ?
Only support for SM3.0 ???
EDIT : And in the readme says "pixel shader 2.b" ?
Edit:
Oh ya, the demo. Looks absolutely fantastic - the code looks really professional, too.
-
- Silver Sponsor
- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
- DanielSefton
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
- Contact:
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?
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.
- xadhoom
- Minaton
- Posts: 973
- Joined: Fri Dec 28, 2007 4:35 pm
- Location: Germany
- x 1
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
That sounds a bit odd. Maybe its getting stuck calculating/rendering something. Which drivers?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)
8800 GTS this is why I need more people testing, instead of thinking that it's good to go just because it runs at 100+ FPS hereJust out of interest, what card are you using to develop this with?
Well, the general idea is the same. Of course, the guys at Crytek probably know what they're doing better than I doEdit: Also, how does this stack up against the technique used in CryEngine?
@ _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
@ 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.
-
- Gnoblar
- Posts: 24
- Joined: Wed Aug 02, 2006 1:02 pm
- Location: Copenhagen, Denmark
Re: SSAO [Screen Space Ambient Occlusion] Demo + Source
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
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
- tuan kuranes
- OGRE Retired Moderator
- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
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).
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).
- xadhoom
- Minaton
- Posts: 973
- Joined: Fri Dec 28, 2007 4:35 pm
- Location: Germany
- x 1
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...
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...
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
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.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...
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
Yeah, it does, but then I had to count seconds per frame instead of frames per second. 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).nullsquared wrote:Does your 5600FX even run this? Because the demo renders to a 128-bit texture (32 bits for each channel)...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.