How to use 2D stretch mode on nested viewports?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By frankjrix

I’m encountering problems inadding a second viewport to render my game in: I’ve been using 2D stretch mode so far, and had no problems whatsoever, but since I added a second viewport “layer” (for postprocessing shaders) a lot of things broke.

Some info on the settings: I’m using a window size of 1920 x 1080 on a 2k monitor specifically to catch “odd pixel issues”, which I had when using viewport stretch mode and were solved by switching to 2D.

I’m getting weird scaling artifacts, quite evident on my pixel art, and the game behaves like it’s using only 2/3 of the screen, offsetting the detected mouse position and stuff. I think that the scaling artifacts are due to the same problem.

In short, could someone help me to make this second viewport management as transparent as possible, and make it behave like the 2D stretch mode?

:bust_in_silhouette: Reply From: Atlinx

You must recreate the viewport stretching script from the engine to achieve this behaviour. Here’s the script I ended up using if this helps anyone else who stumbles upon this problem: