Jump to content



the best ssao ive seen

  • You cannot reply to this topic
238 replies to this topic

#221 Ylisaren   Members   -  Reputation: 100

Like
0Likes
Like

Posted 27 April 2010 - 12:34 AM

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.

Ad:

#222 ArKano22   Members   -  Reputation: 630

Like
0Likes
Like

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.

#223 ArKano22   Members   -  Reputation: 630

Like
0Likes
Like

Posted 27 April 2010 - 02:05 AM

Quote:
Original post by REF_Cracker
Results - Depth Buffer Only
Sampling 8 points per pixel.


That´s quite impressive! If you could reduce haloing...that´s the only showstopper i see (around the arm, its too dark)

#224 davepermen   Members   -  Reputation: 670

Like
0Likes
Like

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.
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud


#225 Ylisaren   Members   -  Reputation: 100

Like
0Likes
Like

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 davepermen   Members   -  Reputation: 670

Like
0Likes
Like

Posted 27 April 2010 - 06:02 AM

can't wait to test it once i start programming a game again :) thanks for the reply.
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud


#227 martinsh   Members   -  Reputation: 136

Like
0Likes
Like

Posted 27 April 2010 - 12:52 PM

Krulspeld:
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 baradrasl   Members   -  Reputation: 100

Like
0Likes
Like

Posted 30 April 2010 - 09:53 PM

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



#229 jessejohhavoc   Members   -  Reputation: 122

Like
0Likes
Like

Posted 30 April 2010 - 11:01 PM

This looks very cool! Great job on the modelling
http://www.codersquare.net/ - CoderSquare.net general programming community

#230 Jason Z   GDNet+   -  Reputation: 1136

Like
0Likes
Like

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.

Jason Zink :: DirectX MVP
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 baradrasl   Members   -  Reputation: 100

Like
0Likes
Like

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 Jason Z   GDNet+   -  Reputation: 1136

Like
0Likes
Like

Posted 02 May 2010 - 09:20 AM

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...
Jason Zink :: DirectX MVP
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 Oni   Members   -  Reputation: 122

Like
0Likes
Like

Posted 18 March 2011 - 04:44 PM

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

Posted Image


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

Posted Image


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:

Posted Image


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:

Posted Image


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!

#234 ilovekonoka   Members   -  Reputation: 112

Like
5Likes
Like

Posted 24 June 2011 - 06:51 AM

Here are some results I've been getting with a multi-resolution approach to SSAO.

additional_house.png additional_spenger.png additional_city.png
additional_truck.png additional_residenca.png additional_girl_car.png
Posted Image

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 mind in a box   Members   -  Reputation: 254

Like
0Likes
Like

Posted 24 June 2011 - 07:38 AM

This looks really good... I will definitely look into it!

#236 PaloDeQueso   Members   -  Reputation: 122

Like
0Likes
Like

Posted 04 October 2011 - 07:35 AM

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

#237 Paksas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 16 November 2011 - 09:37 AM

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:

ssao.png


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

depthBuffer.png


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:
ssaoNoise.png


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

Cheers,
Paksas

#238 GeneralQuery   Members   -  Reputation: 99

Like
0Likes
Like

Posted 16 November 2011 - 10:41 AM

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

#239 Paksas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 16 November 2011 - 04:11 PM

View PostGeneralQuery, on 16 November 2011 - 10:41 AM, said:

@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?






We are working on generating results for this topic
PARTNERS