Quote:*Original post by REF_Cracker* ArKano22:
First off thanks for sharing your method... Now
I'm looking over the code and have a problem with a few things... could you explain the reasoning?
First off I see that vec[8] is initialized to the corners of a cube with the dimensions of (2,2,2). And then you do some pseudo random sampling in those directions. The problem is you are sampling out in 2D so your +1 or -1 in Z of those values never matters. In fact you're only passing the vec2 value of this to your doAmbientOcclusion function anyway. Did I miss something here? Wouldn't you be better off sampling in an 8 way circle if this is the case?
Now for the random length it seems you're sampling a texture with 4 values. That work out to always be one of (1.0,0.72,0.46,0.23) .. is that correct?
Thanks! |

Hello REF:

I´m using 3d samples, the corners of a 2x2x2 cube as you say. Then by multiplying each sample vector with the view transform, i rotate it along with the view. Then i use them as 2d points. The Z location does not matter anymore, but because of the view transform, the x,y values are not the same. So the Z value of each sample is needed to calculate the new x,y values passed to the occlusion function.

This sampling method results in a completely view-independent sampling pattern, because the pattern moves with the camera , and each pixel samples always the same zone, no matter how you move around the scene. This is the original ssao sampling method. 100% 2D sampling was developed after Crysis.

About the sampling lengths, yes, they are always these values. That is because i´m using interleaved sampling, so in a 2x2 area, each pixel samples a different lenght, then the 4 lengths are averaged together using a blur filter. This is also the original method, except Crysis used 4x4 interleaved sampling instead of 2x2 (i think, not sure about this).

So in fact, this method is Crytek´s with a different occlusion function that helps with halos and improves accuracy, nothing more.

EDIT: btw, i forgot to scale the samples with the screen size:

doAmbientOcclusion(i.uv,coord, p, n );

should be

doAmbientOcclusion(i.uv,coord*g_inv_screen_size*1000.0, p, n );

I will correct that as soon as possible.