I got a wired things.
I want render a normal map from a scene using EffectComposer.
I use the texture from composer.readBuffer.texture
as Mugen said from this post: Post-processing of WebGLRenderTarget
but the texture seems swiching from the first render-pass result to the second if I render the composer every time before render the main scene. Did I do something wrong?
here is the example: switching can be stoped by click the button
ok, I find out that Class Pass property ‘needsSwap’ is set to true by default
so i need to change the shaderpass.needsSwap to false and everything is fine now.
must take writebuffer as the output rendertarget when it is not render to canvas.
three/examples/jsm/postprocessing/Pass.js:
...
function Pass() {
// if set to true, the pass is processed by the composer
this.enabled = true;
// if set to true, the pass indicates to swap read and write buffer after rendering
this.needsSwap = true;// that's the problem this should change to false if u want ,and it's defaults to true
// if set to true, the pass clears its buffer before rendering
this.clear = false;
// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
this.renderToScreen = false;
}
...
ok I will use writeBuffer and set shaderpass needsSwap to false