BokehPass resize issue

When I use the BokehPass (GitHub source) like the one used in the DoF example (three.js examples), I don’t know how I can set the correct render target size when I resize the window.

The example doesn’t use a resize handler at all but when I try to implement it, it’s still wrong when I do

renderer.setSize(innerWidth, innerHeight);
composer.setSize(innerWidth, innerHeight);

I also tried to reset the composer or to setSize() on the render target of the composer to no use.
The BokehPass.js implements a function setSize() but it doesn’t do all the things necessary in the shader I think.

If you resize the composer, all passes in the pass chain are resized as well. BokehPass.setSize() is called as well which resizes the internal render target. I think the issue is that BokehPass has an aspect uniform which relies on the aspect ratio of the camera. If you resize the window, camera.aspect is usually updated with a new value. However, the uniform isn’t automatically updated yet. I’ll fix this with a PR: BokehPass: Correctly set `aspect` in `setSize()`. by Mugen87 · Pull Request #27063 · mrdoob/three.js · GitHub

1 Like