Closed AmeliaWang93 closed 4 years ago
Hey, thanks for trying this. Support for integrating threejs is still fairly rough.
I would have guessed that setting .clear
on the AfterimagePass
would clear the underlying buffers but it looks like it's only clearing those buffers if autoClear is set. This may be a bug in threejs but I'm not familiar enough with it to know for sure. I think a if (this.clear) renderer.clear();
here would work: https://github.com/mrdoob/three.js/blob/a8b0cd49939d140baf864183b238dfe5adbdd310/examples/js/postprocessing/AfterimagePass.js#L58
It looks like it's possible to hack around this by wrapping the passes' render function to add the clear:
const ap = new THREE.AfterimagePass();
ap._realRender = ap.render;
ap.render = function(renderer) {
renderer.setRenderTarget( this.textureComp );
renderer.clear();
this._realRender.apply(this, arguments);
}
composer.addPass(ap);
Thanks a lot. The problem above seems to be solved. But when I add buildings by mapbox and put the cube inside, the cube is always on the top as the picture shows, where the cube should be behind the building. This problem also appears when I use other pass like BloomPass
.
the cube is always on the top as the picture shows, where the cube should be behind the building
This is probably because we are using the depth buffer associated with the main framebuffer to store information about how deep each pixel is, when threejs uses a different framebuffer when using these passes. Unfortunately I don't see a clear way for us to fix this.
@ansis Thanks for your reply.
Thanks a lot. The problem above seems to be solved. But when I add buildings by mapbox and put the cube inside, the cube is always on the top as the picture shows, where the cube should be behind the building. This problem also appears when I use other pass like
BloomPass
.
Could you update the demo? thanks
I change the code from https://docs.mapbox.com/mapbox-gl-js/example/add-3d-model/ and use
THREE.EffectComposer
to add some effect, but the map doesn't show. What should I do if it's necessary to set the renderer.autoClear to true when using customLayer?