Hey everyone,
I did build a custom scene transistion into my app.
When leaving a scene I grab the current rendered texture like this
var oldTex = GetViewport().GetTexture();
var oldWidth = oldTex.GetWidth();
var oldHeight = oldTex.GetHeight();
var scalex = 480.0f / oldWidth;
var scaley = 320.0f / oldHeight;
var img = oldTex.GetData();
img.FlipY();
var tex = new ImageTexture();
tex.CreateFromImage(img);
Global().LastSceneSnapshot = tex;
GetTree().ChangeScene(scene);
The next scene will grab the tex and do an animation with it. But due to the scene load flicker, I am also rendering it on top for a single frame:
var layer = new CanvasLayer();
layer.Layer = 99;
var tmp = new Sprite();
tmp.Texture = tex;
tmp.Position = new Vector2(240, 160);
tmp.Scale = new Vector2(scalex, scaley);
GD.Print(tmp.Scale);
layer.AddChild(tmp);
GetTree().GetRoot().AddChild(layer);
Global().LastSceneLayer = layer;
Global().LastScene = this;
This works perfectly within the editor build, but I have a problem on web builds which is visible in the two attached images.
Before the scene switch is trigger:
And then with the captured texture on top.
The web version has a weird bluriness within the captured texture.
Does anyone have any tips on how to fix this?