Fading between two scenes

Hi,

I have two scenes and I’d like to switch between them with a slider with a fading effect. So as the first scene fades the other one starts to appear.

I’ve tried to solve this with post-processes. I created two custom postprocess with the same shader code for the two scenes. I thought I could fade the scenes independently with the two seemingly independent post processes, but with two post processes present the first scene did not appear at all. The post process itself, with one scene, worked as I expected.

Playground

In desperation, I tweaked some settings that seemed somewhat relevant (commented lines in pg), but all I could get is an error, that went over my head:

image

Is it possible to use postprocesses this way?

THanks!

Welcome aboard!

What you need to do is to generate the first scene in a texture, then mix that texture with the 2nd scene.

To do that:

  • you can create a “pass” post-process for the first scene and use effect.setTextureFromPostProcess to bind this texture to the shader that will mix the textures
  • update your “Fade” shader to mix the two textures

Here’s an updated PG:

9 Likes

Thank you very much!

1 Like