Is your feature request related to a problem? Please describe.
A grid on my scene was contributing the depth buffer and nomals buffer of the SSAOPass, I mitigated it by disabling depthWrite and making the grid material transparent, but the normal contribution is still there and is visible in the far distance of the camera, when I inspect the .
Describe the solution you'd like
For the line basic material, not to output black in the normal buffer of SSAOPass.
Describe alternatives you've considered
I considered postprocessing, but I was thrown off by the lack of type support ... but that's unrelated.
Additional context




It just does not seem logical to me for those materials to contribute to the pass, I am not that experienced with the internals of three, I would of fixed it.
You could try the following: Move all objects which should not be affected by SSAO to layer 1. E.g:
grid.layers.set( 1 );
Then modify the render() method of SSAOPass like so:
// render beauty and depth
this.camera.layers.enable( 1 );
renderer.setRenderTarget( this.beautyRenderTarget );
renderer.clear();
renderer.render( this.scene, this.camera );
this.camera.layers.disable( 1 );
Does this improves the result? The modification should ensure that the grid is honored by the beauty pass but not when the actual AO and blur is applied. But notice that you still have to disable depthWrite for your grid.
It just does not seem logical to me for those materials to contribute to the pass,
The contribution of objects with MeshBasicMaterial is required to compute proper SSAO for other object in the scene. Objects with MeshBasicMaterial also can cast shadows.
Oh, I did not take that into consideration.
But we can agree that the situation showcased by the screenshots faulty ? the line material outputting black for normal buffer ?
Lines and points should probably not be taken into account by SSAOPass. The problem is that the pass relies like many other passes on Scene.overrideMaterial. And this property affects all materials in the scene. So it will require some refactoring to properly exclude points and lines. However, other issues like #20428 might require something similar.
For now, I'm afraid you have to solve this on app level.
Could you point me in some direction, I tried a lot of monkey patching to no avail.
At one point I thought I could get away with having two render passes, and I would separate the editor gizmos from the editor model.
This is a rather quirky requirement by my contractor to have SSAO, when they should bake AO to the models.
Have you tried the approach with the layers? Did it help? I've tested it on my system and the normal pass is not affected anymore by the lines.
I did not read that initial comment, sorry. I will try it thanks for the help.
That suggestion fixed my issue, I tried to be clever and set the layer on a Group of gizmos and failed miserably. Might open issue later.
Not sure if I should close this issue, I will leave to one of the maintainers.
Thanks a lot @Mugen87 for your assistance
I tried to be clever and set the layer on a Group of gizmos and failed miserably.
You have to set the layer of all objects in the group of gizmos.
Not sure if I should close this issue, I will leave to one of the maintainers.
I've renamed it for better tracking. I think it's appropriate to leave it open.
Found another issue with the SSAOPass, I reported it mrdoob/three.js#20445, My current project requirement include toggling orthographic and perspective mode.
private updateSSAOCamera(
enable: boolean,
camera: PerspectiveCamera | OrthographicCamera
) {
const ssao = this._ssao;
const ssaoMaterial = ssao.ssaoMaterial;
const uniforms = ssaoMaterial.uniforms;
const defines = ssaoMaterial.defines;
const camProMat4 = "cameraProjectionMatrix";
const camInvProMat4 = "cameraInverseProjectionMatrix";
defines["PERSPECTIVE_CAMERA"] = enable ? 0 : 1;
uniforms[camProMat4].value.copy(camera.projectionMatrix);
uniforms[camInvProMat4].value.getInverse(camera.projectionMatrix);
ssaoMaterial.needsUpdate = true;
}

Most helpful comment
You could try the following: Move all objects which should not be affected by SSAO to layer 1. E.g:
Then modify the
render()method ofSSAOPasslike so:Does this improves the result? The modification should ensure that the grid is honored by the beauty pass but not when the actual AO and blur is applied. But notice that you still have to disable
depthWritefor your grid.