the best ssao ive seen

Started by
237 comments, last by Paksas 12 years, 5 months ago
Quote:Original post by Jason Z
Quote:Original post by baradrasl
Awesome results, especially for the depth only REF_Cracker & martinsh!

I'll just post here to keep all SSAO stuff on topic!
I'm trying to implement a depth only but there is.. something off.
I'm using this as a source:
http://wiki.gamedev.net/index.php/D3DBook:Screen_Space_Ambient_Occlusion

As far as I know, everything is set up correctly. But my results (unblurred SSAO buffer) is more like this:

It makes a little bit sense.. In the right direction.. But what I don't get is the "boxiness" of the sampling. Also I do not get how relatively flat surfaces like the ground or the side of the boxes have all that noise on them (also the skybox, which should be at depth = 1 since I cap/normalize depth at 100m).

I can comment on that article [grin]. Have you tried out the demo program that comes with the chapter? That implementation was very sensitive to how the parameters are adjusted. There was quite a bit of playing around needed to get it working correctly. I don't recall having so much noise on a flat surface though... did you directly use the shader or have you made some changes to it?

If you still have trouble getting it to look correctly, you could always try out one of the other methods that have been posted here - if it is a depth only technique it should be nearly interchangeable.


Yes I tried the demo program with the article. It has a pretty easy way of tweaking the parameters, however, nothing I could come up with there resembled my results.

I've been meaning to try the blendgame shader that I saw here, but I had some worries that it might not fit in right away due to blender having a different setup than most game engines.
Did I miss any other depth only implementations in this thread?
Advertisement
There is one or two in there somewhere - this thread is unbelievably long now, isn't it? IIRC it is somewhere in the latter half, but don't quote me on that...
Hi guys. Im having trouble with this SSAO stuff. I've been hammering at it for a while. I reckon I get it but there were a few gotchas that I had for a while I've tried both the version posted at the beginning of this thread and the 'ring' method (although without the luminance texture). I've been hoping to get it right but the results arent quite right

5537911317_7074bff9c4.jpg


With this model, using the method in the first posting seems not to make a lot of difference. At the bottom of the screen is the normal + depth, the normal render and then the final render. Here is the same shader on a room

5537910217_47eab620cb.jpg


Again, there is some halo-ing around the chair legs and this is quite pronouced. Also, there isn't really that much going on here at all.

I noticed that the depth needs to be linear. In this case it goes from the near plane to the far plane. Its scaled from 0 to 1 with the far plane being 1 and the near plane being 0. Also, it is saved as the ALPHA value and the normals are saved as the RGB with R being X with 0.5 being 0, 0 being -1 and 1 being +1 (i,e allowing negative values as well as positive). That seems to have worked.

I tried the method that was posted here, the example with the luminance texture and the balls flying around (cant remmeber who posted it). This shader seems closer to the effect:

5538492076_bfd4962529.jpg


With the dragon, the effect is worse as all it really does is add a fringe to the model. Not very helpful. However, in the room:

5537907875_2697af6de3.jpg


Im not quite sure what I'm doing wrong. Ive also uploaded a video of this effect. The FPS is really poor :( I tried rendering the SSAO effect to a half size FBO but that meant i needed a combine step and shader which meant another pass which meant there was no speed up afterall :(


If its your first night, you have to fight!
Here are some results I've been getting with a multi-resolution approach to SSAO.

[attachment=3574:additional_house.png][attachment=3573:additional_spenger.png][attachment=3572:additional_city.png]
[attachment=3571:additional_truck.png][attachment=3570:additional_residenca.png][attachment=3569:additional_girl_car.png]
FAeDV.png

It takes about 22ms per frame at 1024x1024 on a laptop with a GTX 460M graphics card (NVIDIA's HBAO takes ~ 50ms). I guess it's not too bad?
If you are interested, the details can be found in a paper on my website.
This looks really good... I will definitely look into it!
ilovekonoka:

I've looked at your stuff outside of this forum, and it is clearly the cleanest nicest ssao I've seen. I'm going to give it a go eventually. Really great work!
Douglas Eugene Reisinger II
Projects/Profile Site
Hi

Thanks for posting the shader - your results look really amazing.

I've been trying to run it the whole day though and I keep having problems, so I thought I'll ask. I'm getting strange artifacts. I use the original HLSL code you posted.

Here's what I'm getting:

[attachment=6112:ssao.png]


Here's the contents of the depth buffer and the normals for it:

[attachment=6114:depthBuffer.png]


[attachment=6115:normals.png]


Both are in view space ( WorldMtx * ViewMtx )

Any hints what I may be doing wrong? Oh - here's the code I'm using to pack/unpack the depth & normal values:


// ----------------------------------------------------------------------------
// Normals
// ----------------------------------------------------------------------------

float2 EncodeNormal( float3 normal )
{
float2 color = normal.xy;
return color;
}

float3 DecodeNormal( float2 input )
{
float3 normal;

normal.xy = 2.0f * input.rg - 1.0f;
normal.z = sqrt( max( 0, 1 - dot( normal.xy, normal.xy ) ) );
return normal;
}

// ----------------------------------------------------------------------------
// Depth
// ----------------------------------------------------------------------------

float2 EncodeDepth( float depth, float maxZ )
{
float remappedDepth = depth / maxZ;

const float2 bitSh = float2( 256.0, 1.0 );
const float2 bitMsk = float2( 0.0, 1.0 / 256.0 );
float2 res = frac( remappedDepth * bitSh );
res -= res.xx * bitMsk;
return res;
}

float DecodeDepth( float2 encodedDepth, float maxZ )
{
const float2 bitSh = float2( 1.0 / 256.0, 1.0 );
float val = dot( encodedDepth, bitSh );

return val * maxZ;
}





One last thing - the image I posted is generated without the random noise you used. When I add it, here's the result I get:
[attachment=6117:ssaoNoise.png]


It's as if the texture was simply blended over the scene.

Cheers,
Paksas
@Paksas: I had this exact same problem with the noise texture! I didn't find a solution, though :(

@Paksas: I had this exact same problem with the noise texture! I didn't find a solution, though :(


I established that when I increase the sampling radius, the weird "cross" in the middle of the screen disappears, and the "overlayed scattered pattern" along with it.
But another problem arises - the edges start bleeding white color further and further.

The radius I'm taking about here equals 100.0f - so it's pretty big...

Any clues - anyone?

This topic is closed to new replies.

Advertisement