I currently have this page turn effect between levels. Levels are broken up into scenes, and right now I have to additively lood the new level, move everything to a separate layer so the first camera doesn't render the next level, play the transition, then reset all the layers and reset the camera. This would be a ton easier in Godot so I'm wondering if this is actually a limitation of Unity? Or is there a simpler way to do this? I can post the relevant code soon.
#Simple way to transition between levels seamlessly?
1 messages · Page 1 of 1 (latest)
No simple way comes to my mind. Technically, you could try making a screenshot of your last frame and then merging both with some post-process effect.
That's essentially what I'm doing -- rendering both cameras to two separate render textures and combining them using an animated UV map
The janky part comes from having to juggle two scenes at the same time and having to move the second scene to an entirely different layer in order for stuff to not render twice
If the state of the previous scene doesn't change, then screenshoting it should be enough. It would be more performant than having 2 cameras at once.
Instead of messing with layers you may also consider simply disabling the root gameobjects (assuming that no gameobjects has to be enabled in the meantime).
They have to be enabled because I'm rendering them
Also I can't screenshot the first scene because the next scene gets loaded as soon as the corner curls up. The player can still move around in the first scene while the second scene is shown
The reason I'm currently messing with the layers is because I need the gameobjects in the second scene to be rendered by the second camera but not the first camera
The only way I'd be able to use a screenshot is if I screenshot the second scene. Which is doable, I'd probably prerender them as image assets then load the next scene after the page finishes turning. I'd only do that if there's an easy way to automatically render the first frame of each scene to an image file though. Otherwise it's basically the same amount of work to load the next scene, move the layers, screenshot it, disable it, reset layers, then reenable it once the transition finishes
Though I suppose that's still marginally better than rendering both at the same time 🤔
rendertexture
They keep the last rendered texture forever?
you capture once with the camera then don't clear it
https://docs.unity3d.com/ScriptReference/Texture2D.ReadPixels.html
Otherwise explicitly writing the pixels with this API
It's the slowest but for one frame not a big deal usually. It recommends other stuff in that page
I also wouldn't be doing that at runtime anyway
Oh wait I would need to because I can't guarantee the same state each time for all scenes