the best ssao ive seen
#221 Members - Reputation: 100
Posted 27 April 2010 - 12:34 AM
After inspecting the RM project I have a few questions.
I see that you've switched to using view space positions when calculating the height difference instead of just depth, how do you feel this compares quality wise to using just depth?
getPosition uses tex2Dlod but always pick from the top mip map, is there a trick to this is or could one simply just use no mip maps together with tex2D?
In the full screen pass you pass the world -> projection matrix from the hebe statue to transform the cube used for sampling ( if I'm not mistaken hehe ). I don't quite see how this would be done when there's multiple objects being rendered. Also, couldn't 14 vector3s used for the cube be pre transformed as they don't change in the pixel shader? I'm thinking it could be a major speed up to not have to do 14 matrix multiplications per pixel.
#222 Members - Reputation: 630
Posted 27 April 2010 - 02:03 AM
Quote:
Original post by Ylisaren
Looks great ArKano22!
After inspecting the RM project I have a few questions.
I see that you've switched to using view space positions when calculating the height difference instead of just depth, how do you feel this compares quality wise to using just depth?
getPosition uses tex2Dlod but always pick from the top mip map, is there a trick to this is or could one simply just use no mip maps together with tex2D?
In the full screen pass you pass the world -> projection matrix from the hebe statue to transform the cube used for sampling ( if I'm not mistaken hehe ). I don't quite see how this would be done when there's multiple objects being rendered. Also, couldn't 14 vector3s used for the cube be pre transformed as they don't change in the pixel shader? I'm thinking it could be a major speed up to not have to do 14 matrix multiplications per pixel.
Thanks :).
For this method i always used positions instead of depth. This is because i do not use only the distance/difference between samples but also angular difference between the receiver´s normal and the vector from the receiver to the occluder. To compute this vector, positions are needed. The quality is better, and the haloing almost disappears. With this method you can also control the amount of self-occlusion, from 0 to completely self occluded. Worth the extra space used to store position, in my oppinion. But as always, it´s a tradeoff quality vs speed.
About the matrix used for the cube, it is the view transform as you say. You could precompute all positions in the vertex shader or even better in the cpu then pass it to the shader, because it´s not having perspective into account. Using this transform is "wrong", but it works well for usual fovs. For extreme fovs it is not as accurate but still looks good.
I´m quite unsure about what method is better: pure 2D sampling or view space sampling. 2D usually requires more samples but it is simpler. It´s a matter of taste, i guess.
#224 Members - Reputation: 670
Posted 27 April 2010 - 02:15 AM
Quote:
Original post by ArKano22
Thanks :).
For this method i always used positions instead of depth. This is because i do not use only the distance/difference between samples but also angular difference between the receiver´s normal and the vector from the receiver to the occluder. To compute this vector, positions are needed. The quality is better, and the haloing almost disappears. With this method you can also control the amount of self-occlusion, from 0 to completely self occluded. Worth the extra space used to store position, in my oppinion. But as always, it´s a tradeoff quality vs speed.
you could compute positions from depth and use that, then, too, right? (just asking for verification). so there's no real quality difference, just computation speed against storage space.
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
#225 Members - Reputation: 100
Posted 27 April 2010 - 03:52 AM
Quote:
Original post by davepermen Quote:
Original post by ArKano22
Thanks :).
For this method i always used positions instead of depth. This is because i do not use only the distance/difference between samples but also angular difference between the receiver´s normal and the vector from the receiver to the occluder. To compute this vector, positions are needed. The quality is better, and the haloing almost disappears. With this method you can also control the amount of self-occlusion, from 0 to completely self occluded. Worth the extra space used to store position, in my oppinion. But as always, it´s a tradeoff quality vs speed.
you could compute positions from depth and use that, then, too, right? (just asking for verification). so there's no real quality difference, just computation speed against storage space.
Yes, that's how I'm going to do it. The view space reconstruction implementation I use depends on vector interpolation between vertex -> pixel shader however, which can't be used when you're sampling arbitrary texels. As long as one has the 4 frustum corners ( even less than that is required ) one can construct the far position very cheaply per sample though.
#226 Members - Reputation: 670
Posted 27 April 2010 - 06:02 AM
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
#227 Members - Reputation: 136
Posted 27 April 2010 - 12:52 PM
Yup you are right, this is how it was intended to be:
for (int i = 0 ; i < rings; i += 1)
{
for (int j = 0 ; j < samples*i; j += 1)
{
float step = PI*2.0 / (samples*float(i));
pw = (cos(float(j)*step)*float(i));
ph = (sin(float(j)*step)*float(i))*aspect;
d = readDepth( vec2(texCoord.s+pw*w,texCoord.t+ph*h));
ao += compareDepths(depth,d);
s++;
}
}
Also I just found out that Arkano has already tried this or similar method before :D
REF_Cracker:
Awesome result!
#228 Members - Reputation: 100
Posted 30 April 2010 - 09:53 PM
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....bient_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).
#229 Members - Reputation: 122
Posted 30 April 2010 - 11:01 PM
#230 GDNet+ - Reputation: 1136
Posted 02 May 2010 - 01:08 AM
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....bient_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.
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
#231 Members - Reputation: 100
Posted 02 May 2010 - 08:58 AM
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....bient_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?
#232 GDNet+ - Reputation: 1136
Posted 02 May 2010 - 09:20 AM
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
#233 Members - Reputation: 122
Posted 18 March 2011 - 04:44 PM

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

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:

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:

Im not quite sure what I'm doing wrong. Ive also uploaded a video of this effect. The FPS is really poor
#234 Members - Reputation: 112
Posted 24 June 2011 - 06:51 AM

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.
#235 Members - Reputation: 254
Posted 24 June 2011 - 07:38 AM
#237 Members - Reputation: 122
Posted 16 November 2011 - 09:37 AM
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:
Here's the contents of the depth buffer and the normals for it:
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:
It's as if the texture was simply blended over the scene.
Cheers,
Paksas
#239 Members - Reputation: 122
Posted 16 November 2011 - 04:11 PM
GeneralQuery, on 16 November 2011 - 10:41 AM, said:
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?


















