[Deprecated]SSAO with XEffects (Reloaded)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

could i help wiht SSAO i want to have it in my game so...
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

devsh wrote:could i help wiht SSAO i want to have it in my game so...
Go right ahead, I provided the source and download package on the first page.

Right now I have yet to sit down and really analyze my problems, or actually look at, in-depth, what I'm doing. I can't seem to find the time these days.
TheQuestion = 2B || !2B
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

I have some basic question about this:

- Is this give the same kind results as a real ambient occlusion? Or you have some kind of limitations?

- Is this being rendered per frame? Or it's baked at launch?

- Can it work with other light sources?

- Can it be colored (blue tinted for example as for simulating a daylight atmosphere, reddish tint to simulate a "torch" lighted atmosphere?

Halifax, you could improve your demo by putting bigger cubes (or make the camera move slower, seem the cubes are small because the movement of the camera is really fast). Also a very flat texture on the cube could reveal more of the SSAO.

Another nice thing would be to have a FPS counter on the window to evaluate the performance.

A flat plane under the mass of cubes should simultate the ground and also give a better view of what the code could do.

I've seen some kind of noise pattern, but it was not moving with the mesh, looked like some kind of unnatural overlaid noise. Is this the same for every SSAO algorithm?
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

christianclavet wrote: Is this give the same kind results as a real ambient occlusion? Or you have some kind of limitations?
It approximates the results of real ambient occlusion by using a depth buffer in screen space to simulate the hemi-sphere sampling.
christianclavet wrote: Is this being rendered per frame? Or it's baked at launch?
Screen-Space Ambient Occlusion is real-time technology. No baking is involved, you just have to use the shader that I provided. (I don't recommend you using the one I provided though because it's in a horrible state. :lol: )
christianclavet wrote: Can it work with other light sources?
Of course. It's a post-process technique. Meaning that all you need to do is get XEffects, follow this example, render your scene with the SSAO post-process enabled and there you go! It doesn't matter if you have lights or not.
christianclavet wrote: Can it be colored (blue tinted for example as for simulating a daylight atmosphere, reddish tint to simulate a "torch" lighted atmosphere?
As of now, no. Can that feature be added in, sure no problem.

Yes, I could really improve the demo. :lol: But really I was just doing an experiment, and wasn't even really concentrated. I will take your recommendations into consideration.

Since there seems to be so much interest in this technique, I will go write a real SSAO shader that works well, is fully integrated, and has tweak-able parameters. I'll write up a demo as well, and even try to write a little tutorial showing how to enable SSAO with XEffects already well produced shadows!

Check the topic for when I release the update.
TheQuestion = 2B || !2B
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Excuse my double post, but this doesn't really fit well with my last reply.

Anyways, I just installed my new GeForce 8800GT and decided to try out my SSAO. Low and behold...all banding issues were gone! I ran the same executable that I ran with my GeForce 6150SE and no banding occured. I find this quite odd.

But anyways, there were some modifications done regardless that helped out. Nate_D provided his great randomized normals map which reduced quite a few artifacts. BlindSide's link to the article about 32-bit buffer compression helped as well. (That's what I'm currently using instead of the 16-bit depth buffer in the standard XEffects.) I think that's all the changes, at least all that I can remember for now.

I'm not releasing anything yet, considering I still have to do all I did above. But I think it's quite interesting, so here are some screenshots:

SSAO Off:
Image

My SSAO, no blur:
Image

Leadwerks SSAO, no blur:
Image

My SSAO, buffer:
Image

As you can probably see, Leadwerks's SSAO shader produces a much more dramatic effect, while mine on the other hand produces a more natural one I think. It's up to you to decide which one you like, but they both will be in the "SDK" release.
TheQuestion = 2B || !2B
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I'm sorry but, yours really doesn't look like ambient occlusion. It looks like you are taking the dot product of the normal with the camera direction, and doing something with that. I think this effect is called "self-occlusion" among ssao enthusiasts and is tried to be avoided at all costs (Along with the cartoon outline effect, which you have done a very good job in avoiding :wink: ).

But really, the older screenshot looks 10x better than this newer one, I'm not quite sure what you changed...

Incase you don't get the problem with your newer one, it's that if you move the camera, the AO effect will change, which isn't really supposed to happen, atleast not in such a noticable way (Aside from maybe the random texture effect). There's also no "randomness" in this new shot, which is sort of a good thing, but all the occlusion went away with it.

I'm very interested to see the code and spot the differences, good luck on the release.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
m_krzywy
Posts: 133
Joined: Sat Nov 04, 2006 2:05 pm

Post by m_krzywy »

Can you post actual shader code?

Like Leadwerks SSAO but can't implement .vert and .frag with XEffectsR. Anny sugestions or code snippets?
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

m_krzywy wrote:Like Leadwerks SSAO but can't implement .vert and .frag with XEffectsR. Anny sugestions or code snippets?
This line threw me for a loop, I can't really understand what your saying. As for the code, I will try my hardest to get it ready by the end of this week, but right now it's really not in a release-able state.

BlindSide and I talked on IRC, and I completely agreed with his post above. The only thing I forgot to tell him is that although the Leadwerks SSAO does not appear to do real SSAO, it seems to be the effect desired by many people who aren't looking for the real SSAO, but rather a cheap effect that adds more depth to their bland scene and does define edges like an edge detection shader. At least that's been my experience.

But at any rate, I'm working with BlindSide who is trying to help me improve this shader.
TheQuestion = 2B || !2B
m_krzywy
Posts: 133
Joined: Sat Nov 04, 2006 2:05 pm

Post by m_krzywy »

Halifax wrote:
m_krzywy wrote:Like Leadwerks SSAO but can't implement .vert and .frag with XEffectsR. Anny sugestions or code snippets?
This line threw me for a loop, I can't really understand what your saying.
Don't know how to load it like you does:

Code: Select all

ssao = effect->addPostProcessingEffectFromFile( stringc( "shaders/SSAO.glsl" ) );

    ITexture* randomVectors = videoDriver->getTexture( "media/SSAORandomVectors.bmp" );

    effect->setPostProcessingUserTexture( randomVectors );
It worked out of the box. I have crated 2 files with .vert and .frag and don't know hot to make em' working. Sorry for offtopic but can't help you because of lack knowledge about shaders. My problem fit to begginers/advanced help. You have succesfully run it, I can't.
fmx

Post by fmx »

Your SSAO buffer looks more like some strange sort of lighting effect rather than true Ambient-occlusion.
The Ledwerks one most definitly seems to be AO, which IMO *is* what people expect ambient-occlusion to do afterall... right?

Could you maybe explain what you think "real SSAO" is?
I'm not looking to start a debate or anything, but I have always thought of SSAO as being precisely
a cheap effect that adds more depth to their bland scene and does define edges like an edge detection shader
But its good to hear you are still working to improve it, keep it up :)
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

m_krzywy: The problem is that you are saving the files as .frag/.vert, then you try to load them with the extension .glsl, so try changing the extensions to .glsl.

fmx: AO (Ambient Occlusion) is exactly what it describes. The occlusion of ambient light in the scene. So basically it should be some cheap edge detection effect, like the Leadwerks shader is. Not evidenced in my screenshot, because of the resolution, is the fact that the Leadwerks shader provides significant ambient occlusion around the very outer edge of the cubes. (Where the red meets the cubes.) That shouldn't be happening.

Specifically what it models is the fact that when two objects are very close together there is a certain area where not a lot of ambient light bounces to, thus producing a soft sort of shadow (rather a lower intensity of ambient light).
Last edited by Halifax on Mon Mar 09, 2009 12:29 am, edited 1 time in total.
TheQuestion = 2B || !2B
9YkKsvXM
Posts: 64
Joined: Tue Mar 11, 2008 11:45 pm

Post by 9YkKsvXM »

-
Last edited by 9YkKsvXM on Mon Jun 08, 2020 1:24 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Hmm yeah, thats the kind of formula I was talking about on IRC, to try and stop far away things from being shadowed.

The leadwerks shader is nice, and it's similar to how I first implemented SSAO, but it's not the way it's supposed to be done. In that sense Halifax's more on the right track except maybe he got lost along the way.

I'm still having a look over but I've got a good idea on how it should work. (And this method will solve alot of limitations inherently like shadowing far away things, SSAO effect getting too strong or weak depending on camera distance, and camera angle dependency.). Don't worry I won't butcher your shader too much Halifax. :P
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

BlindSide wrote:Hmm yeah, thats the kind of formula I was talking about on IRC, to try and stop far away things from being shadowed.

The leadwerks shader is nice, and it's similar to how I first implemented SSAO, but it's not the way it's supposed to be done. In that sense Halifax's more on the right track except maybe he got lost along the way.

I'm still having a look over but I've got a good idea on how it should work. (And this method will solve alot of limitations inherently like shadowing far away things, SSAO effect getting too strong or weak depending on camera distance, and camera angle dependency.). Don't worry I won't butcher your shader too much Halifax. :P
Butcher away BlindSide. As I've said on the IRC channel, I'm here to learn. And right now I'm trying to solve the problem, but simply can't due to my severe lack of knowledge when it comes to shaders.

So I thank you very much for any help you provide. :D
TheQuestion = 2B || !2B
fmx

Post by fmx »

This is a learning experience for us all I suppose, thanks to all you guys for sharing some of your knowledge! :D
Post Reply