Game Development Community

SSAO and Increased View Distance

by Gary Hoffmann · in Torque 3D Professional · 05/27/2009 (7:00 pm) · 5 replies

I'm wondering if anyone else has noticed any artifacts with SSAO and larger than default z-far values. When I increase the visible distance from 1000 to 3000, artifacts (broken lines) start to appear on flat surfaces. It looks like the rest of the SSAO still displays okay. Additionally, increasing the near-clip (even at large values) does nothing to lessen the effect.

I've increased the SSAO contrast in this scene just to show the effect in greater detail.

www.biomassthegame.com/images/misc/ssao.jpg

#1
05/27/2009 (8:46 pm)
I tried to reproduce this on a GTX280 and couldn't.
Running Windows 7 RC1 Nvidia Drivers 185.85
#2
05/27/2009 (9:28 pm)
You may also see artifacting in Advanced Lighting. A lot of the effects are based on linear depth. The G-buffer will store linear depth in 16, 24 (xbox360 only) or 32 bits.
(zfar - znear)/2^d where 'd' is the number of bits used to store depth, is the granularity of the depth data. The SSAO code uses a depth-threshold for it's effect, and I think that what could be happening here is that the data granularity isn't fine enough for the SSAO thresh-hold.

I think that Torque3D is using R16G16B16A16 targets by default for the G-buffer which should use 32 bits for depth, this should be plenty for a view distance of 3000, but something could be broken. If it is using an R8G8B8A8 buffer, though, try switching that to R16G16B16A16. That change is in the constructor of the RenderPrePassMgr. The G-buffer conditioner should do all the rest of the work for you.

I need to double-check to make sure that the zNear value is used properly, as well. It was hard-coded at 0.1 for most of Torque's history.
#3
05/27/2009 (10:38 pm)
Okay, here's a bit more information.

Updated to 185.85 (was 182.50). I have a 8800 GTX running on Vista-64.

Apparently, if I set the visible distance to a value greater than 100,000 the effect mostly disappears (and the SSAO and Advanced Lighting continue to work fine). By mostly, I mean that a single line will occasionally show up based upon the angle of the camera, but there's no consistent series of broken lines.

See the two pictures below. In the next one I have the far distance at 30,000 followed by 300,000.

www.biomassthegame.com/images/misc/ssao2.jpg
www.biomassthegame.com/images/misc/ssao3.jpg
Also, note that in the picture the effect is most pronounced around the camera where the z precision is highest and fades away.

I noticed that the shader also had a quality constant (for values of 0, 1, or 2). If I increase it from 0 (the default) to either 1 or 2, the effect becomes even more pronounced and even shows up with the default visibility settings.
#4
05/28/2009 (2:05 pm)
As Pat noted, this is due to precision of the depth buffer. If you need very large view distances with SSAO, you may have to change the depth buffer target type to the 128-bit type (R32G32B32A32).
#5
05/28/2009 (2:19 pm)
This is most likely something broken in the SSAO shader than something wrong with T3D itself.

We need to revisit that shader anyway as it was not performing very well in the first place.