I’m trying to apply an SAO pass on my Three scene containing two camera’s. I feed cam1 to the composer/render pass when declaring/initializing. All works well. I can see the SAO effect through cam1. When I switch to the second camera using a UI button calling the function UpdateEffectSao , the effect is gone.
It seems the effect can only be bound to one camera.
This is the code
/* EFFECTS*/
const composer = new EffectComposer( renderer );
let renderPass = new RenderPass( scene, cam1);
composer.addPass( renderPass );
const saoPass = new SAOPass( scene, cam1, false, true );
saoPass.params.saoBias = -1;
saoPass.params.saoIntensity = 0.01;
saoPass.params.saoScale = 30;
saoPass.params.saoKernelRadius = 60;
saoPass.params.saoMinResolution = 0;
saoPass.params.saoBlur = true;
saoPass.params.saoBlurRadius = 5;
saoPass.params.saoBlurStdDev = 20;
saoPass.params.saoBlurDepthCutoff = 0.00001;
composer.addPass( saoPass );
function UpdateEffectSao(camera:any)
{
renderPass.camera = camera
saoPass.camera = renderPass.camera
//activeCamera.updateProjectionMatrix()
//activeCamera.cameraInverseProjectionMatrix()
saoPass.setSize(sizes.width, sizes.height)
saoPass.saoMaterial.needsUpdate = true;
if(camera.type == THREE.OrthographicCamera)
saoPass.saoMaterial.defines['PERSPECTIVE_CAMERA'] = 0
else
saoPass.saoMaterial.defines['PERSPECTIVE_CAMERA'] = 1
}
//Calling this by pressing a UI button
UpdateEffectSao(cam2)
//Code in animate frame ......
composer.render()
Is there a special method to achieve this, or do I have to create a seperate composer and render effect for each camera?