Hi everyone,
I am trying to apply Ambient Occlusion (SSAO paired with SSAA) post-processing, however, for some reason it makes the model look very dark. Here is the part of the code that applies post processing:
function initPostprocessing(
composer: EffectComposer,
renderer: WebGLRenderer,
scene: Scene,
camera: PerspectiveCamera,
width: number,
height: number
) {
const ssaoPass = new SSAOPass(scene, camera, width, height);
ssaoPass.kernelRadius = 1;
ssaoPass.minDistance = 0.0001;
ssaoPass.maxDistance = 0.02;
composer.addPass(ssaoPass);
const ssaaRenderPass = new SSAARenderPass(scene, camera);
composer.addPass(ssaaRenderPass);
composer.setPixelRatio(1);
ssaaRenderPass.clearAlpha = renderer.getClearAlpha();
ssaaRenderPass.sampleLevel = 0;
ssaaRenderPass.unbiased = true;
ssaaRenderPass.enabled = true;
/**
* DEBUG
*/
// Init gui
const gui = new GUI();
gui.add(ssaoPass, 'kernelRadius').min(0).max(32);
gui.add(ssaoPass, 'minDistance').min(0.001).max(0.02);
gui.add(ssaoPass, 'maxDistance').min(0.01).max(0.3);
}
And then I render it as follows:
renderer?.setAnimationLoop(() => {
controls.update();
renderer.render(scene!, camera!);
composer.render();
});
Screenshots with and without post-processing:
I tried different things, but couldn’t make it look normal with Ambient Occlusion. Any help is appreciated.
Best regards,
Sergii