Fading between two scenes


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.


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:


Is it possible to use postprocesses this way?


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:


Thank you very much!

1 Like