Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer.toTexture / clear #16

Open
Makio64 opened this issue Mar 6, 2015 · 2 comments
Open

Composer.toTexture / clear #16

Makio64 opened this issue Mar 6, 2015 · 2 comments

Comments

@Makio64
Copy link
Contributor

Makio64 commented Mar 6, 2015

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!

@spite
Copy link
Owner

spite commented Mar 6, 2015

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

@Makio64
Copy link
Contributor Author

Makio64 commented Mar 6, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants