// ...
const composer = new EffectComposer(renderer)
const renderPass = new RenderPass(scene, viewCamera)
const outputPass = new OutputPass()
const passes = [renderPass, outputPass]
for (const pass of passes) composer.addPass(pass)
requestAnimationFrame(function loop() {
composer.render() // works perfectly
requestAnimationFrame(loop)
})
There are no effect yet. Then when I try to add GTAOPass it breaks:
// ...
const composer = new EffectComposer(renderer)
const renderPass = new RenderPass(scene, viewCamera)
const gtaoPass = new GTAOPass(scene, viewCamera, width, height) // ADDED
const outputPass = new OutputPass()
const passes = [renderPass, gtaoPass, outputPass] // UPDATED
for (const pass of passes) composer.addPass(pass)
const aoBox = new Box3().setFromObject(scene) // ADDED
gtaoPass.setSceneClipBox(aoBox) // ADDED
requestAnimationFrame(function loop() {
aoBox.setFromObject(scene) // ADDED
gtaoPass.setSceneClipBox(aoBox) // ADDED
composer.render() // it breaks, with warnings in console
requestAnimationFrame(loop)
})
And after this seemingly simple update, the scene shows nothing/empty, and I see these warnings in console:
255 [.WebGL-0x1c4411daaa00] GL_INVALID_VALUE: Texture dimensions must all be greater than zero.
WebGL: too many errors, no more errors will be reported to the console for this context.
(Note, in the first example, replacing composer.render() with renderer.render(scene, viewCamera) works perfectly, the scene is working great up until the point where I add GTAOPass)
How are width and height defined? Have you tried to console log the individual params of GTAOPass before the pass is created? You could also try adapting the GTAOPass and GTAOPass examples to compare differences between your current setup, It’s great to see GTAO becoming integrated!
Yeah It was a surprise to me. I could have sworn it was just available on the renderer as well. Maybe the behavior has changed, or maybe the resize observer kicks in before the library has fully initialized or something. Could be a recent change as well. I didn’t bother to check if it magically appears later in the lifecycle.. but who knows.
rare ts L.
common debugger W.