I want to exclude mesh from THREE.SAOPass

I want to exclude mesh from THREE.SAOPass

I am using THREE.SAOPass
I want to exclude some meshes from SAO.
Do you have a good idea?

Source code

this.renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer: true } );

// taa
this.taarenderPass = new THREE.TAARenderPass( this.scene, this.camera );
this.taarenderPass.sampleLevel = 3;
this.taarenderPass.unbiased = true;
this.taarenderPass.enabled = true;
this.composer.addPass( this.taarenderPass );

// sao
this.saoPass = new THREE.SAOPass( this.scene, this.camera, true, true );
this.saoPass.resolution.set(2048, 2048);
this.saoPass.renderToScreen = true;
this.saoPass.enabled = true;
this.composer.addPass( this.saoPass );

It was realized by controlling the display in THREE.SAO Pass.

Can you please explain in more detail what you mean by “controlling the display”? Are you referring to a special property of THREE.SAOPass?

1 Like

The property was not found, so I added it.
Is there a property in SAOPass that excludes certain meshes?

No, the ambient occlusion is always applied to the whole scene.

How does your implementation look like?

Not accurate
But it is a satisfactory level.
Before correction, a frame is displayed with a billboard shape

After the correction, I excluded the billboard.

Actually I have a little problem
As you get closer to the billboard you’ll see the problem
But most don’t notice

1 Like

can you please provide a sample code or something how did you achive this ? i am also trying to do something similar

the solution is actually really simple. Don’t write depth on things that you want to be excluded. AO pass works on the depth buffer, so if an object is not written into it - it will not participate in the pass.

I don’t think it’s quite so simple. If you don’t render an object to the depth buffer then the SAO results of the background object will just render on top of it. Granted that might be good enough in some cases. Instead you probably want to draw the objects you want to exclude after SAO has been applied to the rest of the scene but I’m not sure how easy that is to do here.

1 Like