Using SAO Ambient pass on two perspective camera's

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?

/cc

It seems you are not updating all camera related data in your code. The material of SAOPass also has the uniforms cameraInverseProjectionMatrix and cameraProjectionMatrix which require updates if you are exchanging the camera. At least when the projection matrix is different. The relevant code section is:

Hey Mugen87, thanks for the info
The uniforms ‘cameraProjectionMatrix’ and ‘cameraInverseProjectionMatrix’ should be updated when calling saoPass.setSize( … , … )

After intensive testing and debugging with dat.gui I found that the SAO was showing in cam2 all the time.
The problem was the SAO settings. I’m using a zoom all feature in my code that was messing up the AO settings. The SAO became very small in cam2 giving the impression there was no SAO.

Regards
Bert