Wagner
Wagner copied to clipboard
Composer.toTexture / clear
Hi,
I just finished a GodrayPass for Wagner, but I encounter some weird stuff with the renderer.clear and the toTexture.
@composer.renderer.autoClear = false
@composer.renderer.setClearColor(0x333333,1)
@composer.reset()
@composer.renderer.clear()
@composer.render(@occlusion.scene, @camera)
@composer.toTexture(@occlusion.texture)
@godrayPass.params.occlusionTexture = @occlusion.texture
@composer.pass( @godrayPass )
@composer.toTexture(@occlusion.texture)
# Force to render to another texture here
@composer.toTexture(@occlusion.texture2)
@composer.reset()
@composer.renderer.clear()
@composer.render(@scene, @camera)
@blendPass.params.tInput2 = @occlusion.texture
@composer.pass(@blendPass)
@composer.toScreen()
After rendering the occlusionScene + the godray pass I want to blend so I needed to reset / clear / draw the scene but the clear will also clear the latest texture used in composer.toTexture.
To fixed it, I used a second texture so the first one is not clear.. but I'm sure there is a better way wihout this extra renderer.
see the screenshot below where texture & texture2 are render on 2 plane for debugging :

Let me know if I miss something!
I'd need to see how the effect works. Is the code in your forked version?
Nop, not in the forked version, it's write in coffee...
By the way I investigate more and the problem come from this : https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderer.js#L3341
So after composer.reset() we also need to add : @composer.renderer.setRenderTarget(@composer.write) and then the texture use in the toTexture is not overwrite anymore.
I would suggest to put this line as part of the reset function and also call the reset at the initialisation of Wagner to init this.write and this.read without calling composer.reset().