Incorrect depthTexture with SSAO

Hi all,

I’ve been puzzled lately as I’ve been attempting to get a THREE.DepthTexture to work with the Ambient Occlusion shader. I’ve had it working before with RGBA unpacking, but after reading about Matt Deslauriers’s project, Audiograph, I decided to attempt the method he described for a potential performance boost:

Historically in ThreeJS, you would render your scene with MeshDepthMaterial to a WebGLRenderTarget, and then unpack to a linear depth value when sampling from the depth target. This is fairly expensive and often unnecessary, since many environments support the WEBGL_depth_texture extension.

After attempting this method, I somehow ended up with this weird unwanted effect in which lines are all over the terrain:

I have setup a small JSFiddle in which I have replicated the issue. I feel it’s something very obvious that I’m simply glossing over.

I hope someone here is able to point out what I’m missing so that I can get the ambient occlusion working in a way that is a little bit more performant!

Many thanks in advance.

It is solved! I had to increase the camera’s near value. I now have it set at 10.

Thank you WestLangley!