Wagner icon indicating copy to clipboard operation
Wagner copied to clipboard

Composer.toTexture / clear

Open Makio64 opened this issue 10 years ago • 2 comments

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 :

screenocclusion

Let me know if I miss something!

Makio64 avatar Mar 06 '15 01:03 Makio64

I'd need to see how the effect works. Is the code in your forked version?

spite avatar Mar 06 '15 01:03 spite

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().

Makio64 avatar Mar 06 '15 10:03 Makio64